CapsAdmin

Untitled

Nov 24th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local hooks = {}
  2.  
  3. local function func_hook(tag, tbl, func_name, type, func)
  4.     local old = hooks[tag] or tbl[func_name]
  5.    
  6.     if type == "pre" then
  7.         tbl[func_name] = function(...)
  8.             local args = {func(...)}
  9.             if args[1] == false then return end
  10.             return old(select(2, unpack(args)))
  11.         end
  12.     elseif type == "post" then
  13.         tbl[func_name] = function(...)
  14.             local args = {old(...)}
  15.             if func(unpack(args)) == false then return end
  16.             return unpack(args)
  17.         end
  18.     end
  19. end
  20.  
  21. function test(a,b,c)
  22.     epoe.Print(a,b,c)
  23. end
  24.  
  25. test(1, 2, 3)
  26.  
  27. func_hook("test_detour", _G, "test", "pre", function(a, b, c)
  28.     return nil, c, b, a
  29. end)
  30.  
  31. test(1, 2, 3)
Advertisement
Add Comment
Please, Sign In to add comment