-
-
Save zippy36jr/2e35537f406468b19236347fc5599ac9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- INSTALLATION INSTRUCTIONS: | |
-- 1) copy this file into garrysmod/lua/diagnostic-dump.lua creating the file if it does not exist | |
-- 2) run the script by loging into your rcon or commandline and typing lua_openscript diagnostic-dump.lua | |
-- 3) copy the text in garrysmod/data/diagnostic-dump.txt and upload it to hastebin.com or pastebin.com and provide it as a link in your | |
-- support ticket. | |
local dumpers = {} | |
local biggestHeaderLength = 0 | |
local function dumpFunction(func) | |
local info = debug.getinfo(func) | |
local str = {} | |
for i = 1, info.nparams do | |
table.insert(str, "_") | |
end | |
if info.isvararg then | |
table.insert(str, "...") | |
end | |
str = {(info.what or "unknown") .. "@" .. (info.short_src or "unknown"), "(", table.concat(str, ", "), ")"} | |
return table.concat(str, "") | |
end | |
local function registerDump(title, func) | |
if string.len(title) > biggestHeaderLength then | |
biggestHeaderLength = string.len(title) | |
end | |
table.insert(dumpers, { | |
title = title, | |
func = func | |
}) | |
end | |
registerDump("SERVER STATS", function(write) | |
write(" - APP TIME: " .. tostring(system.AppTime()) .. '\n') | |
write(" - COUNTRY: " .. tostring(system.GetCountry()) .. '\n') | |
write(" - IS LINUX: " .. tostring(system.IsLinux()) .. '\n') | |
write(" - IS OSX: " .. tostring(system.IsOSX()) .. '\n') | |
write(" - IS WINDOWS: " .. tostring(system.IsWindows()) .. '\n') | |
write(" - HOSTNAME: " .. tostring(GetHostName())) | |
end) | |
registerDump("HOOK DATA", function(write) | |
for hookName, hooks in pairs(hook.GetTable()) do | |
write(hookName .. "\n") | |
for id, func in pairs(hooks) do | |
write("\t" .. id .. " : " .. dumpFunction(func) .. "\n") | |
end | |
end | |
end) | |
registerDump("ADDON LIST DUMP", function(write) | |
-- dump a list of the installed addons | |
do | |
write("------------------\n") | |
write(" ADDON LIST DUMP \n") | |
write("------------------\n") | |
local _, addons = file.Find('addons/*', 'MOD') | |
for k, dir in pairs(addons) do | |
write('addon: ' .. dir .. '\n') | |
end | |
write('\n\n') | |
local function scan(tab, dir) | |
local files, dirs = file.Find(dir..'/*', "MOD") | |
for k, file in pairs(files) do | |
write(tab .. " - " .. file .. "\n") | |
end | |
for k, _dir in pairs(dirs) do | |
write(tab .. " - " .. _dir .. "/\n") | |
scan(tab .. "\t", dir .. "/" .. _dir) | |
end | |
end | |
scan("", "addons") | |
end | |
end) | |
registerDump("GLOBAL TABLES NAMES", function(write) | |
local namesOfInterest = {'nlr', 'pnlr', 'pf4', 'phud', 'ulx'} | |
for k, v in pairs(_G) do | |
if type(k) ~= 'string' or type(v) ~= 'table' then continue end | |
write(' - ' .. k .. '\n') | |
end | |
end) | |
registerDump("GAMEMODE TABLE", function(write) | |
for k,v in pairs(GAMEMODE) do | |
if type(v) ~= 'function' then | |
write(tostring(k) .. ' - [' .. (type(v)) .. ']:' .. tostring(v) .. '\n') | |
end | |
end | |
for k,v in pairs(GAMEMODE) do | |
if type(v) == 'function' then | |
write(tostring(k) .. ' - ' .. dumpFunction(v) .. '\n') | |
end | |
end | |
end) | |
do | |
local hbar = '-' | |
local prepad = ' ' | |
for i = 1, biggestHeaderLength + 4 do | |
hbar = hbar .. '-' | |
end | |
local f = {} | |
local function write(a, ...) | |
if a == nil then return end | |
table.insert(f, tostring(a)) | |
write(...) | |
end | |
for k,v in ipairs(dumpers) do | |
write( | |
'\n\n' .. hbar .. '\n', | |
prepad .. v.title .. '\n', | |
hbar .. '\n' | |
) | |
local succ, error = pcall(v.func, write) | |
if not succ then | |
write("ERROR IN DUMP SCRIPT!!! HALT!!! PROBLEM!!!\n") | |
write(tostring(error)) | |
end | |
end | |
file.Write('diagnostic-dump.txt', table.concat(f)) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment