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.
[QUOTE=raBBish;27127937]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][/QUOTE]
Works perfect, thanks. Just for future reference though, how would I disable a console command like slot1-10?
[QUOTE=PortalGod;27128180]Works perfect, thanks. Just for future reference though, how would I disable a console command like slot1-10?[/QUOTE]
My method only works for IN_ keys, as listed [url=http://wiki.garrysmod.com/?title=IN_KEYS]here[/url]. You'll have to use another method for other keys.
Try with [url=http://www.facepunch.com/threads/994287]gm_concmdhook[/url]
[QUOTE=Loures;27128392]Try with [url=http://www.facepunch.com/threads/994287]gm_concmdhook[/url][/QUOTE]
Won't work because you can't force clients to download dll's.
[QUOTE=Wizard of Ass;27128876]Won't work because you can't force clients to download dll's.[/QUOTE]
The hook is server-side too. You can use the example to get the player object from the IP address argument.
[QUOTE=raBBish;27129183]The hook is server-side too. You can use the example to get the player object from the IP address argument.[/QUOTE]
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.
Sorry, you need to Log In to post a reply to this thread.