Half-Life Console Help


Making Aliases and Scripts
An alias is a special kind of variable that you can create with the alias command to make your own commands. Once you make an alias, you can execute it just like any other command by just typing its name into the console or a script file. Aliasing, in this sense, is a kind of console shorthand that lets you execute several commands (or other aliases) and/or set variables with one short command. The general format for the alias command is:

alias new_command_name cmd1 ; cmd2 ; . . . ; cmdN ; var1 value1 ; ... ; varN valueN 
You may specify only one alias name (new_command_name), and you must specify at least one command OR variable and value. In general you can specify as many commands and variables as you like, but there is a limit to the line length in script files (which is where you'd want to save a really long alias , so keep the total line length under 255 characters or use the workaround, see Debugging Scripts).

Why Use Aliases and Scripts?
Why would you want to make aliases? The best way to see what you can do with aliases and scripts is to take a look at some useful aliases and scripts that others have made. Try them out to see what they do, and then try changing them a bit to suit your own preferences, or use them as basic templates for writing your own.

If these aliases and scripts still seem a little too complicated, try reading the following explanations of several basic examples.

Avoiding Alias Loops
Make sure you don't accidentally make an alias that executes itself or you'll end up with an infinite loop that may crash the game. For example, never do this:

alias bad_alias "any_commands ; any_variable_settings ; bad_alias" 
Alias loops will cause problems even if they are not direct like the above example, so be careful to avoid even indirect self-references like this:
alias alias1 "any_commands ; any_variable_settings ; alias2"
alias alias2 "any_commands ; any_variable_settings ; alias1" 
Avoiding Stuck-On +Commands
Make sure you don't accidentally make an alias that turns on a +command (for example: +sttack) unless it (or another alias) turns it back off with the -command version (-attack in the example above). For example, never do this:
alias bad_alias "+forward; +jump; wait; -jump" 
This alias, besides being useless (if you need an alias to walk forward and jump, you need to check your keyboard and/or controller configuration :) will cause your player to move forward forever! To stop moving forward (after executing this alias), you'd have to open the console and type -forward or execute another alias that happens to include the -forward command. In the heat of battle, this can be pretty annoying.

Worse yet, another symptom of stuck-on command syndrome is that you can't respawn after you die!. In fact, you may not be able to do much of anything except restart the game. Of course, the game will then work fine again, unless you execute the alias again. Let's re-write the alias to be safer (but still useless, really): 

alias bad_alias "+forward; +jump; wait; -jump; -forward" 
Now the -forward command at the end will make sure you don't keep moving forward forever, but only if the alias gets that far! True, aliases normally execute ALL of the commands they are set to, but this is not true if you happen to be killed while your alias is executing!. If you die while the "wait" part of the script above is executed (the commmands in quotes are executed one at a time, in the order listed) then you'll be jumping and moving forward forever (or until the -forward and -jump commands are executed). 

So how can you avoid this hassle? Easy, make a separate config file, say "reset.cfg" and put it in the directory with your other configs (Half-Life/valve or Half-Life/tfc). For every +command you use anywhere in your scripts, put the corresponding -command in this file (except -mlook, -klook, and -jlook), one per line, like this (I've listed them all here, but you probably won't need them all):

-attack 
-attack2 
-back
-camdistance
-camin
-cammousemove
-camout
-campitchdown
-campitchup
-camyawleft
-camyawright
-det20
-det5
-det50
-duck
-forward 
-gren1
-gren2
-jump
-left 
-lookdown
-lookup
-movedown
-moveleft 
-moveright 
-moveup
-reload 
-right
-showscores
-speed 
-strafe
-use 
Then bind a key in your autoexec.cfg to execute this new config file, such as: bind x "exec reset.cfg". Whenever you die in the middle of a script and you can't respawn, just hit X and then respawn (fire). You may also want to put other default settings into your reset.cfg file, especially if you make aliases that change variables from your normal settings like zoom level (fov), mouse sensitivity (sensitivity), or other settings you would only want your aliases to change temporarily. 
 
[Previous Page] [Back to Console Index] [Next Page]