Difference between revisions of "Scripting"

From Team Fortress Wiki
Jump to: navigation, search
m (External Links)
(Undo edit by Dogman15 (Talk) (3850657) As mentioned, only taunts in the player's loadout)
(Tag: Undo)
 
(330 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
'''Scripting''' is the use of configuration files to create new keybinds and aliases automating complex behaviors and [[console]] command sequences.
+
{{Quotation|'''The Engineer''' after using his [[sentry jump]] script|This thing ain't on auto-pilot, son!|sound=Engineer wranglekills01.wav}}
 +
'''Scripting''' is the use of configuration files ({{code|.cfg}}) typically used to create new keybinds and aliases, change advanced graphical settings, automating complex behaviors, and creating sequences of [[console]] commands. Unlike [[hacking]], scripting is an intentional feature natively built into ''Team Fortress 2'', and will not trigger a VAC ([[Valve Anti-Cheat]]) ban. The complexity of scripting varies from simply binding an input key to output a command, to self-referential loops and nested aliases that redefine one another. There are many graphical settings that can only be changed through the use of console commands, or scripts that automate the input of said console commands. Outside of specific graphical settings, most other functions that can be performed via scripting may also be achieved without it, but scripting grants the advantage of allowing these functionalities to be instantly executed within the heat of battle.  
  
* Keybinds connect a key to a console command, such as choosing a [[weapon]] slot or saying prewritten text in chat.
+
== Scripting Commands ==
 +
The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly.
  
* Aliases build new commands by executing a series of console commands whenever they are used.  An alias might define jumping and crouching as a single jump-crouch command, which can then be bound to a key.
+
=== bind ===
 +
{{Main|vdc:bind|l1=bind}}
 +
The simplest command is the bind command. It will cause a certain key to execute a certain action, whether that action is a setting, a command, or a script.
  
These scripts range in complexity from simple lists of commands to self-referential loops and nested aliases that redefine one another. With enough time and effort, you can use the tools to create almost any behavior available to the client at the press of a single key.
+
<pre>bind [KEY] [COMMAND]</pre>
 +
Quotes can be optionally placed around the key and/or the command. However, the commands will need to have quotes when it has spaces in between the values and the command, so that the console can interpret it as one command. An example would be bind mouse1 "say texthere", where quotes are needed around "say texthere" because of the space between the two phrases.
  
==Basic Scripting Files==
+
<pre>bind [KEY] "[COMMAND 1];[COMMAND 2];[COMMAND 3]"</pre>
 +
Quotes can be optionally placed around the key, but must be present around the commands, as the console will not interpret consecutive commands if quotes are not present.
  
Team Fortress 2 automatically reads several game files and executes any keybinds and aliases inside. Here is the list of those files:
+
''Note:'' The command <code>say "Example Text"</code> is correct, but <code>bind <KEY> "say "Example Text""</code> is not. This is because the quotes are misinterpreted, and quotes inside of quotes are unnecessary due to commands automatically stopping at every semicolon.
  
* config.cfg - This is the default config file, which the game edits whenever you use the in-game menus to bind keys or change video settings. While editing the file is safe, it's simpler to leave it alone.
+
When a key is bound to a string starting with a plus, the same command(s) will be executed when the key is released, except the first plus will be replaced with a minus. For example, <code>bind w +forward</code> will make pressing {{key|W}} execute <code>+forward</code> and releasing {{key|W}} execute <code>-forward</code>. Note that this only effects the first command, and other commands will not be negated. See [[#alias|alias]] for more information.
 +
This bind will make the player move forward while they have {{key|W}} held down.
  
* autoexec.cfg - This is the default config file for executing custom keybinds and aliases. You may put your keybinds directly into this file, but it is often easier to create separate .cfg files for different scripts, which you then execute inside this file.
+
=== toggle ===
 +
This command allows a cvar to be toggled between two or more values. If no values are specified, defaults to toggling between 0 and 1.
  
* <class>.cfg - Each class has a config file which automatically runs whenever you switch to that class.  You may put your keybinds directly into this file, but it is often easier to create separate .cfg files for different scripts, which you then execute inside these files.
+
<pre>toggle tf_bot_quota normal fill match</pre>
  
==Syntax==
+
==== bindToggle ====
 +
BindToggle may be used to bind a key to toggle a cvar between 0 and 1. It cannot be used for values besides 0 and 1.
  
Here is a list of syntactic rules:
+
<pre>bindToggle o sv_cheats</pre>
  
* For any keybind or alias to work, you need to follow this format:
+
=== incrementvar ===
 +
This allows for variables to be increased or decreased repeatedly by a set amount.
  
:'''command <argument1> <argument2>'''
+
<pre>bind MWHEELUP "incrementvar fov_desired 75 90 1"
 +
bind MWHEELDOWN "incrementvar fov_desired 75 90 -1"</pre>
 +
This will cause the [[field of view]] to increase when scrolling up, and to decrease when scrolling down
 +
:''Note:'' Incrementvar will cause the value to wrap around if it gets too large or too small. In this example, once the field of view hits 90, it will drop down to 75, and vice-versa.
  
:* command is the kind of scripting you wantYou have three choices:
+
=== alias ===
 +
{{Main|vdc:alias|l1=alias}}
 +
An alias allows multiple commands to be referenced by a single command. This is effectively shorthand, and it is most useful when a series of commands need to be called multiple times. Alias names cannot contain spaces. They may contain underscores, numbers, symbols, and are not case-sensitive (only when being created, when removing an alias it is case-sensitive). Aliases may not overwrite existing commands or variables except those that start with a plus or minus (for example, <code>alias help</code> is disallowed, but <code>alias +forward</code> is allowed).
  
::* bind - Used to bind commands to a particular key.
+
After running the command <code>alias foo "echo bar"</code>, typing <code>foo</code> in the console will execute <code>echo bar</code>.
::* alias - Used to execute commands when the alias is executed.
+
After running the command <code>alias foo</code>, typing <code>foo</code> in the console will no longer do anything. If the alias was created with uppercase letters (such as <code>alias fOO "echo bar"</code>), typing <code>alias foo</code> will not remove the alias, but <code>alias fOO</code> will.
::* exec - Used to execute commands automatically when a configuration file is loaded.
 
  
:* <argument1> is either the key being bound or the name of the alias being created.
+
Aliases may begin with a plus or minus character. This allows them to be used in conjunction with <code>bind</code> to negate several commands when a key is released. For example, this script allows a player to move diagonally with a single key:
  
:* <argument2> is either the command being bound or the commands executed by the alias.
+
<pre>alias +diagonal "+moveleft; +back"
 +
alias -diagonal "-moveleft; -back"
 +
bind z "+diagonal"</pre>
  
*To run multiple commands, you must put the entire argument in quotation marks and separate the commands with semicolons, like so:
+
Releasing Z will execute <code>-diagonal</code> in this script, whereas simply typing <code>bind "z" "+moveleft; +back"</code> would result in the game never running <code>-back</code> when the player releases the key. This results in the player moving backwards continuously.
  
:'''alias "spraynpray" "+attack; wait 500; -attack"'''
+
=== exec ===
:'''bind "mouse3" "spraynpray"
+
This command will execute another file. This means that complex scripts can be stored in other files, so as not to clutter up more general files.
  
:*When executed, the alias starts firing the player's weapon, continues for 500 physics frames (that is roughly five seconds if you are on a server that runs at a 100 frames per second) and then stops firing.  The alias is keybound to execute when you press the middle mouse button.
+
<code>exec highquality</code>
*To enclose something in quotes that already has quotes in it, you have to ''escape'' the internal quotes by using two consecutive quotes ("") in place of each one.
+
This script will execute the config named {{code|highquality.cfg}} script within the {{code|tf/cfg}} folder.
:'''alias "saysomestuff" "say ""Some Stuff..."""'''
 
:*When you type '''saysomestuff''' in the console, you will speak "Some Stuff..." in the chat. Without the internal quotes, the chat window will only show "Some".
 
  
==Keybinds==
+
=== echo ===
 +
This command will cause text to be printed to the console. This is very useful for debugging.
  
Team Fortress 2 allows scripts and aliases to be bound to any key on the keyboard. The key you wish to bind a command to is placed after your bind command and before the action you want the key to execute, as in the section above.  Most keys are self-explanatory, as all alphanumerics (a-z, 0-9) and function keys are simply listed by typing that key ("bind a" binds a key to "a", "bind 5" binds to "5" and "bind f7" binds to "f7").  Other keys require you type specific names into your .cfg file in order to access them, and these names are not all obvious.  A list of these keys is provided below:
+
<pre>echo Scripting is; echo very useful</pre>
 +
This will print out <code>Scripting is</code> and <code>very useful</code> on ''two separate lines''. This is because a newline is added to the end of any text passed to <code>echo</code>. Spaces are only parsed if they are between words, or if the echoed text is between quotes, as in the next example:
  
====List of Key Names====
+
<pre>echo " Scripting is very useful.  "</pre>
* Keyboard Keys: Names of Keybinds
+
The extra spaces will be printed out, since the string is delimited by quotation marks.
* Left Shift: SHIFT
+
:''Note:'' It is not possible to print out the " character, as its meaning will be misinterpreted. However, you can print single quotes: that is, the ' character.
* Left Ctrl: CTRL
+
:''Note:'' Echo occasionally will misprint strings that are not delimited by quotation marks. As a general rule of thumb, it is better to enclose what you wish to print within quotation marks. It also makes it easier to read for humans.
* Left Alt: ALT
 
* Right Shift: RSHIFT
 
* Right Control: RCTRL
 
* Right Alt: RALT
 
* Tab: TAB
 
* Backspace: BACKSPACE
 
* ---
 
* Insert: INS
 
* Scroll Lock: SCROLLLOCK
 
* Pause/Break: NUMLOCK
 
* ---
 
* Home: HOME
 
* End: END
 
* Delete: DEL
 
* Page Up: PGUP
 
* Page Down: PGDN
 
* ---
 
* Up Arrow: UPARROW
 
* Down Arrow: DOWNARROW
 
* Left Arrow: LEFTARROW
 
* Right Arrow: RIGHTARROW
 
* Numpad Keys: Names of Keybinds
 
* 0: KP_INS
 
* 1: KP_END
 
* 2: KP_DOWNARROW
 
* 3: KP_PGDN
 
* 4: KP_LEFTARROW
 
* 5: KP_5
 
* 6: KP_RIGHTARROW
 
* 7: KP_HOME
 
* 8: KP_UPARROW
 
* 9: KP_PGUP
 
* Enter: KP_ENTER
 
* ".": KP_DEL 
 
* "+": KP_PLUS
 
* "-": KP_MINUS
 
* "*": KP_MULTIPLY
 
* "/":KP_SLASH
 
* Mouse Wheel Direction: Names of Keybinds
 
* Mouse Wheel Up: MWHEELUP
 
* Mouse Wheel Down: MWHEELDOWN
 
  
Using the above keynames you can place the following example command into one of your config files: <bind KP_ENTER "voicemenu 0 1">. When you hit Enter on your Numpad in-game you will trigger the "Thanks" voice command.
+
=== wait ===
 +
This command will make the game wait a given number of frames before executing the next command.
 +
:'''Warning: Wait commands are disabled on certain servers. This will cause certain scripts to fail, and may (in semi-rare cases) cause the game to crash. See [[#Wait-testing|Wait Testing]] for help to protect against this.'''
  
==Basic Commands==
+
<pre>echo Why did the chicken cross the road?;wait 300;echo To get to the other side!</pre>
 +
This script will wait 300 frames (1 second at the default max FPS) before printing the punchline.
  
Most commands accept a single argument, which is whatever value you want to execute.
+
== Class-specific CFG Files ==
 +
When switching to a certain class, the game executes the corresponding CFG file (if it exists), named after the given class.
 +
<pre>
 +
scout.cfg
 +
soldier.cfg
 +
pyro.cfg
 +
demoman.cfg
 +
heavyweapons.cfg
 +
engineer.cfg
 +
medic.cfg
 +
sniper.cfg
 +
spy.cfg
 +
</pre>
  
'''bind "q" "sv_alltalk 1"'''
+
This automation lets the player have different keybinds and game settings for each class.
  
A handful of important commands accept multiple arguments. Here are some examples:
+
=== VPK files and config files ===
 +
[[vdc:VPK|.vpk]] files take priority over config files located within the {{code|cfg}} folder. Mods using {{code|.vpk}} files may run the risk of negatively interfering with any custom configuration changes, however, some mods provide methods to override the configs from within the .vpk files natively.
  
* disguise X Y - This [[disguise]]s the [[Spy]]. X is the class numbered 1 through 9 and Y is the team numbered 1 or 2.
+
== Launch Options ==
 +
Launch options can be used to change how TF2 runs, both in terms of performance and functionality. Please see {{vdc|Command Line Options|Command Line Options}} for a comprehensive list of launch options.
  
* voicemenu X Y - This executes a voice command. X is the number of the primary menu. Y is the command position in that menu.
+
=== Set Launch Options ===
 +
[[File:Setting Launch Options.png|thumb|none|A visual guide on how to set launch options (indicated by the pink circles).]]
 +
# Right-click on the game title under the '''Library''' in Steam and select '''Properties'''.
 +
# Under the '''General''' tab click the '''Set launch options...''' button.
 +
# Enter the launch options you wish to apply (be sure to separate each code with a space) and click '''OK'''.
 +
# Close the game's '''Properties''' window and launch the game.
  
Example: "voicemenu 1 1" is the command for Spy, so:
+
=== Window Options===
 +
Note that these may incorrectly setup an improper video mode not preferred by the material system, reducing performance. Where possible, you should use the in-game settings instead.
 +
====Resolution====
 +
Launch Option: '''-w # -h #'''
 +
:''Description:'' Forces the game resolution width and height in pixels.
 +
====Refresh Rate====
 +
Launch Option: '''-freq #'''
 +
:''Description:'' Forces the game refresh rate in Hz.
 +
====Windowed Mode====
 +
Launch Option: '''-windowed'''
 +
:''Description:'' Launches the game in windowed mode.
 +
====Borderless Windowed Mode====
 +
Launch Option: '''-noborder'''
 +
:''Description:'' When in windowed mode, remove the window border to allow for borderless fullscreen mode, as opposed to exclusive fullscreen mode.
 +
====Fullscreen Mode====
 +
Launch Option: '''-fullscreen'''
 +
:''Description:'' Forces the game resolution width and height in pixels.
  
'''bind "t" "voicemenu 1 1"'''
+
===Peripheral Support===
 +
====Disable Joystick Support====
 +
Launch Option: '''-nojoy'''
 +
:''Description:'' Prevents the joystick system from loading, improving start-up time and memory usage. Don't use this if you intend to use a joystick with the game.
 +
====Disable Steam Controller Support====
 +
Launch Option: '''-nosteamcontroller'''
 +
:''Description:'' Prevents the Steam controller system from loading, improving start-up time and memory usage. Don't use this if you intend to use a Steam controller with the game.
  
This command will make your character yell Spy whenever you hit the key.
+
===Software Support===
 +
====Disable SourceTV====
 +
Launch Option: '''-nohltv'''
 +
:''Description:'' Disables [[SourceTV]] support, improving memory usage. Don't use this if you host SourceTV on your client.
  
==Incrementvar==
+
===Engine Options===
 +
===Disable Intro Video===
 +
Launch Option: '''-novid'''
 +
:''Description:'' Removes the Valve intro video shown when the game is started, improving loading times.
  
This command cycles through a range of specified values whenever it executes and applies those values to another command. This has the form of:
+
====Change Beam Particle Limit====
 +
Launch Option: '''-particles #'''
 +
:''Description:'' Limits the number of beam particles. Set # to '1' to (a limit of 512) to improve memory usage.
  
:'''command "<argument1>" "incrementvar <argument2> X Y Z"'''
+
====Precache Font Rendering====
 +
Launch Option: '''-precachefontchars'''
 +
:''Description:'' Precaches font rendering for common characters, improving rendering time.
  
:*X and Y represent the range of values you want to execute with <argument2>.
+
====Disable Texture Streaming====
:*Z is the size of the step you want to make while you cycle through the range.
+
Launch Option: '''-no_texture_stream'''
 +
:''Description:'' Disables using lower quality textures whilst higher quality versions load, instead favoring to always instantly load the higher quality versions. Disabling texture streaming results in a performance boost on systems running GPUs with low VRAM (video memory).
  
If you wanted a value range of 1 through 10 and you wanted to increment your value by 2 each time the command was executed, you'd make X Y Z into 1 10 2. Then each time it executes, <argument2> will execute with an incrementing value of 2, 4, 6, 8, 10, 2, 4, 6, 8, 10... and so forth.
+
===DirectX Version (Windows exclusive)===
 +
Launch Option: '''-dxlevel #'''
 +
:''Description:'' Sets the DirectX Version used by the game; accepts many values ranging from 80 to 100. The manual setting of DirectX levels is experimental and is typically altered to support older hardware.
 +
::'-dxlevel 100' uses DirectX 9. Hardware is automatically detected to determine the system's graphical capabilities.
 +
::'-dxlevel 81' is the most stable version of DirectX for GPUs released prior to 2004. DirectX 8 has a reduced feature set such as a lack of [[War Paint]]s and transparency on models (such as the [[Voodoo-Cursed Soul]]s). Values below 81 will cause even more graphical issues. This should be avoided unless necessary for compatibility reasons.  
 +
:Note: After launching the game with the -dxlevel command once, the game should then be closed, and then the launch option removed entirely before launching the game again.
  
Here is a real example of incrementvar in action:
+
===Vulkan (Windows exclusive)===
 +
Launch Option: '''-vulkan'''
 +
:''Description:'' Enables [[w:Vulkan|Vulkan]] rather than DirectX. Vulkan is enabled by default on Linux systems.
  
:'''bind "n" "incrementvar net_graphpos 1 3 1"'''
+
===Execute Other Scripts on Startup===
 +
Launch Option: '''+exec script.cfg'''
 +
:''Description:'' Executes the specified script when the game launches.
 +
{{Note|Note: A config named {{code|autoexec.cfg}} is automatically executed on startup.}}
  
This binds the key "n" to cycle to the next position in the 3 available net_graph positions.
+
== List of key names ==
 +
Hover over a key to see its scripting name. Names are not case-sensitive.
 +
{|
 +
! width="45%" <!-- Main Keyboard -->|
 +
! width="03%" <!-- Spacing      -->|
 +
! width="25%" <!-- Special Keys  -->|
 +
! width="01%" <!-- Spacing      -->|
 +
! width="25%" <!-- Keypad 1      -->|
 +
! width="05%" <!-- Keypad 2      -->|
 +
|-
 +
|
 +
{{tooltip|{{key|ESC}}|ESCAPE}}
 +
{{tooltip|{{key|F1}}|F1}}
 +
{{tooltip|{{key|F2}}|F2}}
 +
{{tooltip|{{key|F3}}|F3}}
 +
{{tooltip|{{key|F4}}|F4}}
 +
{{tooltip|{{key|F5}}|F5}}
 +
{{tooltip|{{key|F6}}|F6}}
 +
{{tooltip|{{key|F7}}|F7}}
 +
{{tooltip|{{key|F8}}|F8}}
 +
{{tooltip|{{key|F9}}|F9}}
 +
{{tooltip|{{key|F10}}|F10}}
 +
{{tooltip|{{key|F11}}|F11}}
 +
{{tooltip|{{key|F12}}|F12}}
  
==The + and - commands==
+
{{tooltip|{{key|` &nbsp;}}|`}}
 +
{{tooltip|{{key|1}}|1}}
 +
{{tooltip|{{key|2}}|2}}
 +
{{tooltip|{{key|3}}|3}}
 +
{{tooltip|{{key|4}}|4}}
 +
{{tooltip|{{key|5}}|5}}
 +
{{tooltip|{{key|6}}|6}}
 +
{{tooltip|{{key|7}}|7}}
 +
{{tooltip|{{key|8}}|8}}
 +
{{tooltip|{{key|9}}|9}}
 +
{{tooltip|{{key|0}}|0}}
 +
{{tooltip|{{key|-}}|-}}
 +
{{tooltip|{{key|{{=}}}}|{{=}}}}
 +
{{tooltip|{{key|← Backspace}}|BACKSPACE}}
  
These commands have two states.  While the bound key is pressed, the +command executes and continues to execute.  When the key is released, the -command executes and continues to execute.
+
{{tooltip|{{key|TAB}}|TAB}}
 +
{{tooltip|{{key|Q}}|Q}}
 +
{{tooltip|{{key|W}}|W}}
 +
{{tooltip|{{key|E}}|E}}
 +
{{tooltip|{{key|R}}|R}}
 +
{{tooltip|{{key|T}}|T}}
 +
{{tooltip|{{key|Y}}|Y}}
 +
{{tooltip|{{key|U}}|U}}
 +
{{tooltip|{{key|I}}|I}}
 +
{{tooltip|{{key|O}}|O}}
 +
{{tooltip|{{key|P}}|P}}
 +
{{tooltip|{{key|[}}|[}}
 +
{{tooltip|{{key|]}}|]}}
 +
{{tooltip|{{key|\ &nbsp; &nbsp; &nbsp;}}|\}}
  
Example:
+
{{tooltip|{{key|⇪ Caps}}|CAPSLOCK}}
:'''bind "c" "+duck"
+
{{tooltip|{{key|A}}|A}}
 +
{{tooltip|{{key|S}}|S}}
 +
{{tooltip|{{key|D}}|D}}
 +
{{tooltip|{{key|F}}|F}}
 +
{{tooltip|{{key|G}}|G}}
 +
{{tooltip|{{key|H}}|H}}
 +
{{tooltip|{{key|J}}|J}}
 +
{{tooltip|{{key|K}}|K}}
 +
{{tooltip|{{key|L}}|L}}
 +
{{tooltip|{{key|;}}|SEMICOLON}}
 +
{{tooltip|{{key|' &nbsp;}}|'}}
 +
{{tooltip|{{key|Enter ↵}}|ENTER}}
  
This +command is bound to "c" so whenever the key is pressed, the player ducks. Whenever the key is released, +duck is swapped to -duck and the player stops ducking.
+
{{tooltip|{{key|Shift &nbsp; &nbsp;}}|SHIFT}}
 +
{{tooltip|{{key|Z}}|Z}}
 +
{{tooltip|{{key|X}}|X}}
 +
{{tooltip|{{key|C}}|C}}
 +
{{tooltip|{{key|V}}|V}}
 +
{{tooltip|{{key|B}}|B}}
 +
{{tooltip|{{key|N}}|N}}
 +
{{tooltip|{{key|M}}|M}}
 +
{{tooltip|{{key|, &nbsp;}}|,}}
 +
{{tooltip|{{key|. &nbsp;}}|.}}
 +
{{tooltip|{{key|/ &nbsp;}}|/}}
 +
{{tooltip|{{key|Shift &nbsp; &nbsp; &nbsp; &nbsp;}}|RSHIFT}}
  
In general, if a command or alias is bound to a key, a + tells the game to run the command as long as the key is held.  Similarly, if a command or alias is bound to a key, a - tells the game to run the command when the key is released.
+
{{tooltip|{{key|Ctrl &nbsp;}}|CTRL}}
 +
{{tooltip|{{key|⊞}}|LWIN}}
 +
{{tooltip|{{key|Alt}}|ALT}}
 +
{{tooltip|{{key|&nbsp; &nbsp; &nbsp; Spacebar &nbsp; &nbsp; &nbsp;}}|SPACE}}
 +
{{tooltip|{{key|⊞}}|RWIN}}
 +
{{tooltip|{{key|Alt}}|RALT}}
 +
{{tooltip|{{key|Menu}}|Cannot be bound}}
 +
{{tooltip|{{key|Ctrl &nbsp; &nbsp;}}|RCTRL}}
  
If an alias is defined with a + in front of it, the alias will be run whenever the key is pressed, as the key is pressed. The - command will then run as the key is released.
+
|<!-- Spacing -->
 +
|
 +
{{tooltip|{{key|PrtScn}}|Cannot be bound}}
 +
{{tooltip|{{key|ScrLk}}|SCROLLLOCK}}
 +
{{tooltip|{{key|Pause}}|PAUSE}}
  
==Wait Command==
+
{{tooltip|{{key|Insert &nbsp;}}|INS}}
 +
{{tooltip|{{key|Home}}|HOME}}
 +
{{tooltip|{{key|PgUp}}|PGUP}}
  
If you want the game to delay for a period of time during an alias, or if you want avoid client crashes caused by executing commands too quickly, use the '''wait''' command.
+
{{tooltip|{{key|Delete}}|DEL}}
 +
{{tooltip|{{key|&nbsp; End &nbsp;}}|END}}
 +
{{tooltip|{{key|PgDn}}|PGDN}}
  
Wait tells the game to delay the next command in the script by one physics frame, something like a full turn in the TF2 rules.  It accepts values such as "wait 50" which tells the game to wait fifty frames before the alias continues.  "wait 100" is roughly a second on a 100 FPS server.
 
  
Some servers disable the wait command.  While playing on them, wait commands will be ignored, making some scripts susceptible to crashes. A script containing an indeterminate loop spaced by wait commands will always immediately hang upon usage on such servers.
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{{tooltip|{{key|&uarr;}}|UPARROW}}
==Aliases==
 
  
An alias is like a variable that stores a series of commands which can be executed as a group.  A simple alias will take the form:
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{tooltip|{{key|&larr;}}|LEFTARROW}}
 +
{{tooltip|{{key|&darr;}}|DOWNARROW}}
 +
{{tooltip|{{key|&rarr;}}|RIGHTARROW}}
 +
|<!-- Spacing -->
 +
|
  
'''alias "aliasname" "command1; command2; command3"'''
+
{{Scripting Numpad}}
 +
|}
  
You can then execute the commands through a bound key:
+
{|
 +
! align="left"| Mouse Button
 +
! Name of Keybind
 +
|-
 +
| Scroll Up
 +
| MWHEELUP
 +
|-
 +
| Scroll Down
 +
| MWHEELDOWN
 +
|-
 +
| Left Click
 +
| MOUSE1
 +
|-
 +
| Right Click
 +
| MOUSE2
 +
|-
 +
| Wheel Click
 +
| MOUSE3
 +
|-
 +
| Left Button Click (forward)
 +
| MOUSE4
 +
|-
 +
| Right Button Click (back)
 +
| MOUSE5
 +
|}
  
'''bind "key" "aliasname"'''
+
== Useful commands ==
 +
{{Main|vdc:List of TF2 console commands and variables|l1=List of TF2 console commands and variables}}
  
Whenever the key is pressed, command1, command2, and command3 are executed in order.
+
===Disguising===
 +
The <code>disguise</code> command takes two arguments, the first being the class and the second being the team.
 +
:'''Class'''
 +
:1. Scout
 +
:2. Sniper
 +
:3. Soldier
 +
:4. Demoman
 +
:5. Medic
 +
:6. Heavy
 +
:7. Pyro
 +
:8. Spy
 +
:9. Engineer
  
===Complex Aliases===
+
:'''Team'''
 +
:1. BLU team
 +
:2. RED team
 +
:-1. Opposite team
 +
:-2. Same team
  
Aliases can execute any command including other aliases. Furthermore, an alias can execute an alias in order to redefine that alias's commands. This allows you to create cycling aliases. Here is a very simple example:
+
Thus, <code>disguise 5 1</code> would disguise as a BLU Medic and <code>disguise 7 -2</code> would disguise as a friendly Pyro.
 +
:''Note:'' <code>disguise 8 -2</code> (Friendly Spy) will cause the player to un-disguise.
 +
:''Note:'' Any collection of characters and/or numbers after the class number that are not 1, 2, -1, or -2 will default the disguise to RED team, regardless of the player's current team. For example, <code>disguise 1 3</code> will disguise the Spy as a RED Scout.
  
'''bind "key" namescroll'''<br>
+
=== Buildings ===
'''alias namescroll "firstname" '''<br>
+
The <code>build</code> and <code>destroy</code> commands each take two arguments, the first being the building and the second being the building type. The second argument is only required if it is not <code>0</code>, and is currently only used to differentiate between teleporter entrances and exits.
'''alias firstname "setinfo name "First_name"; alias namescroll secondname" '''<br>
 
'''alias secondname "setinfo name "Second_name"; alias namescroll thirdname"'''<br>
 
'''alias thirdname "setinfo name "Third-name"; alias namescroll firstname"'''<br>
 
  
This is difficult to read, so break it down.
+
The <code>build</code> command will pull up the blueprint to place a building, with an exception of the Sapper, which is wielded.
 +
:<code>build 0 0</code> will build a [[Dispenser]] <small>(Engineer only)</small>
 +
:<code>build 1 0</code> will build a [[teleporter entrance]] <small>(Engineer only)</small>
 +
:<code>build 1 1</code> will build a [[teleporter exit]] <small>(Engineer only)</small>
 +
:<code>build 2 0</code> will build a [[Sentry Gun]] <small>(Engineer only)</small>
 +
:<code>build 3 0</code> will build a [[Sapper]] <small>(Spy only)</small>
  
*The first line binds "key" to an alias "namescroll" which we have yet to define.
+
Similarly, the <code>destroy</code> command will destroy buildings.
*The second line creates the alias "namescroll" which executes the command "firstname"
+
:<code>destroy 0 0</code> will destroy a Dispenser <small>(Engineer only)</small>
*The third line defines the "firstname" alias as two commands:
+
:<code>destroy 1 0</code> will destroy a teleporter entrance <small>(Engineer only)</small>
:*The first command sets your in-game name to "First_name"
+
:<code>destroy 1 1</code> will destroy a teleporter exit <small>(Engineer only)</small>
:*The second command redefines the alias "namescroll" as an alias for executing the alias "secondname"
+
:<code>destroy 2 0</code> will destroy a Sentry Gun <small>(Engineer only)</small>
*The fourth line defines "secondname" in the same manner.  A different in-game name is set, and then "namescroll" is redefined to another alias "thirdname"
+
:''Note:'' Sappers cannot be destroyed.
*The fifth line defines "thirdname" just like the two before it, but with a twist.  It redefines the "namescroll" alias as executing the "firstname" alias.
 
  
This completes a loop.  Each press of the key executes a command and redefines the alias bound to the key, so that when it is next pressed it will execute a different command.  If there were no loop, then the alias "namescroll" wouldn't always have another alias to execute with each keypress.
+
It is possible to use the old <code>build</code> commands, which used only one argument.
 +
:<code>build 0</code> will build a Dispenser <small>(Engineer only)</small>
 +
:<code>build 1</code> will build a teleporter entrance <small>(Engineer only)</small>
 +
:<code>build 2</code> will build a Sentry Gun <small>(Engineer only)</small>
 +
:<code>build 3</code> will build a teleporter exit <small>(Engineer only)</small>
 +
:<code>build 3</code> will build a Sapper <small>(Spy only) [deprecated]</small>
  
===Alias Loops===
+
=== Voice Menu ===
Aliases can be used in conjunction with the Wait command to create looping aliases.<br>
+
The <code>voicemenu</code> command takes two arguments, the menu number and the command number.  
 +
*<code>voicemenu 0</code>
 +
*:0: {{botignore|MEDIC!}}
 +
*:1: Thanks!
 +
*:2: Go! Go! Go!
 +
*:3: Move Up!
 +
*:4: Go Left
 +
*:5: Go Right
 +
*:6: Yes
 +
*:7: No
 +
*:8: Pass To Me!
 +
*<code>voicemenu 1</code>
 +
*:0: Incoming
 +
*:1: Spy!
 +
*:2: Sentry Ahead!
 +
*:3: Teleporter Here
 +
*:4: Dispenser Here
 +
*:5: Sentry Here
 +
*:6: Activate Charge!
 +
*:7: {{botignore|MEDIC: ÜberCharge Ready}}
 +
*:8: Pass To Me!
 +
*<code>voicemenu 2</code>
 +
*:0: Help!
 +
*:1: Battle Cry
 +
*:2: Cheers
 +
*:3: Jeers
 +
*:4: Positive
 +
*:5: Negative
 +
*:6: Nice Shot
 +
*:7: Good Job
  
+
:''Note'': If you wish to display the voicemenu, rather than fire the <code>voicemenu <num> <num></code> message, the command is <code>voice_menu_<num></code>: where <num> is a number between 1 and 3, and takes no arguments. For instance, to display the first voicemenu, one would run the command <code>voice_menu_1</code>.
''Warning:Not having the wait in place, or being on a server with wait disabled will cause this example to crash TF2.''<br>
 
'''alias "Loop" "echo Looping every 150 ticks.;wait 150;Loop"'''<br>
 
'''Loop'''<br>
 
  
Lets break this down into components:<br>
+
=== Eureka Teleport ===
Line 1<br>
+
The <code>eureka_teleport</code> can teleport an Engineer holding the [[Eureka Effect]] to their spawn or teleporter exit.
The echo displays a message to the console, just so you know it works.<br>
+
*<code>eureka_teleport 0</code> will teleport the player to their spawn
The wait makes it wait 150 ticks between iterations<br>
+
*<code>eureka_teleport 1</code> will teleport the player to their [[teleporter exit]]
Loop calls the alias again, restarting at the echo.<br>
 
<br>
 
Line 2<br>
 
Loop starts the looping alias.<br>
 
  
You can also create loops of alias commands, like this example:<br>
+
The player will see "Unknown command" in their [[console]] even though the command works.
'''alias "Loop1" "echo Loop 1;wait 150;Loop2"'''<br>
 
'''alias "Loop2" "echo Loop 2;wait 150;Loop1"'''<br>
 
  
Loop1 calls Loop2 which in turn calls Loop1, etc...<br>
+
=== Assorted ===
This method can also be used for breaking a loop without clearing the loop alias:<br>
+
*<code>clear</code> will clear the console of any information.
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
+
*<code>alias</code> will list all currently defined aliases.
'''alias "Loop2" "Loop1"'''<br>
+
*<code>fov_desired (20-90)</code> will set the [[field of view]].
This would create a loop, then<br>
+
*<code>viewmodel_fov </code> will set the FOV for weapon models. It ranges by default from 54 to 70.
'''alias "Loop2"'''<br>
+
*<code>r_drawviewmodel (0/1)</code> will show (1) or hide (0) weapon models.
would break it, by clearing the Loop2 alias.<br>
+
*<code>lastdisguise</code> will cause the player to re-disguise as their last disguise. <small>(Spy only)</small>
 +
*<code>load_itempreset (0-3)</code> will load a particular loadout preset [A, B, C, D].
 +
*<code>say message</code> will send a message to [[Text chat|public chat]].
 +
*<code>say_team message</code> will send a message to team chat.
 +
*<code>say_party message</code> will send a message to party chat.
 +
*<code>+taunt</code> will open the player's taunt loadout.
 +
*<code>+use_action_slot_item</code> will cause the player to use their action slot item.
 +
*<code>volume (0-1)</code> will change the in-game volume.
 +
*<code>taunt_by_name (name)</code> will run a specified taunt, given the exact name of a taunt in the player's current taunt loadout, without opening the taunt menu.
 +
*<code>key_findbinding (string)</code> will list all keys bound to a string containing the given substring (case-sensitive).
 +
*<code>key_listboundkeys</code> will list all keys currently bound and their associated commands.
  
You can use these for button presses(Via the +/- prefixes covered earlier) like this:<br>
+
== Advanced Scripting Techniques ==
'''alias "Loop2" "Loop1"'''<br>
+
=== Toggles ===
'''alias "Loop1" "echo Loop1;wait 150;Loop2"'''<br>
+
It is possible to bind a key to toggle a command which would otherwise be a press and hold command.
'''alias "+Loop" "alias Loop2 Loop1;Loop2"'''<br>
 
'''alias "-Loop" "alias Loop2"'''<br>
 
'''bind "<Key>" "+Loop"'''<br>
 
In order of what it's doing:<br>
 
Make Loop2 point to Loop1<br>
 
Make Loop1 echo 'Loop1' to the console, wait 150, then call Loop2<br>
 
make +Loop point Loop2 to Loop1 and run Loop2<br>
 
make -Loop clear Loop2's link, breaking the loop<br>
 
  
== Useful Script Commands ==
+
<pre>bind w toggle_movement
There are literally hundreds of different arguments for your script that can make them do almost anything. Here's a list of a few of them.
+
alias toggle_movement enable_movement
 +
alias enable_movement "alias toggle_movement disable_movement;+forward"
 +
alias disable_movement "alias toggle_movement enable_movement;-forward"</pre>
 +
This script will cause a press of {{key|W}} to keep the player moving forward until {{key|W}} is pressed again.
  
===Voice Commands===
+
=== Key combinations ===
 +
It is possible to create a script where holding down a key changes the action of another key. For example, the following script can be used to make {{key|Alt}}+{{key|F4}} exit the game:
  
Voice command is the act of making your class say something, this is often used in gameplay as a way of either signaling information or just for goofing-off.
+
<pre>
 +
alias +alt_pressed  bind f4 exit
 +
alias -alt_pressed unbind f4
 +
 
 +
bind alt +alt_pressed
 +
</pre>
 +
Note that pressing Alt will execute <code>+alt_pressed</code>, and releasing it will execute <code>-alt_pressed</code>.
  
Voice commands are used with the following syntax;
+
=== Wait-testing ===
 +
Since the <code>wait</code> command is integral to some scripts, it may be necessary to test to see if a server has disabled the command.
  
'''voicemenu <menu_number> <phrase_number>
+
<pre>alias waitTester "alias waitTest waitPositive; wait 0; waitTest"
 +
alias wait "alias waitTest waitNegative"
 +
alias waitPositive "echo Wait is enabled on this server.; exec waitPositive.cfg"
 +
alias waitNegative "echo Wait is DISABLED on this server!; exec waitNegative.cfg"
 +
waitTester</pre>
 +
This script relies on the fact that if the wait command is disabled on a server, the alias named <code>wait</code> can be defined by the user. Thus, the script creates an alias named <code>waitTest</code> which by default points to <code>waitPositive</code>, but if <code>wait</code> is not allowed (and can thus be defined by the user), will be redirected to <code>waitNegative</code>.
  
Where <menu_number> is the one of the 3 menus where voice commands are spread out through <phrase_number> is one of the 7 voice commands that are within each <menu_number> menu.
+
=== Loops ===
 +
:'''Warning: Loops which run without a wait command will cause the TF2 client to hang. It is highly suggested to run a looping script only after a wait testing script.'''
 +
It is generally considered bad form to have one alias point to itself, as although the loop can be broken out of, it cannot be reset. Therefore, looping scripts tend to include two parts to the loop: The part that waits, and the part that loops.
  
====Arguments for voice commands====
+
<pre>bind g loopKey
 +
alias loopKey startLoop
 +
alias startLoop "alias loopKey stopLoop;+attack;alias redirect loop;loop"
 +
alias stopLoop "-attack;alias redirect;alias loopKey startLoop"
 +
alias loop "+left;wait 33;-left;+right;wait 33;-right;redirect"</pre>
  
*0 <phrase_number>
+
This script will start looping once {{Key|G}} is pressed. It begins by firing, and then switches the player's view back and forth every 33 frames (half of a second on most servers). Pressing {{Key|G}} would cause the next iteration of the loop to stop, also stopping the firing.
*:0: Medic
+
 
*:1: Thanks
+
=== Sequences ===
*:2: Go
+
<pre>alias +pyrocombo "slot1;+attack;wait 32;slot2"
*:3: Move Up
+
alias -pyrocombo "-attack;slot1"</pre>
*:4: Flank Left
+
This script will create two aliases, one to start a sequence, and one to end it. The sequence will switch to a Pyro's [[Degreaser]] and fire for 32 ticks, before switching to the [[Panic Attack]] and shooting until the button is no longer held. Sequences can also be made like this:
*:5: Flank Right
+
<br><pre>alias quickscope "slot1;+attack2;wait 32;+attack;wait 16;-attack;-attack2"</pre>
*:6: Yes
+
This script will create a sequence alias, that once activated will cause the Sniper to quick-scope his [[Sniper Rifle]]; by executing the long string of commands called a sequence.
*:7: No
+
Sequences are useful in making scripts, and learning how to make one will help in the long run of scripting.
*1 <phrase_number>
+
 
*:0: Incoming
+
=== Cycles ===
*:1: Cloaked Spy
+
A cycle is toggle script where there are a minimum of 3 possible options, which loop (ex, 1, 2, 3, 1). Example:
*:2: Sentry Ahead
+
<pre>
*:3: Teleporter Here
+
alias message_1 "say message 1.; bind x message_2"
*:4: Dispenser Here
+
alias message_2 "say message 2.; bind x message_3"
*:5: Sentry Here
+
alias message_3 "say message 3.; bind x message_1"
*:6: Activate ÜberCharge
+
bind x message_1
*:7: (Medic Only) ÜberCharge Ready
+
</pre>
*2 <phrase_number>
+
This script makes it so pressing the {{Key|X}} key will cycle between making you say "message 1", "message 2", and "message 3".
*:0: Help
 
*:1: Battlecry
 
*:2: Cheers
 
*:3: Jeers
 
*:4: Positive
 
*:5: Negative
 
*:6: Nice Shot
 
*:7: Good Job
 
  
===Quick Spy disguises===
 
  
With these quick and easy commands, you can bind keys to specific disguises instead of having to flip through the disguise menu.
+
{{note|<code>[[vdc:toggle|toggle]]</code>, <code>[[vdc:incrementvar|incrementvar]]</code>, and <code>[[vdc:multvar|multvar]]</code> can often be used in place of aliases when a console variable is being changed.}}
  
Disguise commands are used with the following syntax;
+
=== Selection addons ===
 +
A selection script is built onto a cycle to make it more intuitive. Selection scripts allow cycling upwards and downwards, ultimately giving more control for selecting which command(s) to run.
 +
<pre>
 +
alias CondC_UP Cond1
 +
alias CondC_DOWN Cond5
 +
alias ApplyCond ApplyCond33
 +
alias ApplyCond33 "addcond 33"
 +
alias ApplyCond49 "addcond 49"
 +
alias ApplyCond72 "addcond 72"
 +
alias ApplyCond74 "addcond 74"
 +
alias ApplyCond90 "addcond 90"
 +
alias Cond1 "alias CondC_UP Cond2;alias CondC_DOWN Cond5;alias ApplyCond ApplyCond33"
 +
alias Cond2 "alias CondC_UP Cond3;alias CondC_DOWN Cond1;alias ApplyCond ApplyCond49"
 +
alias Cond3 "alias CondC_UP Cond4;alias CondC_DOWN Cond2;alias ApplyCond ApplyCond72"
 +
alias Cond4 "alias CondC_UP Cond5;alias CondC_DOWN Cond3;alias ApplyCond ApplyCond74"
 +
alias Cond5 "alias CondC_UP Cond1;alias CondC_DOWN Cond4;alias ApplyCond ApplyCond90"
 +
</pre>
 +
This gives more control in what conditions to add to the player. This also allows for better freedom of selection and ease of use, as it makes scrolling through options in the cycle possible.
  
'''disguise <class_number> <team_number>
+
=== Randomization ===
 +
Randomization is a strange and niche feature. Randomization is rarely used, as most processes aren't as useful when randomized. However, randomization can be useful for chat binds, such as for trade advertising.
  
Where <class_number> is the number of the class you wish to disguise as, and <team_number> the number of the team you wish to disguise as.
+
'''Note: Due to the nature of TF2's scripting, this section will be considerably long. If you don't already have an understanding of how cycles work, the information presented may not be relevant.'''
 +
<pre>
 +
alias call f1
 +
alias cycle c2
  
====Arguments for disguise commands====
+
alias c1 "alias cycle c2;alias call f1"
 +
alias c2 "alias cycle c3;alias call f2"
 +
alias c3 "alias cycle c4;alias call f3"
 +
alias c4 "alias cycle c5;alias call f4"
 +
alias c5 "alias cycle c1;alias call f5"
  
*1 <class_number>
+
alias f1 "say 1"
*:1: Scout
+
alias f2 "say 2"
*:2: Sniper
+
alias f3 "say 3"
*:3: Soldier
+
alias f4 "say 4"
*:4: Demoman
+
alias f5 "say 5"
*:5: Medic
 
*:6: Heavy
 
*:7: Pyro
 
*:8: Spy
 
*:9: Engineer
 
  
*2 <team_number>
+
alias +w "+forward;cycle"
*:1: BLU team
+
alias -w "-forward;cycle"
*:2: RED team
+
alias +a "+moveleft;cycle"
*:-1: Opposite team
+
alias -a "-moveleft;cycle"
*:-2: Same team
+
alias +s "+back;cycle"
 +
alias -s "-back;cycle"
 +
alias +d "+moveright;cycle"
 +
alias -d "-moveright;cycle"
  
===Engineer Quickbuilding===
+
bind o call
 +
bind w +w
 +
bind a +a
 +
bind s +s
 +
bind d +d
 +
</pre>
 +
This script is assigning and resigning multiple alias values. When any of the {{key|WASD}} keys are pressed or released, the cycle command is ran, which moves the cycle command to the next value in the cycle and sets the "call" command to a value corresponding to the cycle number. This is based on the player's movement, and only changes values if the player is moving. It is possible to make this randomizer more effective by using other various techniques stated here (ex. Loops), but this example is for demonstration purposes only.
  
Similar to the [[Spy]]'s quick disguise, this allows the [[Engineer]] to bypass his [[PDA]] interface and instantly destroy an existing building type while simultaneously pulling up blueprints to place a new building of the same type.
+
=== Timed action ===
 +
Timed or held actions trigger when a button is pressed down for a certain amount of time. Timed actions can be used in situations where a script or command shouldn't be instantly ran the moment a button is pressed (ex. accidentally pressing a disconnect bind).
  
Building commands are used with the following syntax:
+
<pre>
 +
alias "+ti_zoom" "alias zoom_con zoomOn; wait 132; zoom_con"
 +
alias "-ti_zoom" "zoomOff; alias zoom_con ; rb_tizoom-M4"
 +
alias "rb_tizoom-M4" "unbind mouse4; wait 132; bind mouse4 +ti_zoom"
 +
alias "zoomOn" "fov_desired 20; r_drawviewmodel 0"
 +
alias "zoomOff" "fov_desired 90; r_drawviewmodel 1"
 +
bind "mouse4" "+ti_zoom"
 +
</pre>
  
'''build <building_number><br>
+
Pressing (and immediately releasing) {{key|Mouse 4}} with this script loaded will have no noticeable effect, however holding down {{key|Mouse 4}} for 2 seconds will cause the script to lower the FOV to 20, and hide viewmodels. Letting go of {{key|Mouse 4}} at any point will undo these changes by setting the FOV to 90 and unhiding viewmodels.
'''destroy <building number>
 
  
Where <building_number> is the number of the building you wish to destroy or pull up blueprints for.
+
This works because of the use of + and - aliases. Pressing the key <code>+ti_zoom</code> is bound to will redefine <code>zoom_con</code> to activate the script, and if left pressed for the <code>wait</code> duration will execute the script. However, if the button is released, <code>zoom_con</code> is redefined to do nothing. The key is then "disabled" by being unbound for the same <code>wait</code> duration, and rebound afterwards to restore use of the key.
  
====Arguments for building commands====
+
'''Note:''' Rebinding of the key is technically redundant, as the script will not execute the timed action if the button is released. However, if the button is pressed multiple times it is possible to execute the timed action if the confirmation alias (in this case, <code>zoom_con</code> is properly defined as any of the presses would execute it. Unbinding the key for the same duration of the original <code>wait</code> delay ensures that the effect can't be triggered if the button is rapidly pressed.
*Number: Building/Destroying
 
*:0: Dispenser
 
*:1: Teleporter Entrance
 
*:2: Sentry Gun/Minisentry
 
*:3: Teleporter Exit
 
  
An example of how to implement the above syntax is as follows:
+
=== Basic Conditionals ===
 +
{{rewrite}}
 +
The basic conditional allows a script to change its behavior without running an entirely new script. By making use of a dummy alias it is possible to change the outcome of an input based on other inputs. Basic conditionals can support potentially infinitely many checks on the state of other commands, however it's unlikely that a script would need more than a few checks per conditional.
  
 +
A very basic example of a conditional may look like:
 
<pre>
 
<pre>
alias sentry "destroy 2; build 2"
+
alias "check_test" "alias test success; check1; check2; test"
alias dispenser "destroy 0; build 0"
+
alias "check1" ""
alias entrance "destroy 1; build 1"
+
alias "check2" ""
alias exit "destroy 3; build 3"
+
alias "test" "success"
bind f1 sentry
+
 
bind f2 dispenser
+
alias "fail_check" "alias test failure"
bind f3 entrance
+
 
bind f4 exit
+
alias "success" "echo SUCCESS!"
 +
alias "failure" "echo FAILURE!"
 +
 
 +
alias "+k_pressed" "alias check1 fail_check"
 +
alias "-k_pressed" "alias check1"
 +
alias "+j_pressed" "alias check2 fail_check"
 +
alias "-j_pressed" "alias check2"
 +
 
 +
bind "l" "check_test"
 +
bind "j" "+j_pressed"
 +
bind "k" "+k_pressed"
 
</pre>
 
</pre>
  
In this example buildings are bound to the f1-f4 keys so they do not interfere with weapon selection keys. When activated, the script will instantly and irreversibly destroy an existing building of the listed type while pulling up the [[Engineer]]'s blueprints of the destroyed building's same type, ready to deploy. The script will still function if only one or two building types are used (in case you only want to map sentry quickbuilding to a single key).
+
The main function of this script is the <code>check_test</code> alias. When ran, this alias checks the other 2 conditionals, and if the checks succeed it runs the <code>success</code> alias. However, if one of the checks fails, the dummy alias <code>test</code> is pointed to run the <code>failure</code> alias. Simply put, when a check succeeds the checking command doesn't redirect the alias <code>test</code> is pointing to. If a check fails, it redirects the <code>test</code> alias to the alias storing the code to run when the check fails.  
 +
 
 +
In this case, pressing the button {{key|L}} without pressing either {{key|J}} or {{key|K}}, the check succeeds and prints <code>SUCCESS!</code> to the console. When pressing and holding either {{key|J}} or {{key|K}} and then pressing {{key|L}}, the check will fail and print <code>FAILURE!</code> to the console.
  
===Medic Autocall===
+
A real world example of basic conditionals:
The Medic can control his autocall threshold through keybinds. The command is:
+
<pre>
 +
// Change the crosshair color when moving around
  
'''hud_medicautocallersthreshold <percentage>
+
alias "+w_pressed" "+forward;  alias check_w pressed_w; chc_forward"
 +
alias "+a_pressed" "+moveleft;  alias check_a pressed_a; chc_left"
 +
alias "+s_pressed" "+back;      alias check_s pressed_s; chc_back"
 +
alias "+d_pressed" "+moveright; alias check_d pressed_d; chc_right"
  
The percentage is the percent health below which the autocall is triggered; 0 will show nothing, while 150 will show all nearby allies (since 150% is the maximum possible health).
+
alias "-w_pressed" "-forward;   alias check_w; check_none"
 +
alias "-a_pressed" "-moveleft;  alias check_a; check_none"
 +
alias "-s_pressed" "-back;      alias check_s; check_none"
 +
alias "-d_pressed" "-moveright; alias check_d; check_none"
 +
 
 +
alias "check_w"
 +
alias "check_a"
 +
alias "check_s"
 +
alias "check_d"
 +
 
 +
alias "pressed_w" "dchk_fail; chc_forward"
 +
alias "pressed_a" "dchk_fail; chc_left"
 +
alias "pressed_s" "dchk_fail; chc_back"
 +
alias "pressed_d" "dchk_fail; chc_right"
 +
 
 +
alias "check_none" "check_s; check_a; check_d; check_w; dmy_check"
 +
alias "dmy_check" "chc_success"
 +
 
 +
alias "dchk_fail" "alias dmy_check chc_failure"
 +
alias "dchk_reset" "alias dmy_check chc_success"
 +
 
 +
alias "chc_failure" "dchk_reset"
 +
alias "chc_success" "chc_default"
 +
 
 +
alias "chc_default" "color0"
 +
alias "chc_forward" "color1"
 +
alias "chc_left"    "color2"
 +
alias "chc_back"    "color3"
 +
alias "chc_right"  "color4"
 +
 
 +
// Binds
 +
bind "w" "+w_pressed"
 +
bind "a" "+a_pressed"
 +
bind "s" "+s_pressed"
 +
bind "d" "+d_pressed"
 +
 
 +
// Colors
 +
alias "color0" "cl_crosshair_red 0; cl_crosshair_green 255; cl_crosshair_blue 0"        // Default color when not moving
 +
alias "color1" "cl_crosshair_red 0; cl_crosshair_green 0; cl_crosshair_blue 255"        // Color when moving forward
 +
alias "color2" "cl_crosshair_red 255; cl_crosshair_green 0; cl_crosshair_blue 255"      // Color when moving left
 +
alias "color3" "cl_crosshair_red 128; cl_crosshair_green 212; cl_crosshair_blue 255"    // Color when moving back
 +
alias "color4" "cl_crosshair_red 255; cl_crosshair_green 140; cl_crosshair_blue 25"    // Color when moving right
 +
</pre>
  
This command can be used to make the popular "Medic Radar" script:
+
This script will change the color of the user's crosshair as they walk around with the {{key|WASD}} keys. An important note this script takes advantage of is that when a check fails it can do several things instead of just changing the dummy command for testing. When a check fails the crosshair will change colors, and also change the dummy command to fail the check. This means when several buttons are released, the crosshair's color will properly change to the most recently pressed key.
This set of aliases and commands will temporarily boost the [[Medic]]'s autocall threshold to 150% (a fully-overhealed player)for as long as they hold a key down, allowing him to see where all of his teammates are by their [[Medic]] autocall speech bubbles in the event he finds himself alone.
 
  
  '''alias "autocall_default" "hud_medicautocallersthreshold "75""<br>
+
== Commenting ==
  '''alias "autocall_all" "hud_medicautocallersthreshold "150""<br>
+
As scripts get longer, the need for well-named aliases grows. However, it is not always sufficient to explain what an alias does simply by its name. Adding a pair of forward slashes (//) will turn the rest of the line into a comment–it will not execute any actions on the text.
  '''alias "+radar" "autocall_all"<br>
 
  '''alias "-radar" "autocall_default"<br>
 
  '''bind mouse3 "+radar"<br>
 
  
The default autocall value, or the autocall threshold when this command is not in use, can be adjusted to any desired number (in the example it is listed as 75% health) and the keybind to activate it can be changed as well (the example is bound to mouse3).
+
<pre>voicemenu 1 6 //Activate Charge!</pre>
 +
Since it is not obviously clear what the voice command is, a comment can explain it.
  
==Noteworthy scripts==  
+
== Noteworthy scripts ==  
 +
There are several notable scripts that have affected gameplay. Some of these are patched out, while others remain functional.
  
There are several notable scripts that have affected gameplay.  Some of these are patched out. Others remain functional.
+
=== Patched scripts ===
 +
==== Pistol scripts ====
 +
Originally, the [[Pistol]] could be fired almost as fast as the human hand could press a key. Scripts were created to simulate this rapid pressing by holding down a single key.
  
===Patched Scripts===
+
{{Patch name|8|13|2009}}: The Pistol now fires at a fixed rate, not based on the speed of pressing the fire button.
 +
==== Chargin' Targe turn scripts ====
 +
Originally, the keyboard commands to turn left and right were not treated the same as the mouse commands. The [[Chargin' Targe]] was the first weapon to create a restriction on how quickly a player could turn, therefore Valve put a limit on mouse turn-speed, yet forgot to apply the same restriction to the keyboard command that resulted in the same action. Scripts were created to rebind the turning controls when a player charged, circumventing this restriction.
  
====Pistol Scripts====
+
{{Patch name|6|23|2011}}: Fixed an exploit with the Chargin' Targe that allowed greater turning control than intended.
  
Originally, the [[Pistol]] could be fired almost as fast as the human hand could press a key. Realizing this, some people created scripts that made the Pistol fire as rapidly as possible as long as you held down the fire button.  This not only allowed the [[Scout]] and [[Engineer]] to fire faster than most people could manage, but it was easier to aim because you weren't mashing any keys.
+
==== Air crouching scripts ====
 +
Originally, players could crouch as many times as they liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, the engine could be exploited to make it difficult to properly register shots on jumping targets.
  
Valve eventually leveled the playing field.  They patched the Pistol to have a lower max firing rate, which was reached by default whenever a player held down the attack key.  The Pistol scripts were no longer necessary.
+
{{Patch name|3|6|2009}}: Players can now only duck twice in the air.
  
====Targe Turn Scripts====
+
==== Idling Scripts ====
 +
Most servers seek to prevent players idling for [[Item drop system|drops]]. Players can try to outsmart these systems with scripts that simulate basic movement.
  
Originally, the keyboard commands to turn your viewpoint left and right were not treated the same as the mouse commands.  The [[Chargin' Targe]] was the first weapon to create a restriction on how quickly you could turn your viewpoint, therefore Valve put a limit on mouse turn-speed but forgot to apply the same restriction to the keyboard command that resulted in the same action.
+
[http://www.teamfortress.com/post.php?id=11105 An Active Solution to an Idle Threat] requires players to accept a pop-up notification in order to continue to get drops.
  
Players made scripts that rebound keys whenever a player charged, allowing them to turn at full speed. The most sophisticated examples temporarily rebound the mouse x-axis inputs to the keyboard turn commands, then unbound them when the player attacked at the end of the charge.
+
=== Current Scripts ===
 +
==== Weapon Viewmodel Hiding Scripts ====
 +
There are a large number of scripts which toggle the weapon viewmodel depending on which weapon slot is selected for a class. Players often make their viewmodels invisible to clear up the screen, but make items like melee weapons, PDAs, watches, and so forth visible because these models indicate important information. For example, the [[Spy]] relies heavily on his viewmodel to determine when he is cloaked, when his Cloak is disturbed, and when the [[Dead Ringer]] activates. Other classes use the melee animations to judge when their attacks will hit.
  
Valve eventually capped the keyboard turn commands as they did with the mouse commands, thus conferring no advantage to individuals who used the script.
+
==== Weapon Zoom Scripts ====
 +
By changing your [[FOV]], this script creates the visual effect of zooming in with whatever weapon the user is holding. It can usually be toggled between a zoomed and normal (unzoomed) version.
  
However, it is still possible to write a script that will toggle Sensitivity between insanely high values when charging and normal value when the player performs an attack. It is also possible to turn easily while using a gamepad's analog sticks.
+
==== Sentry Jumping Scripts ====
 +
Since the [[Engineer Update]], Engineers have been able to pack up and carry their [[Sentry Gun]]s. Simultaneously introduced in the update, the [[Wrangler]] allows Engineers to [[Sentry jump]] with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.
  
====Air Crouching Scripts====
+
While a human can repeat this feat, it is difficult. Some players made scripts which could reliably execute the commands in the right order at the right speed allowing them to make a Sentry jump while carrying their Sentry every time.
 +
:''Note:'' The [[Rescue Ranger]] can circumvent this necessity, as it can pick up [[buildings]] at range for 100 [[metal]].
  
Originally, you could crouch as many times as you liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, you could exploit the engine and make it difficult to properly register shots on jumping targets.
+
==== Gunslinger Scripts ====
 +
Since it can be troublesome to destroy then rebuild a [[Combat Mini-Sentry]] in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Combat Mini-Sentry with the click of one or two buttons. Such a script is especially useful when using the [[Frontier Justice]], as the player gains practically instant access to revenge Crits when needed.
  
Valve patched it so you could only crouch twice in a single jump.
+
==== Sensitivity and Control scripts ====
 +
Some players prefer different mouse sensitivities and control schemes for some classes. For example, changing from the Medic, which doesn't require fine aiming, to the Sniper, which encourages high precision headshots, a player may wish to change their mouse sensitivity. These scripts alter control schemes and mouse settings on a per class, or even per weapon, basis.
  
===Current Scripts===
+
==== Charge Dash Scripts ====
 +
Since timing a charge and jump can be difficult, some players may use a quick script that binds the two actions to a button so that the charge dash will cover the maximum amount of distance possible. The player is still required to swing their melee weapon normally to end the charge though.
  
====Weapon Hiding Scripts====
+
==== Quickscope Scripts ====
 +
Many players find it difficult to scope in and fire straight after to get a quick headshot. There are scripts that will zoom in and fire just by clicking one button. This does require players to aim outside of the scope, though.
  
There are a large number of scripts which toggle the weapon display option depending on which weapon slot is selected for a class.  Players often make their guns invisible to clear up the screen, but make items like melee weapons, PDAs, watches and so forth visible because these models indicate important information.  For example, the [[Spy]] relies heavily on his visible model to determine when he is cloaked, when his Cloak is disturbed, and when the [[Dead Ringer]] activates. Other classes use the melee animations to judge when their attacks will hit.
+
==== Rocket Jump Scripts ====
 +
In order to [[Jumping#Soldier jumps|Rocket Jump]] to a maximum height or distance, it is required that the player jumps, crouches, and fires their rocket at roughly the same time. This can be easily scripted to occur with the press of a button.
  
====Sentry Jumping Scripts====
+
==== Auto-Disguise Scripts ====
 +
For Spies who find manually disguising to be a hassle, this script automatically disguises as a chosen class after the player attacks with any weapon. Auto-disguise can usually be toggled and customized to choose a disguise to use.
  
Since the [[Engineer]] update, Engineers have been able to pack up and carry their [[Sentry Gun]]s.  Simultaneously, the [[Wrangler]] allowed Engineers to [[Sentry jump]] with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.
+
==== ÜberCharge Broadcasting Scripts ====
 +
With this script, activating ÜberCharge as [[Medic]] will also write a custom message in team chat to alert your teammates about your activation, in order to encourage your team to push ahead with you. A similar script, upon activation, plays the "ÜberCharge Ready" voice command while writing in team chat that you faked your Über to fool the enemy team.
  
While a human can repeat this feat, it's difficult and sometimes inconsistent. Some players made scripts which could reliably execute the commands in the right order at the right speed. They can make a Sentry jump while carrying their Sentry every time.
+
==== Medic Radar ====
 +
This script only works for Medic, as it lets you press a button to temporarily set the autocall percentage to a very high number. This makes it so that you can see the locations of nearby teammates.  
 +
Script:
 +
<pre>alias "autocall_default" "hud_medicautocallersthreshold 75.730003/Custom Threshold"
 +
alias "autocall_all" "hud_medicautocallersthreshold 150"
 +
alias "+radar" "autocall_all"
 +
alias "-radar" "autocall_default"
 +
bind [KEY] "+radar</pre>
  
====Gunslinger Scripts====
+
==== Kill-Bind Scripts ====
 +
{{main|Suicide}}
 +
In certain circumstances, such as when cornered by a Medic wielding the [[Ubersaw]], it can be beneficial for a class to be able to kill themselves quickly (in this case, to deny the Medic Über) with a key bind (for example, <code>bind k kill</code>). Although mostly only relevant in competitive play, there are occasional uses in public servers, often for comedic effect instead of to benefit gameplay. The killbind can be set to explode you if you use <code>explode</code> instead (for example, <code> bind k explode</code>). There is no difference between these two mechanically.
  
Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Mini-Sentry with the click of one or two mouse buttons.
+
==== Null-Cancelling Movement Scripts ====
 +
In stock TF2, pressing two opposing movement keys at once (such as "A" (+moveleft) and "D" (+moveright)) will cancel all movement and render the player immobile, which can be a fatal mistake during battle. This script makes it so that the direction of the last key pressed will be used instead. For example, pressing "A" will make the player go left, and pressing "D" while still holding "A" will make the player go right instead of stopping.
  
====Sensitivity and Control Scripts====
+
==== Chat Bind Scripts ====
 +
Chat bind scripts are designed to post a pre-written message in the in-game text chat. Typically, users will bind these scripts to a key on their keyboard for easy repetition. These scripts can vary from user-to-user, and can say anything within the text limit, depending on what a player would want to say. Some common binds are used for team co-ordination, such as a bind to tell a team that their Medic has popped an [[ÜberCharge]]. Other common binds are used for banter, such as messages upon kills and/or dominations. Another variation on this is a trade offer bind, where it sends information to the chat about a possible trade offer. This type of script can also be automated to send these offers every couple of minutes.
  
Some players prefer different mouse sensitivities and control schemes for some classes (for example, changing from Demo, which doesn't require fine aiming, to Sniper, which encourages low sensitivity for precise aiming so a hand twitching inadvertently won't ruin your aim too much).  These scripts alter their control schemes and mouse settings on a per class or even per weapon basis.
+
==== Voice Toggle ====
 +
This script enables you to voice toggle, instead of push-to-talk.  
 +
Script:
 +
<pre>bind [KEY] mic_toggle
 +
alias mic_toggle mic_enable
 +
alias mic_enable "+voicerecord; alias mic_toggle mic_disable"
 +
alias mic_disable "-voicerecord; alias mic_toggle mic_enable"</pre>
  
====Charge Dash Scripts====
+
== Notes ==
Since timing the charge and jump can be difficult, some may use a quick script that binds the two actions to a button so that the charge dash will do the maximum amount of distance possible.  The user is still required to swing their melee weapon normally to end the charge though.
+
* Each config file is limited to one [[w:mebibyte|mebibyte]] (1.04858 megabytes) of information, though this restriction can be circumvented by [[#Exec|exec-ing]] another config file at the end of the first.
  
==See Also==
+
== See also ==
 
* [[List of useful console commands]]
 
* [[List of useful console commands]]
* [[Customizing#tf.5Ccfg.5Cconfig default.cfg|Customizing - config_default.cfg]]: The default key-binds within TF2.
+
* {{vdc|List of TF2 console commands and variables}}
 +
* {{vdc|Command Line Options|Command Line Options}}
 +
* {{vdc|VScript}}
 +
* [[Cheats]]
  
==External Links==
+
== External links ==
 +
* [https://gamebanana.com/scripts/games/297 Hundreds of scripting examples on Gamebanana]
 +
* [https://cfg.tf cfg.tf, website dedicated to Team Fortress 2 configuration]
  
*[http://forums.steampowered.com/forums/showthread.php?t=709568 Steam Users' Forums - TF2 Scripting Tutorial]. This covers the basics of scripting, using numerous useful, approachable examples.
 
*[http://warriornation.net/Forum/showthread.php?t=568008 TF2 scripting tutorial - Warrior Nation Network]. This is a much more advanced article, which requires pre-requisite knowledge of the basic scripting syntax.
 
*[http://www.gamebanana.com/scripts/games/297 Gamebanana.com - TF2 scripts]. Hundreds of scripting examples for TF2.
 
 
[[Category:Customization]]
 
[[Category:Customization]]

Latest revision as of 16:20, 2 November 2024

This thing ain't on auto-pilot, son!
The Engineer after using his sentry jump script

Scripting is the use of configuration files (.cfg) typically used to create new keybinds and aliases, change advanced graphical settings, automating complex behaviors, and creating sequences of console commands. Unlike hacking, scripting is an intentional feature natively built into Team Fortress 2, and will not trigger a VAC (Valve Anti-Cheat) ban. The complexity of scripting varies from simply binding an input key to output a command, to self-referential loops and nested aliases that redefine one another. There are many graphical settings that can only be changed through the use of console commands, or scripts that automate the input of said console commands. Outside of specific graphical settings, most other functions that can be performed via scripting may also be achieved without it, but scripting grants the advantage of allowing these functionalities to be instantly executed within the heat of battle.

Contents

Scripting Commands

The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly.

bind

Main article: bind

The simplest command is the bind command. It will cause a certain key to execute a certain action, whether that action is a setting, a command, or a script.

bind [KEY] [COMMAND]

Quotes can be optionally placed around the key and/or the command. However, the commands will need to have quotes when it has spaces in between the values and the command, so that the console can interpret it as one command. An example would be bind mouse1 "say texthere", where quotes are needed around "say texthere" because of the space between the two phrases.

bind [KEY] "[COMMAND 1];[COMMAND 2];[COMMAND 3]"

Quotes can be optionally placed around the key, but must be present around the commands, as the console will not interpret consecutive commands if quotes are not present.

Note: The command say "Example Text" is correct, but bind <KEY> "say "Example Text"" is not. This is because the quotes are misinterpreted, and quotes inside of quotes are unnecessary due to commands automatically stopping at every semicolon.

When a key is bound to a string starting with a plus, the same command(s) will be executed when the key is released, except the first plus will be replaced with a minus. For example, bind w +forward will make pressing W execute +forward and releasing W execute -forward. Note that this only effects the first command, and other commands will not be negated. See alias for more information. This bind will make the player move forward while they have W held down.

toggle

This command allows a cvar to be toggled between two or more values. If no values are specified, defaults to toggling between 0 and 1.

toggle tf_bot_quota normal fill match

bindToggle

BindToggle may be used to bind a key to toggle a cvar between 0 and 1. It cannot be used for values besides 0 and 1.

bindToggle o sv_cheats

incrementvar

This allows for variables to be increased or decreased repeatedly by a set amount.

bind MWHEELUP "incrementvar fov_desired 75 90 1"
bind MWHEELDOWN "incrementvar fov_desired 75 90 -1"

This will cause the field of view to increase when scrolling up, and to decrease when scrolling down

Note: Incrementvar will cause the value to wrap around if it gets too large or too small. In this example, once the field of view hits 90, it will drop down to 75, and vice-versa.

alias

Main article: alias

An alias allows multiple commands to be referenced by a single command. This is effectively shorthand, and it is most useful when a series of commands need to be called multiple times. Alias names cannot contain spaces. They may contain underscores, numbers, symbols, and are not case-sensitive (only when being created, when removing an alias it is case-sensitive). Aliases may not overwrite existing commands or variables except those that start with a plus or minus (for example, alias help is disallowed, but alias +forward is allowed).

After running the command alias foo "echo bar", typing foo in the console will execute echo bar. After running the command alias foo, typing foo in the console will no longer do anything. If the alias was created with uppercase letters (such as alias fOO "echo bar"), typing alias foo will not remove the alias, but alias fOO will.

Aliases may begin with a plus or minus character. This allows them to be used in conjunction with bind to negate several commands when a key is released. For example, this script allows a player to move diagonally with a single key:

alias +diagonal "+moveleft; +back"
alias -diagonal "-moveleft; -back"
bind z "+diagonal"

Releasing Z will execute -diagonal in this script, whereas simply typing bind "z" "+moveleft; +back" would result in the game never running -back when the player releases the key. This results in the player moving backwards continuously.

exec

This command will execute another file. This means that complex scripts can be stored in other files, so as not to clutter up more general files.

exec highquality This script will execute the config named highquality.cfg script within the tf/cfg folder.

echo

This command will cause text to be printed to the console. This is very useful for debugging.

echo Scripting is; echo very useful

This will print out Scripting is and very useful on two separate lines. This is because a newline is added to the end of any text passed to echo. Spaces are only parsed if they are between words, or if the echoed text is between quotes, as in the next example:

echo " Scripting is very useful.   "

The extra spaces will be printed out, since the string is delimited by quotation marks.

Note: It is not possible to print out the " character, as its meaning will be misinterpreted. However, you can print single quotes: that is, the ' character.
Note: Echo occasionally will misprint strings that are not delimited by quotation marks. As a general rule of thumb, it is better to enclose what you wish to print within quotation marks. It also makes it easier to read for humans.

wait

This command will make the game wait a given number of frames before executing the next command.

Warning: Wait commands are disabled on certain servers. This will cause certain scripts to fail, and may (in semi-rare cases) cause the game to crash. See Wait Testing for help to protect against this.
echo Why did the chicken cross the road?;wait 300;echo To get to the other side!

This script will wait 300 frames (1 second at the default max FPS) before printing the punchline.

Class-specific CFG Files

When switching to a certain class, the game executes the corresponding CFG file (if it exists), named after the given class.

scout.cfg
soldier.cfg
pyro.cfg
demoman.cfg
heavyweapons.cfg
engineer.cfg
medic.cfg
sniper.cfg
spy.cfg

This automation lets the player have different keybinds and game settings for each class.

VPK files and config files

.vpk files take priority over config files located within the cfg folder. Mods using .vpk files may run the risk of negatively interfering with any custom configuration changes, however, some mods provide methods to override the configs from within the .vpk files natively.

Launch Options

Launch options can be used to change how TF2 runs, both in terms of performance and functionality. Please see Command Line Options on the Valve Developer Community for a comprehensive list of launch options.

Set Launch Options

A visual guide on how to set launch options (indicated by the pink circles).
  1. Right-click on the game title under the Library in Steam and select Properties.
  2. Under the General tab click the Set launch options... button.
  3. Enter the launch options you wish to apply (be sure to separate each code with a space) and click OK.
  4. Close the game's Properties window and launch the game.

Window Options

Note that these may incorrectly setup an improper video mode not preferred by the material system, reducing performance. Where possible, you should use the in-game settings instead.

Resolution

Launch Option: -w # -h #

Description: Forces the game resolution width and height in pixels.

Refresh Rate

Launch Option: -freq #

Description: Forces the game refresh rate in Hz.

Windowed Mode

Launch Option: -windowed

Description: Launches the game in windowed mode.

Borderless Windowed Mode

Launch Option: -noborder

Description: When in windowed mode, remove the window border to allow for borderless fullscreen mode, as opposed to exclusive fullscreen mode.

Fullscreen Mode

Launch Option: -fullscreen

Description: Forces the game resolution width and height in pixels.

Peripheral Support

Disable Joystick Support

Launch Option: -nojoy

Description: Prevents the joystick system from loading, improving start-up time and memory usage. Don't use this if you intend to use a joystick with the game.

Disable Steam Controller Support

Launch Option: -nosteamcontroller

Description: Prevents the Steam controller system from loading, improving start-up time and memory usage. Don't use this if you intend to use a Steam controller with the game.

Software Support

Disable SourceTV

Launch Option: -nohltv

Description: Disables SourceTV support, improving memory usage. Don't use this if you host SourceTV on your client.

Engine Options

Disable Intro Video

Launch Option: -novid

Description: Removes the Valve intro video shown when the game is started, improving loading times.

Change Beam Particle Limit

Launch Option: -particles #

Description: Limits the number of beam particles. Set # to '1' to (a limit of 512) to improve memory usage.

Precache Font Rendering

Launch Option: -precachefontchars

Description: Precaches font rendering for common characters, improving rendering time.

Disable Texture Streaming

Launch Option: -no_texture_stream

Description: Disables using lower quality textures whilst higher quality versions load, instead favoring to always instantly load the higher quality versions. Disabling texture streaming results in a performance boost on systems running GPUs with low VRAM (video memory).

DirectX Version (Windows exclusive)

Launch Option: -dxlevel #

Description: Sets the DirectX Version used by the game; accepts many values ranging from 80 to 100. The manual setting of DirectX levels is experimental and is typically altered to support older hardware.
'-dxlevel 100' uses DirectX 9. Hardware is automatically detected to determine the system's graphical capabilities.
'-dxlevel 81' is the most stable version of DirectX for GPUs released prior to 2004. DirectX 8 has a reduced feature set such as a lack of War Paints and transparency on models (such as the Voodoo-Cursed Souls). Values below 81 will cause even more graphical issues. This should be avoided unless necessary for compatibility reasons.
Note: After launching the game with the -dxlevel command once, the game should then be closed, and then the launch option removed entirely before launching the game again.

Vulkan (Windows exclusive)

Launch Option: -vulkan

Description: Enables Vulkan rather than DirectX. Vulkan is enabled by default on Linux systems.

Execute Other Scripts on Startup

Launch Option: +exec script.cfg

Description: Executes the specified script when the game launches.

Pictogram comment.png Note: A config named autoexec.cfg is automatically executed on startup.

List of key names

Hover over a key to see its scripting name. Names are not case-sensitive.

ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12

`   1 2 3 4 5 6 7 8 9 0 - = ← Backspace

Tab ⇆ Q W E R T Y U I O P [ ] \      

⇪ Caps A S D F G H J K L ; '   Enter ↵

Shift     Z X C V B N M ,   .   /   Shift        

Ctrl   Alt       Spacebar       Alt ≣ Menu Ctrl    

PrtScn ScrLk Pause

Insert   Home PgUp

Delete   End   PgDn


                 

         

Num / * -
7 8 9 +
4 5 6
1 2 3
    0     .
Mouse Button Name of Keybind
Scroll Up MWHEELUP
Scroll Down MWHEELDOWN
Left Click MOUSE1
Right Click MOUSE2
Wheel Click MOUSE3
Left Button Click (forward) MOUSE4
Right Button Click (back) MOUSE5

Useful commands

Main article: List of TF2 console commands and variables

Disguising

The disguise command takes two arguments, the first being the class and the second being the team.

Class
1. Scout
2. Sniper
3. Soldier
4. Demoman
5. Medic
6. Heavy
7. Pyro
8. Spy
9. Engineer
Team
1. BLU team
2. RED team
-1. Opposite team
-2. Same team

Thus, disguise 5 1 would disguise as a BLU Medic and disguise 7 -2 would disguise as a friendly Pyro.

Note: disguise 8 -2 (Friendly Spy) will cause the player to un-disguise.
Note: Any collection of characters and/or numbers after the class number that are not 1, 2, -1, or -2 will default the disguise to RED team, regardless of the player's current team. For example, disguise 1 3 will disguise the Spy as a RED Scout.

Buildings

The build and destroy commands each take two arguments, the first being the building and the second being the building type. The second argument is only required if it is not 0, and is currently only used to differentiate between teleporter entrances and exits.

The build command will pull up the blueprint to place a building, with an exception of the Sapper, which is wielded.

build 0 0 will build a Dispenser (Engineer only)
build 1 0 will build a teleporter entrance (Engineer only)
build 1 1 will build a teleporter exit (Engineer only)
build 2 0 will build a Sentry Gun (Engineer only)
build 3 0 will build a Sapper (Spy only)

Similarly, the destroy command will destroy buildings.

destroy 0 0 will destroy a Dispenser (Engineer only)
destroy 1 0 will destroy a teleporter entrance (Engineer only)
destroy 1 1 will destroy a teleporter exit (Engineer only)
destroy 2 0 will destroy a Sentry Gun (Engineer only)
Note: Sappers cannot be destroyed.

It is possible to use the old build commands, which used only one argument.

build 0 will build a Dispenser (Engineer only)
build 1 will build a teleporter entrance (Engineer only)
build 2 will build a Sentry Gun (Engineer only)
build 3 will build a teleporter exit (Engineer only)
build 3 will build a Sapper (Spy only) [deprecated]

Voice Menu

The voicemenu command takes two arguments, the menu number and the command number.

  • voicemenu 0
    0: MEDIC!
    1: Thanks!
    2: Go! Go! Go!
    3: Move Up!
    4: Go Left
    5: Go Right
    6: Yes
    7: No
    8: Pass To Me!
  • voicemenu 1
    0: Incoming
    1: Spy!
    2: Sentry Ahead!
    3: Teleporter Here
    4: Dispenser Here
    5: Sentry Here
    6: Activate Charge!
    7: MEDIC: ÜberCharge Ready
    8: Pass To Me!
  • voicemenu 2
    0: Help!
    1: Battle Cry
    2: Cheers
    3: Jeers
    4: Positive
    5: Negative
    6: Nice Shot
    7: Good Job
Note: If you wish to display the voicemenu, rather than fire the voicemenu <num> <num> message, the command is voice_menu_<num>: where <num> is a number between 1 and 3, and takes no arguments. For instance, to display the first voicemenu, one would run the command voice_menu_1.

Eureka Teleport

The eureka_teleport can teleport an Engineer holding the Eureka Effect to their spawn or teleporter exit.

  • eureka_teleport 0 will teleport the player to their spawn
  • eureka_teleport 1 will teleport the player to their teleporter exit

The player will see "Unknown command" in their console even though the command works.

Assorted

  • clear will clear the console of any information.
  • alias will list all currently defined aliases.
  • fov_desired (20-90) will set the field of view.
  • viewmodel_fov will set the FOV for weapon models. It ranges by default from 54 to 70.
  • r_drawviewmodel (0/1) will show (1) or hide (0) weapon models.
  • lastdisguise will cause the player to re-disguise as their last disguise. (Spy only)
  • load_itempreset (0-3) will load a particular loadout preset [A, B, C, D].
  • say message will send a message to public chat.
  • say_team message will send a message to team chat.
  • say_party message will send a message to party chat.
  • +taunt will open the player's taunt loadout.
  • +use_action_slot_item will cause the player to use their action slot item.
  • volume (0-1) will change the in-game volume.
  • taunt_by_name (name) will run a specified taunt, given the exact name of a taunt in the player's current taunt loadout, without opening the taunt menu.
  • key_findbinding (string) will list all keys bound to a string containing the given substring (case-sensitive).
  • key_listboundkeys will list all keys currently bound and their associated commands.

Advanced Scripting Techniques

Toggles

It is possible to bind a key to toggle a command which would otherwise be a press and hold command.

bind w toggle_movement
alias toggle_movement enable_movement
alias enable_movement "alias toggle_movement disable_movement;+forward"
alias disable_movement "alias toggle_movement enable_movement;-forward"

This script will cause a press of W to keep the player moving forward until W is pressed again.

Key combinations

It is possible to create a script where holding down a key changes the action of another key. For example, the following script can be used to make Alt+F4 exit the game:

alias +alt_pressed   bind f4 exit
alias -alt_pressed unbind f4

bind alt +alt_pressed

Note that pressing Alt will execute +alt_pressed, and releasing it will execute -alt_pressed.

Wait-testing

Since the wait command is integral to some scripts, it may be necessary to test to see if a server has disabled the command.

alias waitTester "alias waitTest waitPositive; wait 0; waitTest"
alias wait "alias waitTest waitNegative"
alias waitPositive "echo Wait is enabled on this server.; exec waitPositive.cfg"
alias waitNegative "echo Wait is DISABLED on this server!; exec waitNegative.cfg"
waitTester

This script relies on the fact that if the wait command is disabled on a server, the alias named wait can be defined by the user. Thus, the script creates an alias named waitTest which by default points to waitPositive, but if wait is not allowed (and can thus be defined by the user), will be redirected to waitNegative.

Loops

Warning: Loops which run without a wait command will cause the TF2 client to hang. It is highly suggested to run a looping script only after a wait testing script.

It is generally considered bad form to have one alias point to itself, as although the loop can be broken out of, it cannot be reset. Therefore, looping scripts tend to include two parts to the loop: The part that waits, and the part that loops.

bind g loopKey
alias loopKey startLoop
alias startLoop "alias loopKey stopLoop;+attack;alias redirect loop;loop"
alias stopLoop "-attack;alias redirect;alias loopKey startLoop"
alias loop "+left;wait 33;-left;+right;wait 33;-right;redirect"

This script will start looping once G is pressed. It begins by firing, and then switches the player's view back and forth every 33 frames (half of a second on most servers). Pressing G would cause the next iteration of the loop to stop, also stopping the firing.

Sequences

alias +pyrocombo "slot1;+attack;wait 32;slot2"
alias -pyrocombo "-attack;slot1"

This script will create two aliases, one to start a sequence, and one to end it. The sequence will switch to a Pyro's Degreaser and fire for 32 ticks, before switching to the Panic Attack and shooting until the button is no longer held. Sequences can also be made like this:


alias quickscope "slot1;+attack2;wait 32;+attack;wait 16;-attack;-attack2"

This script will create a sequence alias, that once activated will cause the Sniper to quick-scope his Sniper Rifle; by executing the long string of commands called a sequence. Sequences are useful in making scripts, and learning how to make one will help in the long run of scripting.

Cycles

A cycle is toggle script where there are a minimum of 3 possible options, which loop (ex, 1, 2, 3, 1). Example:

alias message_1 "say message 1.; bind x message_2"
alias message_2 "say message 2.; bind x message_3"
alias message_3 "say message 3.; bind x message_1"
bind x message_1

This script makes it so pressing the X key will cycle between making you say "message 1", "message 2", and "message 3".


Pictogram comment.png toggle, incrementvar, and multvar can often be used in place of aliases when a console variable is being changed.

Selection addons

A selection script is built onto a cycle to make it more intuitive. Selection scripts allow cycling upwards and downwards, ultimately giving more control for selecting which command(s) to run.

alias CondC_UP Cond1
alias CondC_DOWN Cond5
alias ApplyCond ApplyCond33
alias ApplyCond33 "addcond 33"
alias ApplyCond49 "addcond 49"
alias ApplyCond72 "addcond 72"
alias ApplyCond74 "addcond 74"
alias ApplyCond90 "addcond 90"
alias Cond1 "alias CondC_UP Cond2;alias CondC_DOWN Cond5;alias ApplyCond ApplyCond33"
alias Cond2 "alias CondC_UP Cond3;alias CondC_DOWN Cond1;alias ApplyCond ApplyCond49"
alias Cond3 "alias CondC_UP Cond4;alias CondC_DOWN Cond2;alias ApplyCond ApplyCond72"
alias Cond4 "alias CondC_UP Cond5;alias CondC_DOWN Cond3;alias ApplyCond ApplyCond74"
alias Cond5 "alias CondC_UP Cond1;alias CondC_DOWN Cond4;alias ApplyCond ApplyCond90"

This gives more control in what conditions to add to the player. This also allows for better freedom of selection and ease of use, as it makes scrolling through options in the cycle possible.

Randomization

Randomization is a strange and niche feature. Randomization is rarely used, as most processes aren't as useful when randomized. However, randomization can be useful for chat binds, such as for trade advertising.

Note: Due to the nature of TF2's scripting, this section will be considerably long. If you don't already have an understanding of how cycles work, the information presented may not be relevant.

alias call f1
alias cycle c2

alias c1 "alias cycle c2;alias call f1"
alias c2 "alias cycle c3;alias call f2"
alias c3 "alias cycle c4;alias call f3"
alias c4 "alias cycle c5;alias call f4"
alias c5 "alias cycle c1;alias call f5"

alias f1 "say 1"
alias f2 "say 2"
alias f3 "say 3"
alias f4 "say 4"
alias f5 "say 5"

alias +w "+forward;cycle"
alias -w "-forward;cycle"
alias +a "+moveleft;cycle"
alias -a "-moveleft;cycle"
alias +s "+back;cycle"
alias -s "-back;cycle"
alias +d "+moveright;cycle"
alias -d "-moveright;cycle"

bind o call
bind w +w
bind a +a
bind s +s
bind d +d

This script is assigning and resigning multiple alias values. When any of the WASD keys are pressed or released, the cycle command is ran, which moves the cycle command to the next value in the cycle and sets the "call" command to a value corresponding to the cycle number. This is based on the player's movement, and only changes values if the player is moving. It is possible to make this randomizer more effective by using other various techniques stated here (ex. Loops), but this example is for demonstration purposes only.

Timed action

Timed or held actions trigger when a button is pressed down for a certain amount of time. Timed actions can be used in situations where a script or command shouldn't be instantly ran the moment a button is pressed (ex. accidentally pressing a disconnect bind).

alias "+ti_zoom" "alias zoom_con zoomOn; wait 132; zoom_con"
alias "-ti_zoom" "zoomOff; alias zoom_con ; rb_tizoom-M4"
alias "rb_tizoom-M4" "unbind mouse4; wait 132; bind mouse4 +ti_zoom"
alias "zoomOn" "fov_desired 20; r_drawviewmodel 0"
alias "zoomOff" "fov_desired 90; r_drawviewmodel 1"
bind "mouse4" "+ti_zoom"

Pressing (and immediately releasing) Mouse 4 with this script loaded will have no noticeable effect, however holding down Mouse 4 for 2 seconds will cause the script to lower the FOV to 20, and hide viewmodels. Letting go of Mouse 4 at any point will undo these changes by setting the FOV to 90 and unhiding viewmodels.

This works because of the use of + and - aliases. Pressing the key +ti_zoom is bound to will redefine zoom_con to activate the script, and if left pressed for the wait duration will execute the script. However, if the button is released, zoom_con is redefined to do nothing. The key is then "disabled" by being unbound for the same wait duration, and rebound afterwards to restore use of the key.

Note: Rebinding of the key is technically redundant, as the script will not execute the timed action if the button is released. However, if the button is pressed multiple times it is possible to execute the timed action if the confirmation alias (in this case, zoom_con is properly defined as any of the presses would execute it. Unbinding the key for the same duration of the original wait delay ensures that the effect can't be triggered if the button is rapidly pressed.

Basic Conditionals

The basic conditional allows a script to change its behavior without running an entirely new script. By making use of a dummy alias it is possible to change the outcome of an input based on other inputs. Basic conditionals can support potentially infinitely many checks on the state of other commands, however it's unlikely that a script would need more than a few checks per conditional.

A very basic example of a conditional may look like:

alias "check_test" "alias test success; check1; check2; test"
alias "check1" ""
alias "check2" ""
alias "test" "success"

alias "fail_check" "alias test failure"

alias "success" "echo SUCCESS!"
alias "failure" "echo FAILURE!"

alias "+k_pressed" "alias check1 fail_check"
alias "-k_pressed" "alias check1"
alias "+j_pressed" "alias check2 fail_check"
alias "-j_pressed" "alias check2"

bind "l" "check_test"
bind "j" "+j_pressed"
bind "k" "+k_pressed"

The main function of this script is the check_test alias. When ran, this alias checks the other 2 conditionals, and if the checks succeed it runs the success alias. However, if one of the checks fails, the dummy alias test is pointed to run the failure alias. Simply put, when a check succeeds the checking command doesn't redirect the alias test is pointing to. If a check fails, it redirects the test alias to the alias storing the code to run when the check fails.

In this case, pressing the button L without pressing either J or K, the check succeeds and prints SUCCESS! to the console. When pressing and holding either J or K and then pressing L, the check will fail and print FAILURE! to the console.

A real world example of basic conditionals:

// Change the crosshair color when moving around

alias "+w_pressed" "+forward;   alias check_w pressed_w; chc_forward"
alias "+a_pressed" "+moveleft;  alias check_a pressed_a; chc_left"
alias "+s_pressed" "+back;      alias check_s pressed_s; chc_back"
alias "+d_pressed" "+moveright; alias check_d pressed_d; chc_right"

alias "-w_pressed" "-forward;   alias check_w; check_none"
alias "-a_pressed" "-moveleft;  alias check_a; check_none"
alias "-s_pressed" "-back;      alias check_s; check_none"
alias "-d_pressed" "-moveright; alias check_d; check_none"

alias "check_w" 
alias "check_a" 
alias "check_s" 
alias "check_d" 

alias "pressed_w" "dchk_fail; chc_forward"
alias "pressed_a" "dchk_fail; chc_left"
alias "pressed_s" "dchk_fail; chc_back"
alias "pressed_d" "dchk_fail; chc_right"

alias "check_none" "check_s; check_a; check_d; check_w; dmy_check"
alias "dmy_check" "chc_success"

alias "dchk_fail" "alias dmy_check chc_failure"
alias "dchk_reset" "alias dmy_check chc_success"

alias "chc_failure" "dchk_reset"
alias "chc_success" "chc_default"

alias "chc_default" "color0"
alias "chc_forward" "color1"
alias "chc_left"    "color2"
alias "chc_back"    "color3"
alias "chc_right"   "color4"

// Binds
bind "w" "+w_pressed"
bind "a" "+a_pressed"
bind "s" "+s_pressed"
bind "d" "+d_pressed"

// Colors
alias "color0" "cl_crosshair_red 0; cl_crosshair_green 255; cl_crosshair_blue 0"        // Default color when not moving
alias "color1" "cl_crosshair_red 0; cl_crosshair_green 0; cl_crosshair_blue 255"        // Color when moving forward
alias "color2" "cl_crosshair_red 255; cl_crosshair_green 0; cl_crosshair_blue 255"      // Color when moving left
alias "color3" "cl_crosshair_red 128; cl_crosshair_green 212; cl_crosshair_blue 255"    // Color when moving back
alias "color4" "cl_crosshair_red 255; cl_crosshair_green 140; cl_crosshair_blue 25"     // Color when moving right

This script will change the color of the user's crosshair as they walk around with the WASD keys. An important note this script takes advantage of is that when a check fails it can do several things instead of just changing the dummy command for testing. When a check fails the crosshair will change colors, and also change the dummy command to fail the check. This means when several buttons are released, the crosshair's color will properly change to the most recently pressed key.

Commenting

As scripts get longer, the need for well-named aliases grows. However, it is not always sufficient to explain what an alias does simply by its name. Adding a pair of forward slashes (//) will turn the rest of the line into a comment–it will not execute any actions on the text.

voicemenu 1 6 //Activate Charge!

Since it is not obviously clear what the voice command is, a comment can explain it.

Noteworthy scripts

There are several notable scripts that have affected gameplay. Some of these are patched out, while others remain functional.

Patched scripts

Pistol scripts

Originally, the Pistol could be fired almost as fast as the human hand could press a key. Scripts were created to simulate this rapid pressing by holding down a single key.

August 13, 2009 Patch: The Pistol now fires at a fixed rate, not based on the speed of pressing the fire button.

Chargin' Targe turn scripts

Originally, the keyboard commands to turn left and right were not treated the same as the mouse commands. The Chargin' Targe was the first weapon to create a restriction on how quickly a player could turn, therefore Valve put a limit on mouse turn-speed, yet forgot to apply the same restriction to the keyboard command that resulted in the same action. Scripts were created to rebind the turning controls when a player charged, circumventing this restriction.

June 23, 2011 Patch: Fixed an exploit with the Chargin' Targe that allowed greater turning control than intended.

Air crouching scripts

Originally, players could crouch as many times as they liked in a single jump. By binding a script to crouch and uncrouch as rapidly as possible, the engine could be exploited to make it difficult to properly register shots on jumping targets.

March 6, 2009 Patch: Players can now only duck twice in the air.

Idling Scripts

Most servers seek to prevent players idling for drops. Players can try to outsmart these systems with scripts that simulate basic movement.

An Active Solution to an Idle Threat requires players to accept a pop-up notification in order to continue to get drops.

Current Scripts

Weapon Viewmodel Hiding Scripts

There are a large number of scripts which toggle the weapon viewmodel depending on which weapon slot is selected for a class. Players often make their viewmodels invisible to clear up the screen, but make items like melee weapons, PDAs, watches, and so forth visible because these models indicate important information. For example, the Spy relies heavily on his viewmodel to determine when he is cloaked, when his Cloak is disturbed, and when the Dead Ringer activates. Other classes use the melee animations to judge when their attacks will hit.

Weapon Zoom Scripts

By changing your FOV, this script creates the visual effect of zooming in with whatever weapon the user is holding. It can usually be toggled between a zoomed and normal (unzoomed) version.

Sentry Jumping Scripts

Since the Engineer Update, Engineers have been able to pack up and carry their Sentry Guns. Simultaneously introduced in the update, the Wrangler allows Engineers to Sentry jump with their Sentry rockets. With extremely fast inputs, it was discovered that a player could Sentry jump and successfully pack up their Sentry before they were launched away.

While a human can repeat this feat, it is difficult. Some players made scripts which could reliably execute the commands in the right order at the right speed allowing them to make a Sentry jump while carrying their Sentry every time.

Note: The Rescue Ranger can circumvent this necessity, as it can pick up buildings at range for 100 metal.

Gunslinger Scripts

Since it can be troublesome to destroy then rebuild a Combat Mini-Sentry in the heat of battle through the PDA, some players have scripted the destruction and rebuilding of their Combat Mini-Sentry with the click of one or two buttons. Such a script is especially useful when using the Frontier Justice, as the player gains practically instant access to revenge Crits when needed.

Sensitivity and Control scripts

Some players prefer different mouse sensitivities and control schemes for some classes. For example, changing from the Medic, which doesn't require fine aiming, to the Sniper, which encourages high precision headshots, a player may wish to change their mouse sensitivity. These scripts alter control schemes and mouse settings on a per class, or even per weapon, basis.

Charge Dash Scripts

Since timing a charge and jump can be difficult, some players may use a quick script that binds the two actions to a button so that the charge dash will cover the maximum amount of distance possible. The player is still required to swing their melee weapon normally to end the charge though.

Quickscope Scripts

Many players find it difficult to scope in and fire straight after to get a quick headshot. There are scripts that will zoom in and fire just by clicking one button. This does require players to aim outside of the scope, though.

Rocket Jump Scripts

In order to Rocket Jump to a maximum height or distance, it is required that the player jumps, crouches, and fires their rocket at roughly the same time. This can be easily scripted to occur with the press of a button.

Auto-Disguise Scripts

For Spies who find manually disguising to be a hassle, this script automatically disguises as a chosen class after the player attacks with any weapon. Auto-disguise can usually be toggled and customized to choose a disguise to use.

ÜberCharge Broadcasting Scripts

With this script, activating ÜberCharge as Medic will also write a custom message in team chat to alert your teammates about your activation, in order to encourage your team to push ahead with you. A similar script, upon activation, plays the "ÜberCharge Ready" voice command while writing in team chat that you faked your Über to fool the enemy team.

Medic Radar

This script only works for Medic, as it lets you press a button to temporarily set the autocall percentage to a very high number. This makes it so that you can see the locations of nearby teammates. Script:

alias "autocall_default" "hud_medicautocallersthreshold 75.730003/Custom Threshold"
alias "autocall_all" "hud_medicautocallersthreshold 150"
alias "+radar" "autocall_all"
alias "-radar" "autocall_default"
bind [KEY] "+radar

Kill-Bind Scripts

Main article: Suicide

In certain circumstances, such as when cornered by a Medic wielding the Ubersaw, it can be beneficial for a class to be able to kill themselves quickly (in this case, to deny the Medic Über) with a key bind (for example, bind k kill). Although mostly only relevant in competitive play, there are occasional uses in public servers, often for comedic effect instead of to benefit gameplay. The killbind can be set to explode you if you use explode instead (for example, bind k explode). There is no difference between these two mechanically.

Null-Cancelling Movement Scripts

In stock TF2, pressing two opposing movement keys at once (such as "A" (+moveleft) and "D" (+moveright)) will cancel all movement and render the player immobile, which can be a fatal mistake during battle. This script makes it so that the direction of the last key pressed will be used instead. For example, pressing "A" will make the player go left, and pressing "D" while still holding "A" will make the player go right instead of stopping.

Chat Bind Scripts

Chat bind scripts are designed to post a pre-written message in the in-game text chat. Typically, users will bind these scripts to a key on their keyboard for easy repetition. These scripts can vary from user-to-user, and can say anything within the text limit, depending on what a player would want to say. Some common binds are used for team co-ordination, such as a bind to tell a team that their Medic has popped an ÜberCharge. Other common binds are used for banter, such as messages upon kills and/or dominations. Another variation on this is a trade offer bind, where it sends information to the chat about a possible trade offer. This type of script can also be automated to send these offers every couple of minutes.

Voice Toggle

This script enables you to voice toggle, instead of push-to-talk. Script:

bind [KEY] mic_toggle
alias mic_toggle mic_enable
alias mic_enable "+voicerecord; alias mic_toggle mic_disable"
alias mic_disable "-voicerecord; alias mic_toggle mic_enable"

Notes

  • Each config file is limited to one mebibyte (1.04858 megabytes) of information, though this restriction can be circumvented by exec-ing another config file at the end of the first.

See also

External links