Half-Life Console Help

Basic Script Types: Toggle-To-Momentary
Conversely, you may want to change a toggle command into a momentary one. Here's an example script that enables chase-cam mode only while you hold down the 'x' key. Releasing 'x' returns to normal first-person view. Without this script, you'd have to toggle the chase_active variable by setting it to "1" or "0":
alias +chaseon "chase_active 1"
alias -chaseon "chase_active 0"
bind x +chaseon
chase_active 0
Here we're defining a new +command with the alias definition for +chaseon (which turns on chase-cam mode). Of course, we have to define the corresponding -command too (which should turn off chase-cam mode). We only have to bind a key to the +command (+chaseon) and the game will automatically bind the release of the x key to the corresponding -command (-chaseon in this example). Because both of the chase_active settings are inside alias definitions, it's value is indeterminate until x is pressed, so it's a good idea to set your preferred default, as is done in this example with chase_active 0 on the line by itself.
 
[Previous Page] [Back to Console Index] [Next Page]