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.
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.
If you cannot use
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.