Scripting is the use of configuration files (
.cfg) to create new keybinds and aliases automating complex behaviors and console command sequences. Unlike hacking, scripting is built into Team Fortress 2 and is not banned by VAC (Valve Anti-Cheat). Uses of scripting vary from simply binding a key to a command to self-referential loops and nested aliases that redefine one another. Any functionality that can be created with scripting can also be accomplished without it, but scripting allows these functionalities to be used in the heat of battle.
- 1 Scripting Commands
- 2 Launch Options
- 3 List of key names
- 4 Useful commands
- 5 Advanced Scripting Techniques
- 6 Commenting
- 7 Noteworthy scripts
- 7.1 Patched scripts
- 7.2 Current Scripts
- 7.2.1 Weapon Viewmodel Hiding Scripts
- 7.2.2 Weapon Zoom Scripts
- 7.2.3 Sentry Jumping Scripts
- 7.2.4 Gunslinger Scripts
- 7.2.5 Sensitivity and Control scripts
- 7.2.6 Charge Dash Scripts
- 7.2.7 Quickscope Scripts
- 7.2.8 Rocket Jump Scripts
- 7.2.9 Auto-Disguise Scripts
- 7.2.10 ÜberCharge Broadcasting Scripts
- 7.2.11 Medic Radar
- 7.2.12 Kill-Bind Scripts
- 7.2.13 Null-Cancelling Movement Scripts
- 7.2.14 Chat Bind Scripts
- 8 Notes
- 9 See also
- 10 References
- 11 External links
The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly.
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 consceutive commands.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.
Binds come in two forms:
bind "e" "Voicemenu 0 0"
This bind will make the player call for a Medic when they press.
bind "w" "+forward"
This bind will make the player move forward while they haveheld down.
This command allows a setting to be toggled between two or more values.
toggle "sv_cheats" 0 1
This works identically to toggle, but binds it to a key.
bindtoggle o "sv_cheats" 0 1
- Note: If no value is specified, toggle and bindtoggle default to switching between 0 and 1.
For both Toggle and Bind toggle, ensure that the values given are outside the inverted commas. ("example" 0 1)
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.
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.
- Note: Alias names cannot contain spaces. They may contain underscores, numbers, and symbols. Alias names are case-sensitive.
alias Call_For_Medic "Voicemenu 0 0" bind "e" "Call_For_Medic"
This script functions the same with a simple bind, meaning that when the player presses, they will call for a Medic.
alias "+Diagonal" "+moveleft; +back" alias "-Diagonal" "-moveleft; -back" bind "z" "+Diagonal"
This script allows the player to move diagonally. Here, pressingwill cause the player to move diagonally backward and left.
- Warning: The following code will not work!
bind "z" "+moveleft; +back"
Although pressingwill cause the player to move backward and left, the game engine does not invert the +back command due to it being a second command, and releasing will not cause the player to stop backing up.
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.
This script will execute the player's autoexec script.
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.
This command will make the game wait a given number of frames before executing the next command.
- Note: The amount of real time this corresponds to depends on the server's tickrate.
- 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 66; echo To get to the other side!
This script will wait 66 frames (1 second on most servers) before printing the punchline.
In order to improve or otherwise change your gameplay experience, the following launch options can be used. To use them, right-click on Team Fortress 2 in the Steam Library and select "Properties". Then, select "Set Launch Options" and insert your desired commands (note that all launch options contain a "-" before the command, remember to include it):
Launch Option: -w # -h #
- Description: Replace the hashtag with the number of your desired resolution.
Launch Option: -high
- Description: This launch option tells your CPU to run the game in High Priority Mode.
- Warning: Use extreme care when using the high-priority mode, because a high-priority mode application can use nearly all available CPU time.
Launch Option 1: -noforcemaccel and Launch Option 2: -noforcemspd
- Description: Using both of these will remove all mouse acceleration, it's required if you want a guaranteed raw input, which is the best thing.
Launch Option: -novid
- Description: This removes the Valve launch-video shown when the game is started, which decreases loading times.
Launch Option: -dxlevel #
- Description: On Windows, replace the hashtag with either 80, 81, 90, 95 or 100. Note that a high value on lower-end hardware may lower frames-per-second, and vice versa. On Mac or Linux, 90 or 92 should be used. These launch options should be added to first launch, and then removed.
Launch Option 1: -windowed or -sw and Launch Option 2: -noborder
- Description: When used together, the game will run in a borderless window. This will increase the game's stability by letting you alt+tab the fastest at the cost of some performance and increased input lag.
List of key names
Hover over a key to see its scripting name.
|Mouse Button||Name of Keybind|
|Left Button Click (forward)||MOUSE4|
|Right Button Click (back)||MOUSE5|
disguise command takes two arguments, the first being the class and the second being the team.
- 1. Scout
- 2. Sniper
- 3. Soldier
- 4. Demoman
- 5. Medic
- 6. Heavy
- 7. Pyro
- 8. Spy
- 9. Engineer
- 1. BLU team
- 2. RED team
- -1. Opposite team
- -2. Same team
disguise 5 1 would disguise as a BLU Medic and
disguise 7 -2 would disguise as a friendly Pyro.
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 3will disguise the Spy as a RED Scout, but
disguise 8 3will not undisguise a RED Spy.
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.
build command will pull up the blueprint to place a building, with an exception of the Sapper, which is wielded.
build 0 0will build a Dispenser (Engineer only)
build 1 0will build a teleporter entrance (Engineer only)
build 1 1will build a teleporter exit (Engineer only)
build 2 0will build a Sentry Gun (Engineer only)
build 3 0will build a Sapper (Spy only)
destroy command will destroy buildings.
destroy 0 0will destroy a Dispenser (Engineer only)
destroy 1 0will destroy a teleporter entrance (Engineer only)
destroy 1 1will destroy a teleporter exit (Engineer only)
destroy 2 0will 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 0will build a Dispenser (Engineer only)
build 1will build a teleporter entrance (Engineer only)
build 2will build a Sentry Gun (Engineer only)
build 3will build a teleporter exit (Engineer only)
build 3will build a Sapper (Spy only) [deprecated]
voicemenu command takes two arguments, the menu number and the command number.
- 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!
- 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!
- 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
eureka_teleport can teleport an Engineer holding the Eureka Effect to their spawn or teleporter exit.
eureka_teleport 0will teleport the player to their spawn
eureka_teleport 1will teleport the player to their teleporter exit
The player will see "Unknown command" in their console even though the command works.
clearwill clear the console of any information.
aliaswill list all currently defined aliases.
fov_desired (75-90)will set the field of view.
viewmodel_fovwill 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.
lastdisguisewill 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.
+tauntwill open the player's taunt loadout.
+use_action_slot_itemwill 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.
Advanced Scripting Techniques
It is possible to bind a key to toggle a command which would otherwise be a press and hold command.
bind w toggle alias toggle "enable" alias enable "alias toggle disable; +forward" alias disable "alias toggle enable; -forward"
This script will cause a press ofto keep the player moving forward until is pressed again.
It is possible to create a script where pressing one button while another is held down will change the action of the first button.
bind e call alias call Call_For_Medic alias Call_For_Medic "Voicemenu 0 0" alias Call_For_Ubercharge "Voicemenu 1 6"
At this point, the script will mean that every time Ubercharge.is pressed, the player will call for a Medic. It also has an unused alias to call for an
bind shift +toggleState alias +toggleState "alias call Call_For_Ubercharge" alias -toggleState "alias call Call_For_Medic"
call to ask for an ubercharge. Releasing will make
call point back at a Medic call.
When + is pressed, the player will call for an Ubercharge, rather than for a Medic.
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; 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
- 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 onceis 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 would cause the next iteration of the loop to stop, also stopping the firing.
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.
A cycle is toggle script where there are a minimum of 3 possible options, which loop (ex, 1, 2, 3, 1). Example:
alias "Fov_Cycle" "Fov1" alias "Fov1" "alias Fov_Cycle Fov2; fov_desired 70" alias "Fov2" "alias Fov_Cycle Fov3; fov_desired 80" alias "Fov3" "alias Fov_Cycle Fov1; fov_desired 90" bind "o" "Fov_Cycle"
This script makes it so pressing thekey, FOV values switch between 70, 80, and 90.
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" "addcond 49" alias "Cond1" "alias CondC_UP Cond 2; alias CondC_DOWN Cond5; alias ApplyCond addcond 49" alias "Cond2" "alias CondC_UP Cond 3; alias CondC_DOWN Cond1; alias ApplyCond addcond 33" alias "Cond3" "alias CondC_UP Cond 4; alias CondC_DOWN Cond2; alias ApplyCond addcond 72" alias "Cond4" "alias CondC_UP Cond 5; alias CondC_DOWN Cond3; alias ApplyCond addcond 74" alias "Cond5" "alias CondC_UP Cond 1; alias CondC_DOWN Cond4; alias ApplyCond addcond 90"
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 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 are 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 thekeys are pressed, 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.
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.
There are several notable scripts that have affected gameplay. Some of these are patched out, while others remain functional.
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.
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.
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.
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.
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.
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.
This script only works for Medic as it basically lets you press a button to temporarily set the autocall percentage to a very high number, making it so you see teammates locations.
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, sometimes for comedic effect instead of to benefit gameplay.
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 repitition. 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.
- 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.
- List of useful console commands
- List of TF2 console commands and variables on the Valve Developer Community