CapsAdmin

Untitled

Oct 27th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. console.AddCommand("trace_calls", function(_, line, ...)
  2.     line = "_G." .. line
  3.     local ok, old_func = assert(pcall(assert(loadstring("return " .. line))))
  4.  
  5.     if ok and old_func then
  6.         local table_index, key = line:match("(.+)%.(.+)")
  7.         local idx_func = assert(loadstring(("%s[%q] = ..."):format(table_index, key)))
  8.        
  9.         local args = {...}
  10.        
  11.         for k, v in pairs(args) do
  12.             args[k] = select(2, assert(pcall(assert(loadstring("return " .. v)))))
  13.         end
  14.                
  15.         idx_func(function(...) 
  16.            
  17.             if #args > 0 then
  18.                 local found = false
  19.                
  20.                 for i = 1, select("#", ...) do
  21.                     local v = select(i, ...)
  22.                     if args[i] then
  23.                         if args[i] == v then
  24.                             found = true
  25.                         else
  26.                             found = false
  27.                             break
  28.                         end
  29.                     end
  30.                 end
  31.                
  32.                 if found then
  33.                     debug.trace()  
  34.                 end
  35.             else
  36.                 debug.trace()
  37.             end
  38.            
  39.             return old_func(...)
  40.         end)
  41.        
  42.         timer.Delay(1, function()
  43.             idx_func(old_func)
  44.         end)
  45.     end
  46. end)
Advertisement
Add Comment
Please, Sign In to add comment