ST-CS-10-339-75
March 2002

4.  Binds and Aliases  (U)

When a player presses a key in Half-life and something happens, it is because that key has been "bound" to a command. For example, the up arrow key is bound to the move forward command.

Every command in Half-life can also be directly executed from the console. The console is a text interface to Half-life which is only available if the hl.exe program is started with the argument "-console". Normally, pressing the "`" key (top left of the keyboard, to the left of the "1" key) displays the console on screen.

Half-life also supports aliases. An alias is a name which when typed in the console, executes a whole series of commands, one after the other. Players use the alias command to tell Half-life which commands to execute for a given alias name. Usefully, aliases can be bound to a key so a whole series of commands - such as buy gun, buy ammo, buy armour - can be made to happen at the press of one key.

Finally, Half-life can also execute scripts - text files on disk which are lists of commands - using the exec command. Typically, players store their aliases in a text file or two, execute those text files so Half-life loads the aliases, and then have keys bound to execute those aliases in-game. This is how buy scripts work.

alias (alias name) (command)
The commands listed in command are executed when the alias name is executed in the console or via the bind command.
bind (key) (command or alias name)
When the given key is pressed, the command or the alias specified is executed.
echo (string)
The string is printed in the console.
exec (filename)
The filename is assumed to be a half-life script and is executed.
unbind (key)
The command bound to the key with the bind command is removed and so no longer occurs when the key is pressed. This command is the opposite of the bind command.
unbindall
All commands bound to all keys are removed.