Overview
Basic guide on how binds and aliases work and their syntax.
What is a Bind?
To understand what an Alias is we have to know first how a bind works. A bind is a key linked to a command. Everytime we press this key it will execute the command as if we were typing it on console. This only works while you’re connected to a server.
To use binds we either:
- Type them on console.
- Write them in a .cfg file such as userconfig.cfg located in Half-Lifevalve (if you don’t have it, you can create it), which can be opened with notepad in the following format: bind key command.
Syntax:
Example:
bind f12 quit
Result:
Pressing “f12” on a server will execute the command “quit” which exits the game.
But what if we want to use a variable or a complex command consisting of more than one part? Then we use quotation marks (” “) to tell the game that we want to execute everything between them.
Example:
bind f “r_drawviewmodel 0”
bind x “say Hello people”
In the first example, pressing “f” would hide our weapon.
In the second example, pressing “x” would print on chat “Hello people”
And we can also bind more than one command to a key, again, with quotation marks (” “) but this time we’ll also use semicolons (;) to indicate that there is more than one command in our bind.
Example:
bind t “say Taking a snapshot;snapshot”
Result:
By pressing “t” it will print on chat “Taking a snapshot” and immediately after this it will take a snapshot.
Notes:
- We can bind any key we want.
- The bound key (in this case “f12”, “x”, “f” and “t”) must be written in lowercase.
- If the command consists of only one word, you don’t need to use quotation marks (” “).
- We can add more commands to the same bind by adding more semicolons (;) between each command.
What is an Alias?
An Alias is a chain of commands for different purposes. Like binds, they should be written in a .cfg file such as userconfig.cfg located in Half-Lifevalve (if you don’t have it, you can create it), which can be opened with notepad. We will categorize them in four different types:
- Simple: useful for multiple commands and shorten commands.
- Toggle: useful for booleans (ON/OFF).
- Cyclic: useful for multiple variables.
- Held-down (+/-): useful for short-use commands.
Each of these four types of Alias has a different syntax that must be followed to properly execute it. Let’s see one by one how they work.
Notes:
- Unlike binds, aliases cannot be written on console.
- Aliases can have a custom name you chose. Example: alias test1
- Aliases can be bound using command bind. The part of the alias that should be bound is the custom name you chose. Example: bind key test1
Type 1: Simple
This kind of alias assigns a name to group of commands. They can be as much commands as you want.
Syntax:
Syntax Explanation:
- The command alias is assigning a name (aliasname) to a group (” “) of two commands: command1 followed (;) by command2.
Example:
alias hello “say Hi people;say_team Let’s play”
bind h hello
Result:
Pressing “h” executes the alias “hello”, which consists of two commands which send a chat message to everybody on the server saying “Hi people” and another message to our teammates saying “Let’s play”.
Notes:
With this type of alias we can also shorten long commands:
Example:
alias dis disconnect
bind f1 dis
alias bar “model barney”
bind f2 bar
Result:
Pressing “f1” (or typing “dis” on console) will disconnect you from the server.
Pressing “f2” (or typing “bar” on console) will change your model to “barney”.
Type 2: Toggle
With this kind of alias we can create ON/OFF kind of binds (using 1/0 variables). Pressing the bound key once will enable something, pressing it again would disable it or vice versa.
Syntax:
Syntax Explanation:
- Line 1: The command alias is assigning a name (aliasname) to an alias (alias1).
- Line 2: The command alias is assigning alias1 a variable (variable 1), then (;) the command alias reassigns the same name (aliasname) to a different alias (alias2).
- Line 3: The command alias is assigning alias2 a different variable (variable 2), then (;) the command alias reassigns the same name (aliasname) to its original alias (alias1).
Example:
alias fps fps1
alias fps1 “cl_showfps 1;alias fps fps2”
alias fps2 “cl_showfps 0;alias fps fps1”bind o fps
Result:
Pressing “o” once will show our FPS (frames per second) on screen. Pressing it again will hide them.
Type 3: Cyclic
This kind of alias is basically the same as “Toggle” one but we’re gonna add more variables to it. By doing this we’ll be able to rotate between multiple variables/values easily.
Syntax:
Syntax Explanation:
Same as “Toggle” but adding a third variable (or more).
Example:
alias nick nick1
alias nick1 “name GordonFreeman;alias nick nick2”
alias nick2 “name BarneyCalhoun;alias nick nick3”
alias nick3 “name Dr.Coomer;alias nick nick1”bind n nick
Result:
Pressing “n” on a server will change our name to “GordonFreeman”, pressing it again will change it to “BarneyCalhoun”, and a third time will change it to “Dr.Coomer”. After this, pressing “n” will repeat the cycle.
Notes:
You can add as many variables as you want, just make sure the last one goes back to the first one for it to repeat the cycle. It should look like this:
;alias aliasname alias1″
Type 4: Held-down (+/-)
These aliases work in a different way. They either:
- Execute a command while the bound key is being pressed. Once you release the key it executes the same command once again to cancel it.
- Execute a command/variable while the bound key is being pressed. Once you release the key it executes an opposite command/variable to cancel the first one.
Syntax 1:
Syntax Explanation:
- Line 1: The command alias is assigning a name (aliasname) to a variable (variable 1) which will be executed while the bound key is pressed (+).
- Line 2: The command alias is assigning the same name (aliasname) to a different variable (variable 2) which will be executed once the bound key is released (–).
Example:
alias +hideweapon “r_drawviewmodel 0”
alias -hideweapon “r_drawviewmodel 1”bind z +hideweapon
Note that when binding this kind of aliases we also include the + in our bind.
Result:
Holding “z” will hide your weapon model, releasing it will show it again.
Syntax 2:
Syntax Explanation:
- Line 1: The command alias is assigning a name (aliasname) to a command (command1) which will be executed once the bound key is pressed (+).
- Line 2: The command alias is assigning the same name (aliasname) to a different command (command2) which will be executed once the bound key is released (–).
Example:
alias +realnames loadauthid
alias -realnames unloadauthidbind m +realnames
Note that when binding this kind of aliases we also include the + in our bind.
Result:
Holding “m” (while seeing scores) will show players’ real names, releasing it will stop showing them (this alias doesn’t work in default HL but it was used as an example).
Syntax 3:
Syntax Explanation:
- Line 1: The command alias is assigning a name (aliasname) to a group (;) of non-stop (+) commands (+command1 and +command2) which will be executed when the bound key is pressed (+).
- Line 2: The command alias is assigning the same name (aliasname) to a group (;) of stop (–) commands (-command1 and -command2) which will be executed when the bound key is released (–).
Example:
alias +walkandshoot “+forward;+attack”
alias -walkandshoot “-forward;-attack”bind j +walkandshoot
Note that when binding this kind of aliases we also include the + in our bind.
Result:
Holding “j” will make the player walk forward and shoot, releasing it will make the player stop moving and shooting.
The “wait” command
We learnt how to use binds and aliases, but we may encounter some problems when using them. You may notice that some commands are not being executed even if syntaxes were properly followed. This happens because certain commands cannot be executed right after another one was.
In order to fix this we have to make a short pause (of specifically one tick) between one and another by using the command wait.
Example:
alias score_snapshot “+showscores;snapshot;-showscores”
bind p score_snapshot
Result:
This alias is supposed to show the score table (+showscores), then (;) take a snapshot, then (;) hide the score table (-showscores). But it doesn’t work properly. Using it just takes a snapshot but it doesn’t show the score table.
Now let’s try using the command wait:
Example:
alias score_snapshot “+showscores;wait;wait;snapshot;wait;wait;-showscores”
bind p score_snapshot
Result:
Now it does work. And as you may have noticed, the command wait was used four times in two different parts of the alias. This is because sometimes one wait (one tick) is not enough (the execution of the rest of the commands is still too fast).
Notes:
- Depending on the bind/alias you’re writing, you may need to use wait more than one or two times.
The “wait” table
Since writing “wait;wait;wait;wait” and so on multiple times results annoying and time consuming, you can add these “wait” tables to your .cfg file for you to shorten the wait command and make the process less tedious.
Wait Table 1:
alias wait2 “wait;wait”
alias wait4 “wait2;wait2”
alias wait8 “wait4;wait4”
alias wait16 “wait8;wait8”
alias wait32 “wait16;wait16”
alias wait64 “wait32;wait32”
alias wait128 “wait64;wait64”
Example:
alias score_snapshot “+showscores;wait2;snapshot;wait2;-showscores”
bind p score_snapshot
Wait Table 2:
alias w1 “wait”
alias w2 “w1;w1”
alias w3 “w2;w1”
alias w4 “w2;w2”
alias w5 “w4;w1”
alias w6 “w3;w3”
alias w7 “w6;w1”
alias w8 “w4;w4”
alias w9 “w7;w2”
alias w10 “w5;w5”
alias w11 “w9;w2”
alias w12 “w6;w6”
alias w13 “w9;w4”
alias w14 “w9;w5”
alias w15 “w9;w6”
alias w16 “w9;w7”
alias w17 “w9;w8”
alias w18 “w9;w9”
alias w19 “w9;w10”
alias w20 “w9;w11”
alias w21 “w9;w12”
alias w22 “w9;w13”
alias w23 “w9;w14”
alias w24 “w9;w15”
alias w25 “w9;w16”
alias w26 “w9;w17”
alias w27 “w9;w18”
alias w28 “w9;w19”
alias w29 “w9;w20”
alias w30 “w9;w21”
alias w31 “w9;w22”
alias w32 “w9;w23”
alias w33 “w9;w24”
alias w34 “w9;w25”
alias w35 “w9;w26”
alias w36 “w9;w27”
alias w37 “w9;w28”
alias w38 “w9;w29”
alias w39 “w9;w30”
alias w40 “w9;w31”
alias w41 “w9;w32”
alias w42 “w9;w33”
alias w43 “w9;w34”
alias w44 “w9;w35”
alias w45 “w9;w36”
alias w46 “w9;w37”
alias w47 “w9;w38”
alias w48 “w9;w39”
alias w49 “w9;w40”
alias w50 “w9;w41”
alias w51 “w50;w1”
alias w52 “w50;w2”
alias w53 “w50;w3”
alias w54 “w50;w4”
alias w55 “w50;w5”
alias w56 “w50;w6”
alias w57 “w50;w7”
alias w58 “w50;w8”
alias w59 “w50;w9”
alias w60 “w50;w10”
alias w61 “w50;w11”
alias w62 “w50;w12”
alias w63 “w50;w13”
alias w64 “w50;w14”
alias w65 “w50;w15”
alias w66 “w50;w16”
alias w67 “w50;w17”
alias w68 “w50;w18”
alias w69 “w50;w19”
alias w70 “w50;w20”
alias w71 “w50;w21”
alias w72 “w50;w22”
alias w73 “w50;w23”
alias w74 “w50;w24”
alias w75 “w50;w25”
alias w76 “w50;w26”
alias w77 “w50;w27”
alias w78 “w50;w28”
alias w79 “w50;w29”
alias w80 “w50;w30”
alias w81 “w50;w31”
alias w82 “w50;w32”
alias w83 “w50;w33”
alias w84 “w50;w34”
alias w85 “w50;w35”
alias w86 “w50;w36”
alias w87 “w50;w37”
alias w88 “w50;w38”
alias w89 “w50;w39”
alias w90 “w50;w40”
alias w91 “w50;w41”
alias w92 “w50;w42”
alias w93 “w50;w43”
alias w94 “w50;w44”
alias w95 “w50;w45”
alias w96 “w50;w46”
alias w97 “w50;w47”
alias w98 “w50;w48”
alias w99 “w50;w49”
alias w100 “w50;w50”
alias w200 “w100;w100”
alias w300 “w200;w100”
alias w400 “w200;w200”
alias w500 “w400;w100”
alias w600 “w300;w300”
alias w700 “w600;w100”
alias w800 “w400;w400”
alias w900 “w700;w200”
alias w1000 “w500;w500”
Example:
alias score_snapshot “+showscores;w2;snapshot;w2;-showscores”
bind p score_snapshot
Notes:
- Even if both tables do basically the same, it would be better to have both written in a.cfg file such as userconfig.cfg located in Half-Lifevalve, since most aliases that you can find on internet require them.