Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hooks = {}
- local function func_hook(tag, tbl, func_name, type, func)
- local old = hooks[tag] or tbl[func_name]
- if type == "pre" then
- tbl[func_name] = function(...)
- local args = {func(...)}
- if args[1] == false then return end
- return old(select(2, unpack(args)))
- end
- elseif type == "post" then
- tbl[func_name] = function(...)
- local args = {old(...)}
- if func(unpack(args)) == false then return end
- return unpack(args)
- end
- end
- end
- function test(a,b,c)
- epoe.Print(a,b,c)
- end
- test(1, 2, 3)
- func_hook("test_detour", _G, "test", "pre", function(a, b, c)
- return nil, c, b, a
- end)
- test(1, 2, 3)
Advertisement
Add Comment
Please, Sign In to add comment