Blocking a Console Command

For my gamemode, I need to disable ducking and jumping. This is my code so far:
[lua]
function GM:PlayerBindPress(Player, Bind, bPressed)
if(string.find(Bind, “jump”) or string.find(Bind, “duck”)) then
return true
end
end
[/lua]

But that doesn’t disable it being ran from console. I don’t think I can run alias on the player, because that would screw up the commands until they restart the game.

Since you’re already doing that client-side, I’d recommend this.

[lua]function GM:CreateMove( ucmd )
local btn = ucmd:GetButtons()
if btn & IN_JUMP ~= 0 then
btn = btn - IN_JUMP
end
if btn & IN_DUCK ~= 0 then
btn = btn - IN_DUCK
end
ucmd:SetButtons( btn )
end[/lua]

hook.Add(“Think”, “DuckCheck”, function(ply) if ply:Crouching() then ply:Kick(“CrouchExploitation”) end end);

Along with the other stuff and some stuff for jumping.

Works perfect, thanks. Just for future reference though, how would I disable a console command like slot1-10?

My method only works for IN_ keys, as listed here. You’ll have to use another method for other keys.

Try with gm_concmdhook

Won’t work because you can’t force clients to download dll’s.

The hook is server-side too. You can use the example to get the player object from the IP address argument.

I mean that It won’t stop clients from running console commands, afaik the IN_KEYS aka binds are not being send directly to the server on press, they are being send in user commands as seen above.

So using the module would be pointless.