local h = {
hooks = {},
};
local null = function() end
function h.detour(typ)
h.hooks[typ] = {};
local ofunc = GAMEMODE[typ] || null;
GAMEMODE[typ] = function(self, ...)
ofunc(self, ...);
for k,v in next, h.hooks[typ] do
local ret1, ret2, ret3, ret4 = v(...);
if(ret1) then return ret1, ret2, ret3, ret4; end
end
end
end
function h.Add(typ, func)
if(!h.hooks[typ]) then
h.detour(typ);
end
h.hooks[typ][ #h.hooks[typ] + 1 ] = func;
end
--example:
h.Add("Think", function() print("nice"); end);