Half-Life

Half-Life

42 ratings
How to create Binds and Aliases
By nu
Basic guide on how binds and aliases work and their syntax.
   
Award
Favorite
Favorited
Unfavorite
Where do I write my binds/aliases?
Go to Half-Life\valve and create a text file named "userconfig.cfg" (change the format from .txt to .cfg). Open it with notepad and write there every single bind or alias you create. It is important to write them line by line in the following format: bind key command and alias aliasname "chain of commands".

Example:

//Binds
bind f weapon_gauss
bind t weapon_crossbow

//Aliases
alias example "say this is an example;snapshot" //Says something and takes a snapshot
alias example2 "say this is another example;disconnect" //Says something and disconnects

Notes:

  • You can give a different name to your config file, such as yourname.cfg but the game will not read it automatically, and every time you open the game you'll have to type on console the following command for it to do so: exec yourname.cfg. Another option is naming it yourname.cfg anyways and writing exec yourname.cfg in userconfig.cfg.
  • Everything you write there, valid or not, will be read by the game as a command or script. In order to make comments or simply put a title to each section of your config file you should begin with "//". In other words, everything written after "//" on a line will not be read by the game.

What is a Bind?
A bind is a key linked to a command. Every time we press this key it will execute the command as if we were typing it on the console. This only works while you're connected to a server.

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, a boolean 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.
  • We can unbind (on console) any key we already bound by using the command unbind followed by the key. Example: unbind f.
What is an Alias?
An Alias is a chain of commands for different purposes. We will categorize them into four different types:

  • Simple: useful for multiple commands and shorten commands.
  • Toggle: useful for booleans (ON/OFF).
  • Cyclic: useful for multiple values of a variable.
  • Held-down (+/-): useful for short-use commands.

Notes:

  • Aliases can have a custom name you chose. Example: alias test1
  • Aliases can be bound using the command bind. The part of the alias that should be bound is the custom name you chose. Example: bind key test1

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.
Type 1: Simple
This kind of alias assigns a name to a group of commands. They can be as many commands as you want, but if you're gonna use several commands make sure you use the wait command, which I'll explain later.

Syntax:





Syntax Explanation:

  • Simple explanation: aliasname contains command1 + command2. Pressing the bound key will execute these.

  • Detailed explanation: the command alias is assigning a name (aliasname) to a group (" ") of two commands: command1 followed (;) by command2.

Example:

alias bye "snapshot;disconnect"

bind b bye

Result:

Pressing "b" executes the alias "bye", which consists of two commands, the first one takes a snapshot and the second one disconnects us from the server.

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 booleans (1/0 commands, where 1 means "true" and 0 means "false"). Pressing the bound key once will enable something, pressing it again would disable it or vice versa.

Syntax:








Syntax Explanation:

  • Simple explanation: aliasname = alias1 which contains boolean 1. After pressing the bound key, boolean 1 will be executed and now aliasname = alias2 which contains boolean 0, after pressing the bound key, boolean 0 will be executed and now aliasname = alias1 again.

  • Detailed explanation:
    Line 1: the command alias is assigning a name (aliasname) to an alias (alias1).
    Line 2: the command alias is assigning alias1 a boolean (boolean 1), then (;) the command alias reassigns the same name (aliasname) to a different alias (alias2).
    Line 3: the command alias is assigning alias2 the opposite boolean (boolean 0), 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 instead of booleans we're gonna use a variable (commands which aren't limited to 1 and 0 values) with 3 or more different values. By doing this we'll be able to rotate between these easily.

Syntax:









Syntax Explanation:

  • Simple explanation: aliasname = alias1 which contains variable 1. After pressing the bound key, variable 1 will be executed and now aliasname = alias2 which contains variable 2, after pressing the bound key, variable 2 will be executed and now aliasname = alias3. After pressing the bound key, variable 3 will be executed and now aliasname = alias1 again.

  • Detailed 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 and a value (variable 1), then (;) the command alias reassigns the same name (aliasname) to a second alias (alias2).
    Line 3: the command alias is assigning alias2 the same variable and a second value (variable 2), then (;) the command alias reassigns the same name (aliasname) to a third alias (alias3).
    Line 4: the command alias is assigning alias3 the same variable and a third value (variable 3), then (;) the command alias reassigns the same name (aliasname) to its original alias (alias1).

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 values 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 boolean while the bound key is being pressed. Once you release the key it executes the opposite boolean to cancel the first one. [*1]
  • Execute a command while the bound key is being pressed. Once you release the key it executes another command or the same one once again to cancel the first one. [*2]
  • Execute a non-stop command while the bound key is being pressed. Once you release the key it executes a stop command to cancel the first one. [*3]




Syntax 1:






Syntax Explanation:
  • Simple explanation: +aliasname contains boolean 1. While pressing the key, boolean 1 is executed. -aliasname contains boolean 0. Releasing the key will execute boolean 0.

  • Detailed explanation:
    Line 1: the command alias is assigning a name (aliasname) to a boolean and a value (boolean 1) which will be executed while the bound key is pressed (+).
    Line 2: the command alias is assigning the same name (aliasname) to the same boolean with its opposite value (boolean 0) which will be executed once the bound key is released (-).

Example:

alias +fps "cl_showfps 1"
alias -fps "cl_showfps 0"

bind z +fps

Note that when binding this kind of aliases we also include the + in our bind.

Result:

Holding "z" will show our FPS, releasing it will hide them again.



Syntax 2:






Syntax Explanation:
  • Simple explanation: +aliasname contains command1. While pressing the key, command1 is executed. -aliasname contains command2. Releasing the key will execute command2.

  • Detailed 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 unloadauthid

bind 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:

  • Simple explanation: +aliasname contains +command. While pressing the key, +command is executed. -aliasname contains -command. Releasing the key will execute -command.

  • Detailed explanation:
    Line 1: the command alias is assigning a name (aliasname) to a non-stop command (+command) which will be executed when the bound key is pressed (+).
    Line 2: the command alias is assigning the same name (aliasname) to a stop command (-command) which will be executed when the bound key is released (-).

Example:

alias +run +forward
alias -run -forward

bind j +run

Note that when binding this kind of aliases we also include the + in our bind.

Result:

Holding "j" will make the player move forward, releasing it will make the player stop moving, actually this is the default behaviour when pressing "W" but it was used just as an example.

Notes:

You can add more +commands to these kind of aliases, just make sure you also add its -command as well.

Example:
alias +runandshoot "+forward;+attack"
alias -runandshoot "-forward;-attack"

bind j +runandshoot
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 since the execution is too fast.
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 to avoid the repetition of 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 your .cfg file, since most aliases that you can find on internet require them.
Useful Aliases
After adding these aliases to userconfig.cfg make sure you select a key for them. Just replace the "key" part with any key you want.

Bunny Hop: allows you to move faster by performing multiple jumps. Keep pressed the key you selected while pressing A (moving your mouse to the left) or D (moving your mouse to the right) to increase your speed while jumping. W is only pressed during the first jump. NOTE: it doesn't work anymore on Half-Life after the 2013 update, but it can be helpful to understand its mechanism.

//Bunny Hop
alias bh1 "+jump;alias bh@ bh2;special"
alias bh2 "wait;alias bh@ bh3;special"
alias bh3 "-jump;alias bh@ bh4;special"
alias bh4 "wait;alias bh@ bh1;special"
alias +bhop "alias _special bh@;bh1"
alias -bhop "alias _special;-jump"

bind key +bhop

Climb: allows you to climb through boxes quickly. NOTE: it doesn't work anymore on Half-Life after the 2013 update, but it can be helpful to understand its mechanism.

//Climb
alias +bhdk "alias _special @bhdk;@bhdk"
alias -bhdk "alias _special"
alias @bhdk "special;wait;+duck;wait;-duck"
alias +s_climb "+jump;wait;wait;wait;wait;wait;wait;+bhdk"
alias -s_climb "-jump;-bhdk"

bind key +s_climb

Gauss Boost: once you fully charged the Gauss, press the bound key while holding +jump to impulse yourself towards the place you're aiming at. NOTE: it requires bunny hop on your game.

//Gauss Boost
alias "gauss" "cl_pitchup 180;cl_pitchdown -180;-attack2;wait;cl_pitchup -12;cl_pitchdown 12;wait;cl_pitchup 89.999;cl_pitchdown 89.999"

bind key gauss

Quick Xbow: using this one with the Crossbow makes you zoom-in, shoot and zoom-out quickly.

//Quick Xbow
alias "cross" "wait;+attack2; +attack; wait; +reload; wait; wait; -reload; -attack; -attack2; lastinv; lastinv;wait"

bind key cross

Long Jump: performs a long jump just like when you press crouch+jump having the Long Jump Module. Requires LJ.

//Long Jump
alias +lj "+forward;+duck;+forward;wait;wait;wait;wait;wait;wait;wait;wait;wait;wait;wait;wait;+jump"
alias -lj "-forward;-duck;-jump"

bind key +lj

Long Jump Backwards: same as the previous one but backwards. Requires LJ.

//Long Jump Backwards
alias "+ljback" "+back;wait;wait;wait;wait;+duck;wait;wait;wait;wait;wait;wait;+jump"
alias "-ljback" "-jump;-duck;-back"
alias "+ljback2" "cl_pitchup 180;cl_pitchdown -180;+ljback;wait;cl_pitchup -12;cl_pitchdown 12;wait;cl_pitchup 89.999;cl_pitchdown 89.999;wait;-duck"
alias "-ljback2" "-ljback"

bind key +ljback2

FPS Toggle: rotates between 4 different FPS values (60, 125, 250 and 500) and their respective correct cl_cmdrate values (65, 130, 255 and 505).

//FPS Toggle
alias fps fps1
alias fps1 "fps_max 60;cl_cmdrate 65; alias fps fps2"
alias fps2 "fps_max 120;cl_cmdrate 125; alias fps fps3"
alias fps3 "fps_max 240;cl_cmdrate 245; alias fps fps4"
alias fps4 "fps_max 480;cl_cmdrate 485; alias fps fps1"

bind key fps

Use Spam: spams +use multiple times, useful for speedrunning or bunny hopping maps.

//Use Spam
alias +usespam "alias _special usespam;usespam"
alias -usespam "alias _special"
alias usespam "+use;wait;-use;wait;special"

bind key +usespam

Quick Use: executes an one frame +use that doesn't slow down your speed, perfect to press buttons as you bunnyhop beside them.

//Quick Use
alias quickuse "-use;wait;+use;wait;-use"

bind key quickuse




The following aliases require server-side support to show colors, locations and player info.


Drop Team: drops a weapon to your team mates, it also sends a team message saying which weapon has been dropped and where. It also makes a sound so that teammates pay attention to it.

//Drop Team
alias "dropteam" "say_team ^2Dropped ^4[^2%W^4] ^9@ %L;play_team fvox/beep.wav;drop"

bind key dropteam

Postion: sends a team message saying where you are at and your current HP, armor and weapon. It also makes a sound.

//Position
alias "position" "say_team ^4[^8%H ^4- ^8%A^4] [^8%W^4] ^8%P ^9@ %L;play_team fvox/position.wav"

bind key position


4 Comments
DudeMcCool69 Jan 15 @ 1:13am 
thanks i used this to make a "zoom/ads" with this forum. I used the default_fov command to do this basically just make a cfg file (i like to just for custom binds but you don't have to) then type:

alias +ads "default_fov 65"
alias -ads "default_fov 115"

This is the settings i prefer then in config.cfg i go to "MOUSE2" bind and put "+ads"
and it worked.

~ Also make sure to put an "exec" command to your cfg file at the top after unbindall ~
Luchotaa Feb 23, 2024 @ 9:22pm 
Buenar2
Leito Jun 12, 2021 @ 3:33pm 
buena guia bro
🎮Nλmeless ⁧⁧🎮Bλttle Jun 12, 2021 @ 9:26am 
Buena guía y muy útil!