I just had a question about possibilities relating to overriding or rewriting a base function thats run by the game, to filter out certain returns.
What i mean is, by example, say i were to overwrite the RunConsoleCommand() function to filter out certain console commands.
I know how to do that, but what im unsure of is how to change how a hook runs, because I wanna change the PlayerBindPress hook so that all functions running on that hook filter out certain binds,
can someone please help?
Bump
[lua]
function RunConsoleCommand(cmd)
print("Denied - " .. cmd)
return;
end
[/lua]
[lua]
oldRunConCmd=RunConsoleCommand
local NoCmdz={"disconnect","connect","bind")
function RunConsoleCommand(cmd)
if table.HasValue(NoCmdz,cmd) then Msg("Idunno lol "..cmd) else
oldRunConCmd(cmd) end
end
[/lua]
I dunno, this is how I would do it. It's still missing the arguments for the command though, which is a problem. I'm not sure how the official RunConsoleCommand does it.
[lua]
local blocked = {"kickMe"};
function RunConsoleCommand(cmd,...)
for a,b in pairs(blocked)do
if(cmd==b)then
print("Command Blocked - " .. cmd);
return false;
end
end
concommand.Run(LocalPlayer(),cmd,...);
end
[/lua]
PrintTable(...) to see the arguments IRRC.
"say i were to overwrite the RunConsoleCommand() function to filter out certain console commands.
I know how to do that, but what im unsure of is how to change how a hook runs"
Please read that..
What hook are you trying to Override?
He means how a hook is called.
You just overwrite the function but most, if not all hook calls are included in the GMod base (c++).
Sorry, you need to Log In to post a reply to this thread.