• How to use StartCommand to disable the use of + attack, + duck, + jump and the l
    7 replies, posted
How to use StartCommand to disable the use of + attack, + duck, + jump and the like.
Use createmove and CUserCmd/SetButtons
Player/ConCommand GM/StartCommand Category aaaaand IN Enumerations those should all be helpful
i need any example
hook.Add("StartCommand", "NullControl", function(ply, CUserCmd) local ply = LocalPlayer() for k,v in pairs(player.GetAll()) do     if v:Alive() then         CUserCmd:ClearMovement()         CUserCmd:RemoveKey( 1 ) --See: https://wiki.garrysmod.com/page/Enums/IN         CUserCmd:RemoveKey( 2 )         CUserCmd:RemoveKey( 4 )         end     end end)
Thats not how you'd use it. This hook is on a per-player basis, so there's no need to cycle through every player in it to disable it. You should also use the actual IN_ enum for good practice, they almost 100% will never be changed, but you never know. Correct usage would be(this would be in a shared file): hook.Add("StartCommand", "DisableFunctions", function(ply, cmd)     cmd:RemoveKey(IN_ATTACK);     cmd:RemoveKey(IN_ATTACK2);     cmd:RemoveKey(IN_JUMP);     cmd:RemoveKey(IN_DUCK); end)
Thanks for explaining. I'm still forming habits so I don't always know the best way to write it.
Many thanks for your answers. Including @LearningLua for an answer in my two threads.
Sorry, you need to Log In to post a reply to this thread.