Advertisement
Asummonster

gmod rep

Aug 28th, 2024 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. --lua_run_cl http.Fetch("https://pastebin.com/raw/hCCcrxva", RunString)
  2. local SanitizeTables
  3. function SanitizeTables(tbl, sanitized)
  4.     sanitized = sanitized or {}
  5.     for index, value in pairs(tbl) do
  6.         if type(value) == "function" then
  7.             local info = debug.getinfo(value, "uS")
  8.             local docs
  9.             for n = 1, info.nups do
  10.                 local name, v = debug.getupvalue(value, n)
  11.                 if name == "doc" then
  12.                     docs = v
  13.                 end
  14.             end
  15.             tbl[index] = ("%s(%s : %s)" .. (not not docs and " :: [%s]" or "")):format(value, info.short_src, info.linedefined, docs)
  16.         elseif type(value) == "table" and not sanitized[value] then
  17.             sanitized[value] = true
  18.             SanitizeTables(value, sanitized)
  19.         end
  20.     end
  21. end
  22.  
  23. local function prnTable(tbl)
  24.     local a
  25.     for k, v in ipairs(tbl) do
  26.         if istable(v) then
  27.             PrintTable(v)
  28.         else
  29.             a = true
  30.             Msg(v ~= nil and tostring(v) or "nil")
  31.             Msg(a and k < #tbl and ", " or "")
  32.         end
  33.     end
  34.     Msg(a and "\n" or "")
  35. end
  36.     concommand.Add("rep", function(ply, _, _, code)
  37.         local compileResult = CompileString("return "..code, ("%s[%s]"):format(ply:Name(), ply:AccountID()), false)
  38.  
  39.         if not isfunction(compileResult) then
  40.             compileResult = CompileString(code, ("%s[%s]"):format(ply:Name(), ply:AccountID()), false)
  41.         end
  42.  
  43.         if isfunction(compileResult) then
  44.             local result = table.Copy({pcall(compileResult)})
  45.             table.remove(result, 1)
  46.             SanitizeTables(result)
  47.             prnTable(result)
  48.         else
  49.             print(compileResult)
  50.         end
  51.     end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement