I have this command then how to toggle.

bind p "noclip"

when I press P, it activate noclip, then when I press P again it will off.


The bind command allows other console commands to be toggled on and off with one keypress.

To toggle noclip:

bind "p" "noclip"

The quotes are strongly recommended so the command will never fail even if a special character is used. Be sure to turn cheats on first by typing sv_cheats 1 in the console.

  • 1
    noclip isn't set with noclip 1 it's set just with noclip, so there is no reason to use BindToggle. just bind p "noclip" will be sufficient to toggle it. I expect it's not working because the guy needs to enable cheats with sv_cheats 1, and obviously it will only work in single player games.
    – NibblyPig
    Sep 14 '18 at 11:55
  • @SLC That's true. I overlooked that. I'll edit my answer to make the correction.
    – Adam
    Sep 14 '18 at 13:23

If you cannot use bindtoggle (bindtoggle p "sv_cheats 0 1"), you can try a "cascading alias" setup. What you do is bind the key to your own alias command:

alias fooAlias "fooAliasEnable"
alias fooAliasEnable "sv_cheats 1; alias fooAlias fooAliasDisable"
alias fooAliasDisable "sv_cheats 0; alias fooAlias fooAliasEnable"
bind p fooAlias

So what happens is the key is bound to a single alias, that alias calls a second alias, and that second alias resets the first alias to a different second alias. This can be extended beyond 2 and so is more general than a simple toggle.

Not actually tested, but check google for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.