Difference between revisions of "Scripting"

From Team Fortress Wiki
Jump to: navigation, search
m (Advanced Scripting Techniques)
m (Advanced Launch Options)
(48 intermediate revisions by 19 users not shown)
Line 1: Line 1:
'''Scripting''' is the use of configuration files ({{code|.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.  
+
{{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}}) mainly 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.  
  
==Scripting Commands==
+
== Scripting Commands ==
 
The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly.
 
The following is a list of commands which have no use apart from scripting; they do not influence gameplay directly.
===Bind===
+
 
 +
=== 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.
 
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.
  
Line 10: Line 12:
  
 
<pre>bind [KEY] "[COMMAND 1];[COMMAND 2];[COMMAND 3]"</pre>
 
<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 consceutive commands.
+
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 <pre>say "Example Text"</pre> is correct, but <pre>bind <KEY> "say "Example Text""</pre> is not. This is because the quotes are misinterpreted, and quotes inside of quotes are unnecessary due to commands automatically stopping at every semicolon.
 
''Note:'' The command <pre>say "Example Text"</pre> is correct, but <pre>bind <KEY> "say "Example Text""</pre> 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:
 
Binds come in two forms:
<pre>bind "e" "Voicemenu 0 0"</pre>
+
<pre>bind e "voicemenu 0 0"</pre>
 
This bind will make the player call for a Medic when they press {{key|E}}.
 
This bind will make the player call for a Medic when they press {{key|E}}.
  
<pre>bind "w" "+forward"</pre>
+
<pre>bind w +forward</pre>
 
This bind will make the player move forward while they have {{key|W}} held down.
 
This bind will make the player move forward while they have {{key|W}} held down.
  
===Toggle===
+
=== Toggle ===
 
This command allows a setting to be toggled between two or more values.
 
This command allows a setting to be toggled between two or more values.
  
<pre>toggle "sv_cheats 0 1"</pre>
+
<pre>toggle sv_cheats 0 1</pre>
  
===Bindtoggle===
+
=== Bindtoggle ===
 
This works identically to toggle, but binds it to a key.
 
This works identically to toggle, but binds it to a key.
  
<pre>bindtoggle o "sv_cheats 0 1"</pre>
+
<pre>bindtoggle o sv_cheats 0 1</pre>
 
:''Note:'' If no value is specified, toggle and bindtoggle default to switching between 0 and 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)
  
===Incrementvar===
+
=== Incrementvar ===
 
This allows for variables to be increased or decreased repeatedly by a set amount.
 
This allows for variables to be increased or decreased repeatedly by a set amount.
  
Line 41: Line 43:
 
:''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.
 
:''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===
+
=== 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.
 
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.
 
:''Note:'' Alias names cannot contain spaces. They may contain underscores, numbers, and symbols. Alias names are case-sensitive.
Line 48: Line 50:
 
bind "e" "Call_For_Medic"</pre>
 
bind "e" "Call_For_Medic"</pre>
 
This script functions the same with a simple bind, meaning that when the player presses {{key|E}}, they will call for a Medic.
 
This script functions the same with a simple bind, meaning that when the player presses {{key|E}}, they will call for a Medic.
 +
 +
:''Note:'' An alias can have a + symbol in front of it (e.g. +Diagonal), it will execute the - version afterwards (e.g. -Diagonal). This can be useful for movement binds.
  
 
<pre>alias "+Diagonal" "+moveleft; +back"
 
<pre>alias "+Diagonal" "+moveleft; +back"
Line 63: Line 67:
 
<pre>exec autoexec.cfg</pre>
 
<pre>exec autoexec.cfg</pre>
 
This script will execute the player's autoexec script.
 
This script will execute the player's autoexec script.
===Echo===
+
 
 +
=== Echo ===
 
This command will cause text to be printed to the console. This is very useful for debugging.
 
This command will cause text to be printed to the console. This is very useful for debugging.
  
Line 74: Line 79:
 
:''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.
 
:''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===
+
=== Wait ===
 
This command will make the game wait a given number of frames before executing the next command.
 
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.
 
:''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|Wait Testing]] for help to protect against this.'''
 
:'''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.'''
  
<pre>echo Why did the chicken cross the road?; wait 66; echo To get to the other side!</pre>
+
<pre>echo Why did the chicken cross the road?;wait 66;echo To get to the other side!</pre>
This script will wait 66 frames (1 second on most servers) before printing the punchline.
+
This script will wait 66 ticks (1 second on most servers) 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.
 +
<pre>
 +
scout.cfg
 +
soldier.cfg
 +
pyro.cfg
 +
demoman.cfg
 +
heavy.cfg
 +
engineer.cfg
 +
medic.cfg
 +
sniper.cfg
 +
spy.cfg
 +
</pre>
 +
This automation lets the player have different keybinds and game settings for each class.
 +
 
 +
== Launch Options ==
 +
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 Options==
 
In order to improve or otherwise change your game-play 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):
 
  
===High===
+
== Set Launch Options ==
 +
[[File:Setting Launch Options.png|thumb|none|A visual guide on how to set launch options (indicated by the green areas).]]
 +
# 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.
 +
 
 +
== Common Launch Options ==
 +
{| class="wikitable grid"
 +
    ! class="header" style="text-align:center" | Option
 +
    ! class="header" style="text-align:center" | Value
 +
    ! class="header" style="text-align:center" | Description
 +
    |-
 +
    | -autoconfig || N/A || Restores video and performance settings to default for the current hardware detected. Ignores settings inside any .cfg files until this parameter is removed
 +
    |-
 +
    | -dxlevel || 80, 81, 90, 95 || Forces a specific DirectX version when launching the game. This is useful if your graphics hardware is older, and gets significantly better performance in an earlier version of DirectX
 +
    |-
 +
    | -fullscreen || N/A || Forces the engine to start in fullscreen mode
 +
    |-
 +
    | -windowed || N/A || Forces the engine to start in windowed mode
 +
    |-
 +
    | -w || <width> || Forces the engine to start with resolution set to <width>
 +
    |-
 +
    | -h || <height> || Forces the engine to start with resolution set to <height>. This launch option does not need to be set in the presence of -w. The width value will determine the height automatically
 +
    |-
 +
    | -refresh || <rate> || Force a specific refresh rate
 +
    |-
 +
    | -novid || N/A || Skips the valve intro video
 +
    |-
 +
    | -sillygibs || N/A || Enables low violence mode
 +
|}
 +
 
 +
== Launch Options to Adjust Detail Levels and Graphic Rendering ==
 +
{| class="wikitable grid"
 +
    ! class="header" | Option
 +
    ! class="header" | Value
 +
    ! class="header" | Description
 +
    |-
 +
    | +r_rootlod || # || Adjusts Model Detail where # is 0 for high, 1 is medium, and 2 for low
 +
    |-
 +
    | +mat_picmip || # || Adjusts Texture Detail where # is 0 for high, 1 is medium, and 2 for low
 +
    |-
 +
    | +mat_reducefillrate || # || Adjusts Shader Detail where # is 0 for high and 1 for low
 +
    |-
 +
    | +r_waterforceexpensive || # || Adjusts Water Detail where # is 0 for low and 1 for high
 +
    |-
 +
    | +r_waterforcereflectentities || # || Adjusts Water Reflectiveness where # is 0 for low and 1 for high
 +
    |-
 +
    | +r_shadowrendertotexture || # || Adjusts Shadow Detail where # is 0 for low and 1 for high
 +
    |-
 +
    | +mat_colorcorrection || # || Adjusts Color Correction where # is 0 for low and 1 for high
 +
    |-
 +
    | +mat_trilinear || # || Use Bilinear Mode (least system-intensive, # = 0) / Use Trilinear Mode (more system-intensive, # = 1)
 +
    |-
 +
    | +mat_forceaniso || # || Use Trilinear Mode (where # is 2, 4, 8, or 16 - higher levels of filtering require more system resources)
 +
    |-
 +
    | +mat_hdr_level || # || Adjusts High Dynamic Range lighting effects where # is 0 for "off" (requires least resources) and 2 for "full"
 +
|}
 +
 
 +
== Advanced Launch Options ==
 +
* -all_languages - Loads all language files
 +
* -autoconfig - Restores video and performance settings to default for the current hardware detected. Ignores settings inside any .cfg files until this parameter is removed
 +
* -32bit - Forces the engine to start in 32-bit mode. Only useful on 64-bit Operating Systems.
 +
* -adapter - Sets the GL graphics adapter. Default is 0.
 +
* -allowdebug - Fakes a debugger for phonehome, and is the same as -dev, unless -nodev is specified.
 +
* -allowstalezip - Suppresses console warnings from stale.txt existing.
 +
* -basedir - Sets the base directory for the game files. On Xbox 360 RFS, this is forced to smb://hostname/game.
 +
* -bi - Defines the build identifier ID which is used in phonehome
 +
* -bugbait - This lets IsLoadingBugBaitReport return true.
 +
* -bugreporterdll - Name of the bug reporter DLL to use
 +
* -buildcubemaps - Builds cubemaps when fully loaded into a map, then quits the game.
 +
* -ccsyntax - Spew details about the localized strings we load.
 +
* -clientport - Sets the client port. Default is 27002.
 +
* -collate - Skips everything, just merges the reslist from temp folders to the final folder again.
 +
* -conclearlog - Clears the console.log text file on start. Only works if -condebug set.
 +
* -condebug - Logs all console output into the console.log text file.
 +
* -console - Starts the game with the developer console enabled. Same as having con_enable enabled.
 +
* -deathsonly - Supposed to only count deaths while parsing TF2 gamestats, but actually pointless because there is only code for deaths.
 +
* -defaultgamedir - Fallback directory if "-game" is not set. Default is "hl2".
 +
* -dev - Enables developer mode. Also disables the automatic loading of menu background maps and stops the quit dialog from appearing on exit.
 +
* -debugdxsupport - Writes debug DirectX information as keyvalues to the console as shader devices are loading configuration.
 +
* -disallowhwmorph - Same as mat_disablehwmorph 1. Disables HW morphing for particular mods.
 +
* -dti - Prints the datatable when being sent
 +
* -dumpvidmemstats - Spews video memory statistics to vidmemstats.txt. This forces CModelLoader to quit.
 +
* -dvd - Enables strict DVD mode. Allows loading files from DVD only. Xbox 360 only.
 +
* -dvddev - Enables developer DVD mode. Allows loading files from a remote path as a fallback as well as the DVD. Xbox 360 only.
 +
* -dxlevel <level> - Forces the game to start using specified DirectX API version. Officially supported values are: 60, 70, 80, 81, 90, 91, 95 (recommended), 98 (Xbox 360 only), and 100. After starting the game with this launch parameter, the selected value will be saved for future start ups and video settings will be temporarily reset (but not saved), so it is highly recommended to remove this launch parameter after first launch with it. See mat_dxlevel.
 +
* -edit - According to comments, intended to replace -tools. Does nothing except disable all file logging for building reslists.
 +
* -endgamevid - If specified startup videos will not be skipped, and EndGameVids.txt will be used instead of StartupVids.txt. This can also be invoked by the command "startupmenu playendgamevid", which bails back to the menu and plays the end game video.
 +
* -exit - Quits the game after fully loading into a map.
 +
* -filmgrain - Enables the filmgrain screen space effect.
 +
* -flushlog - Causes log files to be flushed to disk once per second (rather than after every 4kbytes of log data).
 +
* -floathdr - Forces HDR to use float values.
 +
* -forcenovsync - Forces vsync to be disabled.
 +
* -forcestartupmenu - Forces the background menu map to always load, even if developer mode is active or the game is loading straight to a level.
 +
* -forcexboxreconfig - Forces default config settings to be loaded on Xbox 360.
 +
* -forever - When you get to the end of the maplist, start over from the top
 +
* -fs_log - Starts creating a batch file to copy files at the specified filename. This works on the latest engine branch.
 +
* -fs_logbins - Logs binaries to the batch file from -fs_log.
 +
* -fs_nopreloaddata - Loads in the precompiled keyvalues data for each type. Works only with dedicated servers.
 +
* -fs_target - Sets the target game directory to copy files to, used with -fs_log.
 +
* -full_memory_dumps -
 +
* -fullscreen or -full - Forces the engine to start in fullscreen mode.
 +
* -g15 - Enables Logitech G15 support. G15 is only supported in SiN Episodes: Emergence. [confirm]
 +
* -game - Sets game or mod directory to load the game from. Usually is set by default if not user specified. Default is "-defaultgamedir"'s setting. If -defaultgamedir is not set, "hl2" is used.
 +
* -gamestatslogging - Enables game stats logging.
 +
* -gamestatsloggingtofile - Enables game stats logging out to a file, gamestats.log. Passing this parameter automatically forces -gamestatslogging.
 +
* -gl_enablesamplerobjects - (Linux) Use OpenGL Sampler Objects for better texture preloading
 +
* -gl_texclientstorage - (MacOS) Reduce memory usage by relying on GPU memory instead of a host copy
 +
* -gamestatstag <tag> - Tags each map reported with the specified tag.
 +
* -h <height> - Forces the engine to start with resolution set to <height>. Ex: -h 768
 +
* -height <height> - Same as -h
 +
* -heapcheck - (Windows only) Check if the heap isent damaged or empty at the initiation of the game and every frame
 +
* -heapsize <kilobytes> - Specifies the heapsize (in kilobyte) the game will use. This no longer exists on the Source 2009.
 +
* -hideconsole - Forces the console to be hidden, whatever parameters are passed. This overrides -console, -dev, and all others.
 +
* -high - Sets the game's priority to High
 +
* -hijack - Take control of an existing instance of the game, if any, instead of complaining about already running.
 +
* -host - Sets hostname. On Xbox 360, this sets the host computer name to be used for RFS. Xbox name must be <HostPC>_360.
 +
* -hushasserts - Disables a number of asserts in core Source libraries, skipping some error checks and messages.
 +
* -hushsteam - For security. Prevents local game servers from registering their IP with Steam.
 +
* -ignoredxsupportcfg - Skips reading DirectX support file, dxsupport.cfg.
 +
* -insecure - Disable Valve Anti Cheat (VAC).
 +
* -internalbuild - Causes the bug reporter panel to be drawn as internal
 +
* -ip - Does the same as the ipname Cvar
 +
* -language %l - Sets the game language to the one specified. (Examples: "english", "german").
 +
* -leakcheck - Dumps statistics about memory leaks.
 +
* -limitvsconst - Limits the number of vertex shaders to a maximum of 256.
 +
* -localcser - Sets a custom gamestats CSER other than the Steam-provided public one (default is steambeta1:27013)
 +
* -low - Sets the game's priority to Low
 +
* -lowmemworkshop - Allow updating very large map files on Steam Workshop. (Supposedly added and fixed in the {{patch name|6|22|2021}} but unknown if compatible)
 +
* -makedevshots - Used for taking screenshots, causing entities to not fade. Enables the use of the devshots_nextmap concommand
 +
* -makereslists - Makes reslists. Need to run with -textmode. Passing a parameter here uses a script file to control more complex makereslists operations (multiple passes, etc.)
 +
* -mat_aaquality - Set MSAA quality level, does the same as the Convar mat_aaquality
 +
* -mat_antialias - Antialiasing. Can be set to 8, amount past 8 won't sharpen the edges of game world.
 +
* -mat_vsync - Enables Vertical Sync
 +
* -mat_softwaretl - Enables software vertex processing.
 +
* -maxdxlevel - Limits the maximum dxlevel to use. Default is 0.
 +
* -maxdownloadfilesizemb - client launch option -maxdownloadfilesizemb N if clients needs to download even larger files from community servers.
 +
* -maxplayers - Set the maximum players allowed to join the server. This does the same as the maxplayers convar, the maximum you can set it to is limited by the game/mod
 +
* -minmemory - Set startup memory to mem_min_heapsize ?*1024 * 1024?
 +
* -monitorTextureSize - Set the size of the texture used to render point_cameras.
 +
* -multirun (only in <Source><Source>) - Allows the game to run even if another Source game is already open.
 +
* Note.png Note:  - While only implemented in Source 2013, using this while a non-2013 game is already running will work.
 +
* -navanalyze - related to navmeshes (unknown)
 +
* -navforceanalyze - related to navmeshes (unknown)
 +
* -netspike - Sets the trace threshold to the specified value (the limit of the number of records that will be written to netspike.txt before all records are removed).
 +
* -newdialogs - Forces new Steam dialog to be used.
 +
* -no_compressed_verts - Disables vertex compression for shaders.
 +
* -no_compressed_vvds - Enables thin VVD data, even if the client is not an Xbox 360.
 +
* -noassert - Allows attaching to a debugger instead of directly asserting.
 +
* -noasync - Disables asynchronous filesystem access.
 +
* -noborder - When used with the game set to windowed mode, will make the game act as if in fullscreen mode (no window border).
 +
* -nobots - Allows Counter-Strike server hosts to force bots disabled to enforce CPU limits. (may be TF2 compatible)
 +
* -nobreakpad - unknown
 +
* -noconvert - (xbox360) "No conversions during retail"
 +
* -noclearsave - Skips clearing the save directory after restoring a save.
 +
* -nocrashdialog - Stop some windows crash message boxes from showing up.
 +
* -nodev - Disables -dev and -allowdebug during startup so sv_cheats and developer mode dosent get set.
 +
* -nodns - Disable DNS requests and resolving DNS adresses.
 +
* -nodttest - Skips datatable testing.
 +
* -noff - Disables force feedback for controllers.
 +
* -noforcemaccel - Use the Windows mouse acceleration settings. Only works if -useforcedmparms is set.
 +
* -noforcemspd - Use the Windows mouse speed settings. Only works if -useforcedmparms is set.
 +
* -nogamedll - Do not load the Game DLL, this most likely will cause your game/server to crash
 +
* -nogamestats - related to game stats (unknown)
 +
* -nohltv - Disable SourceTV
 +
* -noip - Do not bind to an ip and disables all multiplayer support
 +
* -nojoy - Disables joystick support.
 +
* -NoLoadPluginsForClient - Disables plugins for client-side
 +
* -nomaster - Hides server from master serverlist.
 +
* -nomessagebox - Stop various windows error message boxes from showing up
 +
* -nominidumps - Dont write minidumps
 +
* -nomouse - Disables in-game mouse support.
 +
* -nop4 - Forces the Engine to bypass Perforce Integration
 +
* -nopreload - Forces models to not be preloaded. Takes priority over cl_forcepreload and -preload.
 +
* -nopreloadmodels - Same as -nopreload
 +
* -nops2b - Disables Pixel Shader 2b support.
 +
* -noqueuedload - Disables queued loading of map resources.
 +
* -NoQueuedPacketThread - (Linux) No queued packet thread will be created.
 +
* -norebuildaudio - Opposite of and overrides -rebuildaudio for the map reslist generator.
 +
* -nodefaultmap - (Linux only[confirm]) Supresses the addition of -map
 +
* -norfs - Forces Remote Filesystem disabled. Xbox 360 only.
 +
* -noshaderapi - Loads a non-existent shader API dll, shaderapiempty.dll. Effectively disables shader and texture loading completely. May be useful with -textmode to load the game quickly since a GUI is not required.
 +
* -nosound - Disables sound support
 +
* -nosrgb - Disables support for SRGB.
 +
* -nostartupsound - Disables menu music (sound/ui/gamestartup*.mp3) to play on startup.
 +
* -nosteamcontroller - Disables Steam controller system
 +
* -nouserclip - Uses software clipping instead of hardware user clip planes
 +
* -NoVConfig - Prevents the filesystem library from running VConfig if it encounters a filesystem error where it cannot find the game content.
 +
* -novid - When loading a game with this parameter, the intro video will not play.
 +
* -olddialogs - Forces old Windows dialogs instead of new Steam ones.
 +
* -override_vpk - Forces actual files to override VPK.
 +
* -particles - Sets the number of beam trails to allow (2048 by default, minimum is 512).
 +
* -phonehome - If debug mode is also enabled, forces the init of phonehome ?which handles some build information and sends them via netmessages to steam?
 +
* -pidfile <pidfile> - Use the specified <pidfile> to store the server pid. Default is srcds.pid[confirm] (Unix/Linux only).
 +
* -pixel_offset_x - Sets the pixel offset to translate on the X axis in MatSystemSurface.
 +
* -pixel_offset_y - Sets the pixel offset to translate on the Y axis in MatSystemSurface.
 +
* -pme - Activate the performance monitoring events code, this again only works on Intel processors newer then PENTIUM4
 +
* -port <variable> - Sets port for a listen server. Default is 27015.
 +
* -preload - Does the same as the sv_forcepreload Cvar. If -nopreload or -nopreloadmodels, this behaviour is disabled
 +
* -primarysound - If surround sound isn't enabled, forces the use of the primary sound buffer
 +
* -profile - If using Xbox360 or enabling this, additional debugging information are logged like the map startup time and similar
 +
* -publicbuild - Is this build a public one? If not, phonehome will not post information of this build to steam
 +
* -random_invariant - Forces the game's random number generator value to be invariant.
 +
* -rebuildaudio - Forces rebuild of _other_rebuild.cache (metacache) file at exit for the map reslist generator.
 +
* -recapvid - RecapVids.txt will be used instead of EndGameVids.txt. This can also be invoked by the command "startupmenu playrecapvid", which bails to the mainmenu and plays the recap video.
 +
* -ref - Sets MATERIAL_INIT_REFERENCE_RASTERIZER on the shader material adapter.
 +
* -remote - Sets the remote file path to be used with -dvddev.
 +
* -replay - Increases maxplayers by 1 at startup and automatically executes replay.cfg for the server.
 +
* -requirecubemaps - If a map dosen't have cubemaps, the game will promt up with "Map X does not have cubemaps!"
 +
* -reflectionTextureSize - Set the size of the texture used to render the Water shader's real-time reflection and refraction.
 +
* -refresh <rate> - Force a specific refresh rate. Ex: -refresh 60
 +
* -refreshrate <rate> - Same as -refresh
 +
* -freq <rate> - Same as -refresh
 +
* -r_emulate_gl - Emulates OpenGL on Windows, provides a framerate boost for most GPUs
 +
* -resizing - Allows resizing the window lower than a specific resolution.
 +
* -reslistdir - Default is "reslists", use this to override. Reslist generator only.
 +
* -reuse - Reuse network sockets
 +
* -rpt - Same as having -condebug, -conclearlog, and -console enabled
 +
* -safe - Enables video safe mode, which sets the game to windowed, the width to 640, the height to 480, refresh rate to default, and disables antialiasing.
 +
* -shader - Loads a specific shader library instead of depending on hardware. Debug only.
 +
* -shaderdll - Loads a different shader dll. Default is shaderapidx9.dll. To do: Is this the same as -shader?
 +
* -shadersondemand - Creates shaders on access, helps reduce D3D memory for tools, but causes I/O hitches.
 +
* -sillygibs - Forces pyroland-esqe gibs
 +
* -small - Allow window sizing smaller then 640x480
 +
* -sndcachedebug - Prints sound cache debug messages (developer must be enabled to see)
 +
* -snoforceformat - Skips sound buffer creation
 +
* -soft - Enables Software hardware rendering mode.
 +
* -softparticlesdefaultoff - Sets particles to be rendered without feathering (scene depth blending) by default.
 +
* -softparticlesdefaulton - Opposite of -softparticlesdefaultoff.
 +
* -spewsentences - Spew out vox sentence names during reslist generation
 +
* -startmap - Restarts devshot generation at the specified map if resuming from a crash.
 +
* -startstage - When running from script file, this starts at specified stage, and sets current work item (default is 0). Reslist generator only.
 +
* -steam - Enables Steam support (if the game is launched from Steam, this is enabled by default). Working directory must be Steam directory. Works only for singleplayer games.
 +
* -steamlocal - Similar to -steam. Runs Steam in local filesystem mode (all content off HDD), as opposed to remote filesystem mode (requiring Steam backend).
 +
* -steamport - Master server updater port. Steam authentication port is this port + 1. (default is 26900)
 +
* -strictportbind - If you launch the game with this option it will quit with an error message if it can't bind to the default or specified port.
 +
* -sv_benchmark - Enables benchmarking through sv_benchmark_force_start.
 +
* -swapcores - Swaps threads for the particle and material systems each init
 +
* -tempcontent - Searches for game content in a folder called "_tempcontent" relative to the absolute game path. This option is enabled by default for Portal 1
 +
* -testscript <filename> - Loads a .vtest file.
 +
* -testshaders - Loads the shader_test library. Debug only.
 +
* -testsub - does nothing
 +
* -textmessagedebug - Spews client text messages to console.
 +
* -textmode - Runs the game without graphics
 +
* -threads - Number of threads to allocate for the thread pool, default is 3
 +
* -tickrate - Sets the game tick interval. Disabled in code for TF2 because "server ops are abusing it".
 +
* -timedemoloop - unknown
 +
* -toconsole - Starts the engine directly in the console, unless a map is specified with +map.
 +
* -tools - Enables engine tools.
 +
* -trackdeletions - Logs what files are marked for deletion in Reslist Generator.
 +
* -tvmasteronly - Only one person allowed in HLTV.
 +
* -usedevshotsfile - Get map list from specified file, default is to build for maps/*.bsp
 +
* -useforcedmparms - Allows the use of -noforcemspd and -noforcemaccel.
 +
* -usegh - Loads ghostinj.dll to allow support for third party dlls (gamehost)
 +
* -uselogdir - Logs various data to logs/(mapname)/*
 +
* -usercon - Enable RCON for Counter-Strike: Global Offensive servers (may work in TF2)
 +
* -usereslistfile - Get map list from specified file, default is to build for maps/*.bsp. Reslist generator only.
 +
* -usetcp - Disable TCP support
 +
* -vcrplayback - Plays back a VCR recording. Nothing is simulated on the server, but all server packets are recorded.
 +
* -vcrrecord - Records a client's game and allows you to play it back and reproduce it exactly. To do: how is this different from a demo?
 +
* -vguifocus - Enables debug VGUI messages related to input focus.
 +
* -vguimessages - Enables debug VGUI messages.
 +
* -vxconsole - Waits for Valve Xbox console to initialise. Xbox 360 only.
 +
* -vproject - Manually sets the VProject directory to load game content for tools.
 +
* -w <width> - Forces the engine to start with resolution set to <width>. Ex: -w 1024
 +
* -width <width> - Same as -w
 +
* -wavonly - Disables DirectSound and makes the engine attempt to play all sounds in PCM format.
 +
* -window - Forces the engine to start in windowed mode
 +
* -sw - Same as -window
 +
* -startwindowed - Same as -window
 +
* -windowed - Same as -window
 +
* -xnet_bypass_security - Disables Xbox 360 secure networking, to allow cross-platform testing.
 +
* -x <x position> - In borderless windowed mode, determines where the window should be horizontally. Ex: -x 0
 +
* -y <y position> - In borderless windowed mode, determines where the window should be vertically. Ex: -y 0
 +
* +connect - Console Command
 +
* +load - Console Command
 +
* +mat_hdr_level - sets the hdr strength
 +
* +maxplayers - Console Command
 +
* +playdemo - Console Command
 +
* +port - Console Command
 +
* +timedemo - Console Command
 +
* +timedemoquit - Console Command
 +
 
 +
=== Resolution ===
 +
Launch Option: -w # -h #
 +
:''Description:'' Replace the hashtag with the number of your desired resolution.
 +
 
 +
=== High ===
 
Launch Option: -high
 
Launch Option: -high
 
:''Description:'' This launch option tells your CPU to run the game in High Priority Mode.
 
:''Description:'' This launch option tells your CPU to run the game in High Priority Mode.
 +
: [[File:Warning red.png|25px]] Warning: Use extreme care when using the high-priority mode, because a high-priority mode application can use nearly all available CPU time.<ref>https://docs.microsoft.com/nl-nl/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass</ref>
  
===Threads===
+
=== Mouse Acceleration ===
Launch Option: -threads #
 
:''Description:'' To use this launch option, replace the hashtag with the number of threads that your CPU has minus 4. It allows your CPU to run the game using multiple threads. This option isn't needed for a CPU with 4 cores or less.
 
 
 
===Mouse Acceleration===
 
 
Launch Option 1: -noforcemaccel and  
 
Launch Option 1: -noforcemaccel and  
 
Launch Option 2: -noforcemspd  
 
Launch Option 2: -noforcemspd  
:''Description:'' Using both of these will remove all mouse acceleration, which will improve aiming.
+
:''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 Video===
+
=== Launch Video ===
 
Launch Option: -novid
 
Launch Option: -novid
 
:''Description:'' This removes the Valve launch-video shown when the game is started, which decreases loading times.
 
:''Description:'' This removes the Valve launch-video shown when the game is started, which decreases loading times.
  
===Direct-X===
+
=== DirectX ===
 
Launch Option: -dxlevel #
 
Launch Option: -dxlevel #
:''Description:'' On Windows, replace the hashtag with either 80, 81, 90, 95 or 98. The larger the number, the better the graphics will be. 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.
+
:''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.
  
===Windowed Mode===
+
=== Windowed Mode ===
 
Launch Option 1: -windowed or -sw and  
 
Launch Option 1: -windowed or -sw and  
 
Launch Option 2: -noborder
 
Launch Option 2: -noborder
:''Description:'' When used together, the game will run in a borderless window. This will increase the game's stability.
+
:''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==
+
== List of key names ==
Hover over a key to see its scripting name.
+
Hover over a key to see its scripting name. Names are not case-sensitive.
 
{|
 
{|
 
! width="45%" <!-- Main Keyboard -->|
 
! width="45%" <!-- Main Keyboard -->|
Line 254: Line 560:
 
|}
 
|}
  
==Useful commands==
+
== Useful commands ==
{{Main|vdc:List_of_TF2_console_commands_and_variables|l1=List of TF2 console commands and variables}}
+
{{Main|vdc:List of TF2 console commands and variables|l1=List of TF2 console commands and variables}}
  
 
===Disguising===
 
===Disguising===
Line 280: Line 586:
 
:''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, but <code>disguise 8 3</code> will not undisguise a RED Spy.
 
:''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, but <code>disguise 8 3</code> will not undisguise a RED Spy.
  
===Buildings===
+
=== Buildings ===
 
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.
 
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.
  
Line 304: Line 610:
 
:<code>build 3</code> will build a Sapper <small>(Spy only) [deprecated]</small>
 
:<code>build 3</code> will build a Sapper <small>(Spy only) [deprecated]</small>
  
===Voice Menu===
+
=== Voice Menu ===
 
The <code>voicemenu</code> command takes two arguments, the menu number and the command number.  
 
The <code>voicemenu</code> command takes two arguments, the menu number and the command number.  
 
*<code>voicemenu 0</code>
 
*<code>voicemenu 0</code>
Line 338: Line 644:
 
:''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>.
 
:''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>.
  
===Eureka Teleport===
+
=== Eureka Teleport ===
 
The <code>eureka_teleport</code> can teleport an Engineer holding the [[Eureka Effect]] to their spawn or teleporter exit.
 
The <code>eureka_teleport</code> can teleport an Engineer holding the [[Eureka Effect]] to their spawn or teleporter exit.
 
*<code>eureka_teleport 0</code> will teleport the player to their spawn
 
*<code>eureka_teleport 0</code> will teleport the player to their spawn
Line 345: Line 651:
 
The player will see "Unknown command" in their [[console]] even though the command works.
 
The player will see "Unknown command" in their [[console]] even though the command works.
  
===Assorted===
+
=== Assorted ===
 
*<code>clear</code> will clear the console of any information.
 
*<code>clear</code> will clear the console of any information.
 
*<code>alias</code> will list all currently defined aliases.
 
*<code>alias</code> will list all currently defined aliases.
*<code>fov_desired (75-90)</code> will set the [[field of view]].
+
*<code>fov_desired (20-90)</code> will set the [[field of view]].
 
*<code>viewmodel_fov </code> will set the FOV for weapon models. It ranges by default from 54 to 70.
 
*<code>viewmodel_fov </code> will set the FOV for weapon models. It ranges by default from 54 to 70.
 
*<code>r_drawviewmodel (0/1)</code> will show (1) or hide (0) weapon models.
 
*<code>r_drawviewmodel (0/1)</code> will show (1) or hide (0) weapon models.
 
*<code>lastdisguise</code> will cause the player to re-disguise as their last disguise. <small>(Spy only)</small>
 
*<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>load_itempreset (0-3)</code> will load a particular loadout preset [A, B, C, D].
*<code>say "message"</code> will send a message to public chat.
+
*<code>say message</code> will send a message to public chat.
*<code>say_team "message"</code> will send a message to team 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>+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>+use_action_slot_item</code> will cause the player to use their action slot item.
Line 360: Line 667:
 
*<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>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.
  
==Advanced Scripting Techniques==
+
== Advanced Scripting Techniques ==
===Toggles===
+
=== Toggles ===
 
It is possible to bind a key to toggle a command which would otherwise be a press and hold command.
 
It is possible to bind a key to toggle a command which would otherwise be a press and hold command.
  
<pre>bind w toggle
+
<pre>bind w toggle_movement
alias toggle "enable"
+
alias toggle_movement enable_movement
alias enable "alias toggle disable; +forward"
+
alias enable_movement "alias toggle_movement disable_movement;+forward"
alias disable "alias toggle enable; -forward"</pre>
+
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.
 
This script will cause a press of {{key|W}} to keep the player moving forward until {{key|W}} is pressed again.
===Key combinations===
+
 
 +
=== Key combinations ===
 
It is possible to create a script where pressing one button while another is held down will change the action of the first button.
 
It is possible to create a script where pressing one button while another is held down will change the action of the first button.
  
 
<pre>bind e call
 
<pre>bind e call
 
alias call Call_For_Medic
 
alias call Call_For_Medic
alias Call_For_Medic "Voicemenu 0 0"
+
alias Call_For_Medic "voicemenu 0 0"
alias Call_For_Ubercharge "Voicemenu 1 6"</pre>
+
alias Call_For_Ubercharge "voicemenu 1 6"</pre>
 
At this point, the script will mean that every time {{key|E}} is pressed, the player will call for a Medic. It also has an unused alias to call for an [[Ubercharge]].
 
At this point, the script will mean that every time {{key|E}} is pressed, the player will call for a Medic. It also has an unused alias to call for an [[Ubercharge]].
 
<pre>bind shift +toggleState
 
<pre>bind shift +toggleState
Line 382: Line 690:
 
Now, pressing {{Key|Shift}} will redirect <code>call</code> to ask for an ubercharge. Releasing {{Key|Shift}} will make <code>call</code> point back at a Medic call.
 
Now, pressing {{Key|Shift}} will redirect <code>call</code> to ask for an ubercharge. Releasing {{Key|Shift}} will make <code>call</code> point back at a Medic call.
 
When {{Key|Shift|E}} is pressed, the player will call for an Ubercharge, rather than for a Medic.
 
When {{Key|Shift|E}} is pressed, the player will call for an Ubercharge, rather than for a Medic.
 +
If you want multiple key combination binds connected to the same toggle key you will have to repeat the first step listed before.
 +
<pre>bind f thank
 +
alias thank Thank_Player
 +
alias Thank_Player "voicemenu 0 1"
 +
alias Good_Work "voicemenu 2 7"</pre>
 +
After this add the same command as what happened in the second step, but alongside the already used command.
 +
<pre>bind shift +toggleState
 +
alias +toggleState "alias call Call_For_Ubercharge;alias thank Thank_Player"
 +
alias -toggleState "alias call Call_For_Medic;alias thank Good_Work"</pre>
 +
Overall the script should look like:
 +
<pre>bind e call
 +
alias call Call_For_Medic
 +
alias Call_For_Medic "voicemenu 0 0"
 +
alias Call_For_Ubercharge "voicemenu 1 6"
  
===Wait-testing===
+
bind f thank
 +
alias thank Thank_Player
 +
alias Thank_Player "voicemenu 0 1"
 +
alias Good_Work "voicemenu 2 7"
 +
 
 +
bind shift +toggleState
 +
alias +toggleState "alias call Call_For_Ubercharge;alias thank Thank_Player"
 +
alias -toggleState "alias call Call_For_Medic;alias thank Good_Work"</pre>
 +
 
 +
=== 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.
 
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.
  
<pre>alias waitTester "alias waitTest waitPositive; wait; waitTest"
+
<pre>alias waitTester "alias waitTest waitPositive;wait;waitTest"
 
alias wait "alias waitTest waitNegative"
 
alias wait "alias waitTest waitNegative"
alias waitPositive "echo Wait is enabled on this server.; exec waitPositive.cfg"
+
alias waitPositive "echo Wait is enabled on this server.;exec waitPositive.cfg"
alias waitNegative "echo Wait is DISABLED on this server!; exec waitNegative.cfg"
+
alias waitNegative "echo Wait is DISABLED on this server!;exec waitNegative.cfg"
 
waitTester</pre>
 
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>.
 
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>.
===Loops===
+
 
 +
=== 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.'''
 
:'''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.
 
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.
  
<pre>bind g "loopKey"
+
<pre>bind g loopKey
 
alias loopKey startLoop
 
alias loopKey startLoop
alias startLoop "alias loopKey stopLoop; +attack; alias redirect loop; loop"
+
alias startLoop "alias loopKey stopLoop;+attack;alias redirect loop;loop"
alias stopLoop "-attack; alias redirect; alias loopKey startLoop"
+
alias stopLoop "-attack;alias redirect;alias loopKey startLoop"
alias loop "+left; wait 33; -left; +right; wait 33; -right; redirect"</pre>
+
alias loop "+left;wait 33;-left;+right;wait 33;-right;redirect"</pre>
  
 
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.
 
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.
===Sequences===
+
 
 +
=== Sequences ===
 
<pre>alias +pyrocombo "slot1;+attack;wait 32;slot2"
 
<pre>alias +pyrocombo "slot1;+attack;wait 32;slot2"
 
alias -pyrocombo "-attack;slot1"</pre>
 
alias -pyrocombo "-attack;slot1"</pre>
Line 411: Line 744:
 
Sequences are useful in making scripts, and learning how to make one will help in the long run of scripting.
 
Sequences are useful in making scripts, and learning how to make one will help in the long run of scripting.
  
===Cycles===
+
=== Cycles ===
A cycle is usually a longer toggle script where instead of an alias toggling between On and Off, the script can cycle though options 1-3. An important part of a cycle is that is always loops back on itself. So after cycling to "3", the script would always return to "1" as it's next option. An example of this would look somewhat like:
+
A cycle is toggle script where there are a minimum of 3 possible options, which loop (ex, 1, 2, 3, 1). Example:
 
<pre>
 
<pre>
alias "Fov_Cycle" "Fov1"
+
alias Fov_Cycle Fov1
alias "Fov1" "alias Fov_Cycle Fov2; fov_desired 90"
+
alias Fov1 "alias Fov_Cycle Fov2;fov_desired 70"
alias "Fov2" "alias Fov_Cycle Fov3; fov_desired 70"
+
alias Fov2 "alias Fov_Cycle Fov3;fov_desired 80"
alias "Fov3" "alias Fov_Cycle Fov1; fov_desired 80"
+
alias Fov3 "alias Fov_Cycle Fov1;fov_desired 90"
  
bind "o" "Fov_Cycle"
+
bind o Fov_Cycle
 
</pre>
 
</pre>
This makes it so upon pressing {{Key|O}} you switch between 90, 70, and 80 as fov values.
+
This script makes it so pressing the {{Key|O}} key, FOV values switch between 70, 80, and 90.
  
===Selection addons===
+
=== Selection addons ===
A selection script is usually built onto a cycle script to make it a little more intuitive. What a selection script does is allow you to not only cycle upwards in a cycle, but also downwards. This ultimately gives more control when it comes to selecting which command(s) you want to run
+
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>
 
<pre>
alias "CondC_UP" "Cond1"
+
alias CondC_UP Cond1
alias "CondC_DOWN" "Cond5"
+
alias CondC_DOWN Cond5
alias "ApplyCond" "addcond 49"
+
alias ApplyCond ApplyCond33
alias "Cond1" "alias CondC_UP Cond 2; alias CondC_DOWN Cond5; alias ApplyCond addcond 49"
+
alias ApplyCond33 "addcond 33"
alias "Cond2" "alias CondC_UP Cond 3; alias CondC_DOWN Cond1; alias ApplyCond addcond 33"
+
alias ApplyCond49 "addcond 49"
alias "Cond3" "alias CondC_UP Cond 4; alias CondC_DOWN Cond2; alias ApplyCond addcond 72"
+
alias ApplyCond72 "addcond 72"
alias "Cond4" "alias CondC_UP Cond 5; alias CondC_DOWN Cond3; alias ApplyCond addcond 74"
+
alias ApplyCond74 "addcond 74"
alias "Cond5" "alias CondC_UP Cond 1; alias CondC_DOWN Cond4; alias ApplyCond addcond 90"
+
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>
 
</pre>
What this does is allow us to choose a specific condition we want to add to the player, but it also allows us freedom of selection due to how we can not only scroll backwards and forwards. Essentially, this allows us to count up and down when it comes to choosing a specific thing to use.
+
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 ===
Randomization in TF2 is a strange and mainly useless thing when it comes to scripting. Due to how most things can't really be effectively used when random, this type of script is very rare and almost never talked about. But, when applied to loops or chat binds, you can get some useful results
+
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 how TF2's scripting works, this section will be considerably long. If you already don't really understand how cycles work, then you most likely won't understand how this works'''
+
'''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>
 
<pre>
alias "call" "f1"
+
alias call f1
alias "cycle" "c2"
+
alias cycle c2
  
alias "c1" "alias cycle c2; alias call f1"
+
alias c1 "alias cycle c2;alias call f1"
alias "c2" "alias cycle c3; alias call f2"
+
alias c2 "alias cycle c3;alias call f2"
alias "c3" "alias cycle c4; alias call f3"
+
alias c3 "alias cycle c4;alias call f3"
alias "c4" "alias cycle c5; alias call f4"
+
alias c4 "alias cycle c5;alias call f4"
alias "c5" "alias cycle c1; alias call f5"
+
alias c5 "alias cycle c1;alias call f5"
  
alias "f1" "say 1"
+
alias f1 "say 1"
alias "f2" "say 2"
+
alias f2 "say 2"
alias "f3" "say 3"
+
alias f3 "say 3"
alias "f4" "say 4"
+
alias f4 "say 4"
alias "f5" "say 5"
+
alias f5 "say 5"
  
alias "+w" "+forward; cycle"
+
alias +w "+forward;cycle"
alias "-w" "-forward; cycle"
+
alias -w "-forward;cycle"
alias "+a" "+moveleft; cycle"
+
alias +a "+moveleft;cycle"
alias "-a" "-moveleft; cycle"
+
alias -a "-moveleft;cycle"
alias "+s" "+back; cycle"
+
alias +s "+back;cycle"
alias "-s" "-back; cycle"
+
alias -s "-back;cycle"
alias "+d" "+moveright; cycle"
+
alias +d "+moveright;cycle"
alias "-d" "-moveright; cycle"
+
alias -d "-moveright;cycle"
  
bind "o" "call"
+
bind o call
bind "w" "+w"
+
bind w +w
bind "a" "+a"
+
bind a +a
bind "s" "+s"
+
bind s +s
bind "d" "+d"
+
bind d +d
 
</pre>
 
</pre>
Although small, this script is doing a whole bunch of assigning and resigning of alias values. When you hit any of the {{key|WASD}} keys you hit the cycle command, which moves the cycle command to the next value in the cycle and set the "call" command to a value corresponding to the cycle number. This entire thing works off of the players movement, and only works IF the player is in-fact moving. The limits of this specific randomizer are quite low, but with adding almost all of the other techniques stated here, a much better version of a randomizer can be achieved
+
This script is assigning and resigning multiple alias values. When any of the {{key|WASD}} keys 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.
 +
 
 +
=== 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).
 +
 
 +
<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>
 +
 
 +
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.
 +
 
 +
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.
 +
 
 +
'''Note:''' Rebinding of the key is technically redundant, as the script will not execute the timed action if the button is unpressed. 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 duraiton of the original <code>wait</code> delay ensures that the effect can't be triggered if the button is rapidly pressed.
  
 
== Commenting ==
 
== Commenting ==
Line 480: Line 836:
 
Since it is not obviously clear what the voice command is, a comment can explain it.
 
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, while others remain functional.
  
===Patched scripts===
+
=== Patched scripts ===
====Pistol 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.
 
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.
  
 
{{Patch name|8|13|2009}}: The Pistol now fires at a fixed rate, not based on the speed of pressing the fire button.
 
{{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====
+
==== 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.
 
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.
  
 
{{Patch name|6|23|2011}}: Fixed an exploit with the Chargin' Targe that allowed greater turning control than intended.
 
{{Patch name|6|23|2011}}: Fixed an exploit with the Chargin' Targe that allowed greater turning control than intended.
  
====Air crouching scripts====
+
==== 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.
 
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.
  
 
{{Patch name|3|6|2009}}: Players can now only duck twice in the air.
 
{{Patch name|3|6|2009}}: Players can now only duck twice in the air.
  
====Idling 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.
 
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.
  
 
[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.
 
[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.
  
===Current Scripts===
+
=== Current Scripts ===
====Weapon Viewmodel Hiding 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.
 
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====
+
==== 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.
 
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====
+
==== 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.
 
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.
  
Line 516: Line 872:
 
:''Note:'' The [[Rescue Ranger]] can circumvent this necessity, as it can pick up [[buildings]] at range for 100 [[metal]].
 
:''Note:'' The [[Rescue Ranger]] can circumvent this necessity, as it can pick up [[buildings]] at range for 100 [[metal]].
  
====Gunslinger Scripts====
+
==== 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.
 
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====
+
==== 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.
 
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====
+
==== 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.
 
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====
+
==== 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.
 
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====
+
==== 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.
+
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.
  
====Auto-Disguise 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.
 
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====
+
==== Ü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.
 
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.
  
====Kill-Bind Scripts====
+
==== 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>
 +
 
 +
==== Kill-Bind Scripts ====
 
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, sometimes for comedic effect instead of to benefit gameplay.
 
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, sometimes for comedic effect instead of to benefit gameplay.
  
====Null-Cancelling Movement Scripts====
+
==== 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.
 
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.
  
 
== Notes ==
 
== Notes ==
Line 549: Line 917:
 
* [[List of useful console commands]]
 
* [[List of useful console commands]]
 
* {{vdc|List of TF2 console commands and variables}}
 
* {{vdc|List of TF2 console commands and variables}}
 +
 +
== References ==
 +
<references />
  
 
== External links ==
 
== External links ==
*[http://www.gamebanana.com/scripts/games/297 Hundreds of scripting examples on Gamebanana]
+
* [http://gamebanana.com/scripts/games/297 Hundreds of scripting examples on Gamebanana]
 +
* [http://cfg.tf/ Website dedicated to Team Fortress 2 configuration]
  
 
[[Category:Customization]]
 
[[Category:Customization]]

Revision as of 15:53, 18 September 2021

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

Scripting is the use of configuration files (.cfg) mainly 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.

Scripting Commands

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

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.

Binds come in two forms:

bind e "voicemenu 0 0"

This bind will make the player call for a Medic when they press E.

bind w +forward

This bind will make the player move forward while they have W held down.

Toggle

This command allows a setting to be toggled between two or more values.

toggle sv_cheats 0 1

Bindtoggle

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)

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

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 E, they will call for a Medic.

Note: An alias can have a + symbol in front of it (e.g. +Diagonal), it will execute the - version afterwards (e.g. -Diagonal). This can be useful for movement binds.
alias "+Diagonal" "+moveleft; +back"
alias "-Diagonal" "-moveleft; -back"
bind "z" "+Diagonal"

This script allows the player to move diagonally. Here, pressing Z will cause the player to move diagonally backward and left.

Warning: The following code will not work!
bind "z" "+moveleft; +back"

Although pressing Z will 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 Z will not cause the player to stop backing up.

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 autoexec.cfg

This script will execute the player's autoexec script.

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.

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 ticks (1 second on most servers) 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
heavy.cfg
engineer.cfg
medic.cfg
sniper.cfg
spy.cfg

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

Launch Options

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


Set Launch Options

A visual guide on how to set launch options (indicated by the green areas).
  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.

Common Launch Options

Option Value Description
-autoconfig N/A Restores video and performance settings to default for the current hardware detected. Ignores settings inside any .cfg files until this parameter is removed
-dxlevel 80, 81, 90, 95 Forces a specific DirectX version when launching the game. This is useful if your graphics hardware is older, and gets significantly better performance in an earlier version of DirectX
-fullscreen N/A Forces the engine to start in fullscreen mode
-windowed N/A Forces the engine to start in windowed mode
-w <width> Forces the engine to start with resolution set to <width>
-h <height> Forces the engine to start with resolution set to <height>. This launch option does not need to be set in the presence of -w. The width value will determine the height automatically
-refresh <rate> Force a specific refresh rate
-novid N/A Skips the valve intro video
-sillygibs N/A Enables low violence mode

Launch Options to Adjust Detail Levels and Graphic Rendering

Option Value Description
+r_rootlod # Adjusts Model Detail where # is 0 for high, 1 is medium, and 2 for low
+mat_picmip # Adjusts Texture Detail where # is 0 for high, 1 is medium, and 2 for low
+mat_reducefillrate # Adjusts Shader Detail where # is 0 for high and 1 for low
+r_waterforceexpensive # Adjusts Water Detail where # is 0 for low and 1 for high
+r_waterforcereflectentities # Adjusts Water Reflectiveness where # is 0 for low and 1 for high
+r_shadowrendertotexture # Adjusts Shadow Detail where # is 0 for low and 1 for high
+mat_colorcorrection # Adjusts Color Correction where # is 0 for low and 1 for high
+mat_trilinear # Use Bilinear Mode (least system-intensive, # = 0) / Use Trilinear Mode (more system-intensive, # = 1)
+mat_forceaniso # Use Trilinear Mode (where # is 2, 4, 8, or 16 - higher levels of filtering require more system resources)
+mat_hdr_level # Adjusts High Dynamic Range lighting effects where # is 0 for "off" (requires least resources) and 2 for "full"

Advanced Launch Options

  • -all_languages - Loads all language files
  • -autoconfig - Restores video and performance settings to default for the current hardware detected. Ignores settings inside any .cfg files until this parameter is removed
  • -32bit - Forces the engine to start in 32-bit mode. Only useful on 64-bit Operating Systems.
  • -adapter - Sets the GL graphics adapter. Default is 0.
  • -allowdebug - Fakes a debugger for phonehome, and is the same as -dev, unless -nodev is specified.
  • -allowstalezip - Suppresses console warnings from stale.txt existing.
  • -basedir - Sets the base directory for the game files. On Xbox 360 RFS, this is forced to smb://hostname/game.
  • -bi - Defines the build identifier ID which is used in phonehome
  • -bugbait - This lets IsLoadingBugBaitReport return true.
  • -bugreporterdll - Name of the bug reporter DLL to use
  • -buildcubemaps - Builds cubemaps when fully loaded into a map, then quits the game.
  • -ccsyntax - Spew details about the localized strings we load.
  • -clientport - Sets the client port. Default is 27002.
  • -collate - Skips everything, just merges the reslist from temp folders to the final folder again.
  • -conclearlog - Clears the console.log text file on start. Only works if -condebug set.
  • -condebug - Logs all console output into the console.log text file.
  • -console - Starts the game with the developer console enabled. Same as having con_enable enabled.
  • -deathsonly - Supposed to only count deaths while parsing TF2 gamestats, but actually pointless because there is only code for deaths.
  • -defaultgamedir - Fallback directory if "-game" is not set. Default is "hl2".
  • -dev - Enables developer mode. Also disables the automatic loading of menu background maps and stops the quit dialog from appearing on exit.
  • -debugdxsupport - Writes debug DirectX information as keyvalues to the console as shader devices are loading configuration.
  • -disallowhwmorph - Same as mat_disablehwmorph 1. Disables HW morphing for particular mods.
  • -dti - Prints the datatable when being sent
  • -dumpvidmemstats - Spews video memory statistics to vidmemstats.txt. This forces CModelLoader to quit.
  • -dvd - Enables strict DVD mode. Allows loading files from DVD only. Xbox 360 only.
  • -dvddev - Enables developer DVD mode. Allows loading files from a remote path as a fallback as well as the DVD. Xbox 360 only.
  • -dxlevel <level> - Forces the game to start using specified DirectX API version. Officially supported values are: 60, 70, 80, 81, 90, 91, 95 (recommended), 98 (Xbox 360 only), and 100. After starting the game with this launch parameter, the selected value will be saved for future start ups and video settings will be temporarily reset (but not saved), so it is highly recommended to remove this launch parameter after first launch with it. See mat_dxlevel.
  • -edit - According to comments, intended to replace -tools. Does nothing except disable all file logging for building reslists.
  • -endgamevid - If specified startup videos will not be skipped, and EndGameVids.txt will be used instead of StartupVids.txt. This can also be invoked by the command "startupmenu playendgamevid", which bails back to the menu and plays the end game video.
  • -exit - Quits the game after fully loading into a map.
  • -filmgrain - Enables the filmgrain screen space effect.
  • -flushlog - Causes log files to be flushed to disk once per second (rather than after every 4kbytes of log data).
  • -floathdr - Forces HDR to use float values.
  • -forcenovsync - Forces vsync to be disabled.
  • -forcestartupmenu - Forces the background menu map to always load, even if developer mode is active or the game is loading straight to a level.
  • -forcexboxreconfig - Forces default config settings to be loaded on Xbox 360.
  • -forever - When you get to the end of the maplist, start over from the top
  • -fs_log - Starts creating a batch file to copy files at the specified filename. This works on the latest engine branch.
  • -fs_logbins - Logs binaries to the batch file from -fs_log.
  • -fs_nopreloaddata - Loads in the precompiled keyvalues data for each type. Works only with dedicated servers.
  • -fs_target - Sets the target game directory to copy files to, used with -fs_log.
  • -full_memory_dumps -
  • -fullscreen or -full - Forces the engine to start in fullscreen mode.
  • -g15 - Enables Logitech G15 support. G15 is only supported in SiN Episodes: Emergence. [confirm]
  • -game - Sets game or mod directory to load the game from. Usually is set by default if not user specified. Default is "-defaultgamedir"'s setting. If -defaultgamedir is not set, "hl2" is used.
  • -gamestatslogging - Enables game stats logging.
  • -gamestatsloggingtofile - Enables game stats logging out to a file, gamestats.log. Passing this parameter automatically forces -gamestatslogging.
  • -gl_enablesamplerobjects - (Linux) Use OpenGL Sampler Objects for better texture preloading
  • -gl_texclientstorage - (MacOS) Reduce memory usage by relying on GPU memory instead of a host copy
  • -gamestatstag <tag> - Tags each map reported with the specified tag.
  • -h <height> - Forces the engine to start with resolution set to <height>. Ex: -h 768
  • -height <height> - Same as -h
  • -heapcheck - (Windows only) Check if the heap isent damaged or empty at the initiation of the game and every frame
  • -heapsize <kilobytes> - Specifies the heapsize (in kilobyte) the game will use. This no longer exists on the Source 2009.
  • -hideconsole - Forces the console to be hidden, whatever parameters are passed. This overrides -console, -dev, and all others.
  • -high - Sets the game's priority to High
  • -hijack - Take control of an existing instance of the game, if any, instead of complaining about already running.
  • -host - Sets hostname. On Xbox 360, this sets the host computer name to be used for RFS. Xbox name must be <HostPC>_360.
  • -hushasserts - Disables a number of asserts in core Source libraries, skipping some error checks and messages.
  • -hushsteam - For security. Prevents local game servers from registering their IP with Steam.
  • -ignoredxsupportcfg - Skips reading DirectX support file, dxsupport.cfg.
  • -insecure - Disable Valve Anti Cheat (VAC).
  • -internalbuild - Causes the bug reporter panel to be drawn as internal
  • -ip - Does the same as the ipname Cvar
  • -language %l - Sets the game language to the one specified. (Examples: "english", "german").
  • -leakcheck - Dumps statistics about memory leaks.
  • -limitvsconst - Limits the number of vertex shaders to a maximum of 256.
  • -localcser - Sets a custom gamestats CSER other than the Steam-provided public one (default is steambeta1:27013)
  • -low - Sets the game's priority to Low
  • -lowmemworkshop - Allow updating very large map files on Steam Workshop. (Supposedly added and fixed in the June 22, 2021 Patch but unknown if compatible)
  • -makedevshots - Used for taking screenshots, causing entities to not fade. Enables the use of the devshots_nextmap concommand
  • -makereslists - Makes reslists. Need to run with -textmode. Passing a parameter here uses a script file to control more complex makereslists operations (multiple passes, etc.)
  • -mat_aaquality - Set MSAA quality level, does the same as the Convar mat_aaquality
  • -mat_antialias - Antialiasing. Can be set to 8, amount past 8 won't sharpen the edges of game world.
  • -mat_vsync - Enables Vertical Sync
  • -mat_softwaretl - Enables software vertex processing.
  • -maxdxlevel - Limits the maximum dxlevel to use. Default is 0.
  • -maxdownloadfilesizemb - client launch option -maxdownloadfilesizemb N if clients needs to download even larger files from community servers.
  • -maxplayers - Set the maximum players allowed to join the server. This does the same as the maxplayers convar, the maximum you can set it to is limited by the game/mod
  • -minmemory - Set startup memory to mem_min_heapsize ?*1024 * 1024?
  • -monitorTextureSize - Set the size of the texture used to render point_cameras.
  • -multirun (only in <Source><Source>) - Allows the game to run even if another Source game is already open.
  • Note.png Note: - While only implemented in Source 2013, using this while a non-2013 game is already running will work.
  • -navanalyze - related to navmeshes (unknown)
  • -navforceanalyze - related to navmeshes (unknown)
  • -netspike - Sets the trace threshold to the specified value (the limit of the number of records that will be written to netspike.txt before all records are removed).
  • -newdialogs - Forces new Steam dialog to be used.
  • -no_compressed_verts - Disables vertex compression for shaders.
  • -no_compressed_vvds - Enables thin VVD data, even if the client is not an Xbox 360.
  • -noassert - Allows attaching to a debugger instead of directly asserting.
  • -noasync - Disables asynchronous filesystem access.
  • -noborder - When used with the game set to windowed mode, will make the game act as if in fullscreen mode (no window border).
  • -nobots - Allows Counter-Strike server hosts to force bots disabled to enforce CPU limits. (may be TF2 compatible)
  • -nobreakpad - unknown
  • -noconvert - (xbox360) "No conversions during retail"
  • -noclearsave - Skips clearing the save directory after restoring a save.
  • -nocrashdialog - Stop some windows crash message boxes from showing up.
  • -nodev - Disables -dev and -allowdebug during startup so sv_cheats and developer mode dosent get set.
  • -nodns - Disable DNS requests and resolving DNS adresses.
  • -nodttest - Skips datatable testing.
  • -noff - Disables force feedback for controllers.
  • -noforcemaccel - Use the Windows mouse acceleration settings. Only works if -useforcedmparms is set.
  • -noforcemspd - Use the Windows mouse speed settings. Only works if -useforcedmparms is set.
  • -nogamedll - Do not load the Game DLL, this most likely will cause your game/server to crash
  • -nogamestats - related to game stats (unknown)
  • -nohltv - Disable SourceTV
  • -noip - Do not bind to an ip and disables all multiplayer support
  • -nojoy - Disables joystick support.
  • -NoLoadPluginsForClient - Disables plugins for client-side
  • -nomaster - Hides server from master serverlist.
  • -nomessagebox - Stop various windows error message boxes from showing up
  • -nominidumps - Dont write minidumps
  • -nomouse - Disables in-game mouse support.
  • -nop4 - Forces the Engine to bypass Perforce Integration
  • -nopreload - Forces models to not be preloaded. Takes priority over cl_forcepreload and -preload.
  • -nopreloadmodels - Same as -nopreload
  • -nops2b - Disables Pixel Shader 2b support.
  • -noqueuedload - Disables queued loading of map resources.
  • -NoQueuedPacketThread - (Linux) No queued packet thread will be created.
  • -norebuildaudio - Opposite of and overrides -rebuildaudio for the map reslist generator.
  • -nodefaultmap - (Linux only[confirm]) Supresses the addition of -map
  • -norfs - Forces Remote Filesystem disabled. Xbox 360 only.
  • -noshaderapi - Loads a non-existent shader API dll, shaderapiempty.dll. Effectively disables shader and texture loading completely. May be useful with -textmode to load the game quickly since a GUI is not required.
  • -nosound - Disables sound support
  • -nosrgb - Disables support for SRGB.
  • -nostartupsound - Disables menu music (sound/ui/gamestartup*.mp3) to play on startup.
  • -nosteamcontroller - Disables Steam controller system
  • -nouserclip - Uses software clipping instead of hardware user clip planes
  • -NoVConfig - Prevents the filesystem library from running VConfig if it encounters a filesystem error where it cannot find the game content.
  • -novid - When loading a game with this parameter, the intro video will not play.
  • -olddialogs - Forces old Windows dialogs instead of new Steam ones.
  • -override_vpk - Forces actual files to override VPK.
  • -particles - Sets the number of beam trails to allow (2048 by default, minimum is 512).
  • -phonehome - If debug mode is also enabled, forces the init of phonehome ?which handles some build information and sends them via netmessages to steam?
  • -pidfile <pidfile> - Use the specified <pidfile> to store the server pid. Default is srcds.pid[confirm] (Unix/Linux only).
  • -pixel_offset_x - Sets the pixel offset to translate on the X axis in MatSystemSurface.
  • -pixel_offset_y - Sets the pixel offset to translate on the Y axis in MatSystemSurface.
  • -pme - Activate the performance monitoring events code, this again only works on Intel processors newer then PENTIUM4
  • -port <variable> - Sets port for a listen server. Default is 27015.
  • -preload - Does the same as the sv_forcepreload Cvar. If -nopreload or -nopreloadmodels, this behaviour is disabled
  • -primarysound - If surround sound isn't enabled, forces the use of the primary sound buffer
  • -profile - If using Xbox360 or enabling this, additional debugging information are logged like the map startup time and similar
  • -publicbuild - Is this build a public one? If not, phonehome will not post information of this build to steam
  • -random_invariant - Forces the game's random number generator value to be invariant.
  • -rebuildaudio - Forces rebuild of _other_rebuild.cache (metacache) file at exit for the map reslist generator.
  • -recapvid - RecapVids.txt will be used instead of EndGameVids.txt. This can also be invoked by the command "startupmenu playrecapvid", which bails to the mainmenu and plays the recap video.
  • -ref - Sets MATERIAL_INIT_REFERENCE_RASTERIZER on the shader material adapter.
  • -remote - Sets the remote file path to be used with -dvddev.
  • -replay - Increases maxplayers by 1 at startup and automatically executes replay.cfg for the server.
  • -requirecubemaps - If a map dosen't have cubemaps, the game will promt up with "Map X does not have cubemaps!"
  • -reflectionTextureSize - Set the size of the texture used to render the Water shader's real-time reflection and refraction.
  • -refresh <rate> - Force a specific refresh rate. Ex: -refresh 60
  • -refreshrate <rate> - Same as -refresh
  • -freq <rate> - Same as -refresh
  • -r_emulate_gl - Emulates OpenGL on Windows, provides a framerate boost for most GPUs
  • -resizing - Allows resizing the window lower than a specific resolution.
  • -reslistdir - Default is "reslists", use this to override. Reslist generator only.
  • -reuse - Reuse network sockets
  • -rpt - Same as having -condebug, -conclearlog, and -console enabled
  • -safe - Enables video safe mode, which sets the game to windowed, the width to 640, the height to 480, refresh rate to default, and disables antialiasing.
  • -shader - Loads a specific shader library instead of depending on hardware. Debug only.
  • -shaderdll - Loads a different shader dll. Default is shaderapidx9.dll. To do: Is this the same as -shader?
  • -shadersondemand - Creates shaders on access, helps reduce D3D memory for tools, but causes I/O hitches.
  • -sillygibs - Forces pyroland-esqe gibs
  • -small - Allow window sizing smaller then 640x480
  • -sndcachedebug - Prints sound cache debug messages (developer must be enabled to see)
  • -snoforceformat - Skips sound buffer creation
  • -soft - Enables Software hardware rendering mode.
  • -softparticlesdefaultoff - Sets particles to be rendered without feathering (scene depth blending) by default.
  • -softparticlesdefaulton - Opposite of -softparticlesdefaultoff.
  • -spewsentences - Spew out vox sentence names during reslist generation
  • -startmap - Restarts devshot generation at the specified map if resuming from a crash.
  • -startstage - When running from script file, this starts at specified stage, and sets current work item (default is 0). Reslist generator only.
  • -steam - Enables Steam support (if the game is launched from Steam, this is enabled by default). Working directory must be Steam directory. Works only for singleplayer games.
  • -steamlocal - Similar to -steam. Runs Steam in local filesystem mode (all content off HDD), as opposed to remote filesystem mode (requiring Steam backend).
  • -steamport - Master server updater port. Steam authentication port is this port + 1. (default is 26900)
  • -strictportbind - If you launch the game with this option it will quit with an error message if it can't bind to the default or specified port.
  • -sv_benchmark - Enables benchmarking through sv_benchmark_force_start.
  • -swapcores - Swaps threads for the particle and material systems each init
  • -tempcontent - Searches for game content in a folder called "_tempcontent" relative to the absolute game path. This option is enabled by default for Portal 1
  • -testscript <filename> - Loads a .vtest file.
  • -testshaders - Loads the shader_test library. Debug only.
  • -testsub - does nothing
  • -textmessagedebug - Spews client text messages to console.
  • -textmode - Runs the game without graphics
  • -threads - Number of threads to allocate for the thread pool, default is 3
  • -tickrate - Sets the game tick interval. Disabled in code for TF2 because "server ops are abusing it".
  • -timedemoloop - unknown
  • -toconsole - Starts the engine directly in the console, unless a map is specified with +map.
  • -tools - Enables engine tools.
  • -trackdeletions - Logs what files are marked for deletion in Reslist Generator.
  • -tvmasteronly - Only one person allowed in HLTV.
  • -usedevshotsfile - Get map list from specified file, default is to build for maps/*.bsp
  • -useforcedmparms - Allows the use of -noforcemspd and -noforcemaccel.
  • -usegh - Loads ghostinj.dll to allow support for third party dlls (gamehost)
  • -uselogdir - Logs various data to logs/(mapname)/*
  • -usercon - Enable RCON for Counter-Strike: Global Offensive servers (may work in TF2)
  • -usereslistfile - Get map list from specified file, default is to build for maps/*.bsp. Reslist generator only.
  • -usetcp - Disable TCP support
  • -vcrplayback - Plays back a VCR recording. Nothing is simulated on the server, but all server packets are recorded.
  • -vcrrecord - Records a client's game and allows you to play it back and reproduce it exactly. To do: how is this different from a demo?
  • -vguifocus - Enables debug VGUI messages related to input focus.
  • -vguimessages - Enables debug VGUI messages.
  • -vxconsole - Waits for Valve Xbox console to initialise. Xbox 360 only.
  • -vproject - Manually sets the VProject directory to load game content for tools.
  • -w <width> - Forces the engine to start with resolution set to <width>. Ex: -w 1024
  • -width <width> - Same as -w
  • -wavonly - Disables DirectSound and makes the engine attempt to play all sounds in PCM format.
  • -window - Forces the engine to start in windowed mode
  • -sw - Same as -window
  • -startwindowed - Same as -window
  • -windowed - Same as -window
  • -xnet_bypass_security - Disables Xbox 360 secure networking, to allow cross-platform testing.
  • -x <x position> - In borderless windowed mode, determines where the window should be horizontally. Ex: -x 0
  • -y <y position> - In borderless windowed mode, determines where the window should be vertically. Ex: -y 0
  • +connect - Console Command
  • +load - Console Command
  • +mat_hdr_level - sets the hdr strength
  • +maxplayers - Console Command
  • +playdemo - Console Command
  • +port - Console Command
  • +timedemo - Console Command
  • +timedemoquit - Console Command

Resolution

Launch Option: -w # -h #

Description: Replace the hashtag with the number of your desired resolution.

High

Launch Option: -high

Description: This launch option tells your CPU to run the game in High Priority Mode.
Warning red.png Warning: Use extreme care when using the high-priority mode, because a high-priority mode application can use nearly all available CPU time.[1]

Mouse Acceleration

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 Video

Launch Option: -novid

Description: This removes the Valve launch-video shown when the game is started, which decreases loading times.

DirectX

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.

Windowed Mode

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. 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, but disguise 8 3 will not undisguise a RED Spy.

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.

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 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 E is pressed, the player will call for a Medic. It also has an unused alias to call for an Ubercharge.

bind shift +toggleState
alias +toggleState "alias call Call_For_Ubercharge"
alias -toggleState "alias call Call_For_Medic"

Now, pressing ⇧ Shift will redirect call to ask for an ubercharge. Releasing ⇧ Shift will make call point back at a Medic call. When ⇧ Shift+E is pressed, the player will call for an Ubercharge, rather than for a Medic. If you want multiple key combination binds connected to the same toggle key you will have to repeat the first step listed before.

bind f thank
alias thank Thank_Player
alias Thank_Player "voicemenu 0 1"
alias Good_Work "voicemenu 2 7"

After this add the same command as what happened in the second step, but alongside the already used command.

bind shift +toggleState
alias +toggleState "alias call Call_For_Ubercharge;alias thank Thank_Player"
alias -toggleState "alias call Call_For_Medic;alias thank Good_Work"

Overall the script should look like:

bind e call
alias call Call_For_Medic
alias Call_For_Medic "voicemenu 0 0"
alias Call_For_Ubercharge "voicemenu 1 6"

bind f thank
alias thank Thank_Player
alias Thank_Player "voicemenu 0 1"
alias Good_Work "voicemenu 2 7"

bind shift +toggleState
alias +toggleState "alias call Call_For_Ubercharge;alias thank Thank_Player"
alias -toggleState "alias call Call_For_Medic;alias thank Good_Work"

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;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 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 the O key, FOV values switch between 70, 80, and 90.

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, 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 unpressed. 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 duraiton of the original wait delay ensures that the effect can't be triggered if the button is rapidly pressed.

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

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.

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

References

External links