Tool Bar top Anon

TF2 Scripting Tutorial

The post has been submitted for moderation and won't be listed publicly until it has been approved.

FanUp SCORE

8.2
good
Rate This

Team Fortress 2

+ Add  Article

TF2 Scripting Tutorial

Welcome to my scripting guide!
You may learn here basics of scripting in TF2.

For editing CFG files I recommend using Notepad + +.

All things mentioned here should be saved in your user config.
How you can make your own config? Where it should be placed?

Your TF2 cfg folder where you put all your configs should be located in:
C:\Program Files\Steam\steamapps\%accountame%\team fortress 2\tf\cfg
C:\Program Files\Valve\Steam\steamapps\%accountame%\team fortress 2\tf\cfg
Where %accountname% is your Steam login.

To save your config as a cfg file when you are saving file pick from file type dropdown All files (*.*), but when you are using this method you need to type file name and extension. For exapmle myconfig.cfg

Now open autoexec.cfg
and add a line
exec configname
where configname is name of config that you have chosen recently.

In your CFG folder you can find configs with class names in titles, they are executed every time you select that class.

Note:If you cant see file extension in file name please follow this guide.

Numpad key names
Code:
"KP_MINUS" Minus
"KP_PLUS" Plus
"KP_Enter" Enter
"KP_DEL" ,
"KP_INS" 0
"KP_END" 1
"KP_DOWNARROW" 2
"KP_PGDN" 3
"KP_LEFTARROW" 4
"KP_5" 5
"KP_RIGHTARROW" 6
"KP_HOME" 7
"KP_UPARROW" 8
"KP_PGUP" 9
"KP_SLASH" /
"KP_MULTIPLY" *

Binding

Binding is basically assigning commands to keys
Code:
bind "key" "command"

If you want to assign multiple commands divide them by ;
Code:
bind "key" "command; command; command"

Example №1: You want to bind reload to a specified key:
Code:
bind "key" "+reload"

Example №2: You want to bind taunt and explode commands to same key
Code:
bind "key" "taunt; wait 30; explode"

Incrementvar
That command allows you cycle between specified values on chosen range.
Code:
bind "key" "incrementvar command 1 12 3
(where 1 and 12 is range and 3 is jump between values)

Example №1: You want to change sensitivity from one to twenty with 2 points jump.
Code:
bind "key" "incrementvar sensitivity 1 20 2"

Example №2: You want to switch between 3 basic net_graph positions with one click.

Code:
bind "key" "incrementvar net_graphpos 1 3 1"

Aliasing
Alias command allows you to shorten very long commands into one short alias.
Code:
alias nameofyourscript "firstalias"
alias firstalias "command; command; alias nameofyourscript secondalias"
alias secondalias "command; command; alias nameofyourscript thirdalias"
alias thirdalias "command; alias nameofyourscript firstalias" //last alias should point to first one

Note: you can use as many aliases as you want, same with commands.

Example №1: Lets say that we want a name changing script.
Code:
alias namescr "firstname"
alias firstname "setinfo name "First_name"; alias namescr secondname"
alias secondname "setinfo name "Second_name"; alias namescr thirdname"
alias thirdname "setinfo name "Third-name"; alias namescr firstname"

bind "key" namescr

Note: That script does not allow spaces in names, if you want space in your nick look below.

Example №2: Duck script. Second example will be a duck script that will allow you to duck without holding a key.
Code:
alias duck "duckON"
alias duckON "+duck; alias duck duckOFF"
alias duckOFF "-duck; alias duck duckON"
bind "key" "duck"

Example №3: You and your friend are playing at same PC, both of you have different keybindings. There is a easy solution for this!
Code:
alias configsw "yourconfig"
alias yourconfig "exec yourconfig; developer 1; echo Yourconfig.cfg; wait 250; developer 0; alias configsw friendconfig"
alias friendconfig "exec friendconfig; developer 1; echo Friendconfig.cfg; wait 250; developer 0; alias configsw yourconfig"
bind "key" "configsw"

This should be used if you want to switch names in game and your names have spaces.

+ and - commands
Plus and Minus commands are commands that have 2 states.
Plus part is executed when you press a key and it's execute until key is released. When key is released it goes into minus state.
Example:
Code:
bind "mouse1" "+attack"

You aren't limited to commands that developers created. You can create your own using alias command.
Code:
alias +minigun "+duck; +attack"
alias -minigun "-attack; -duck"
bind "key" "+minigun"

As you probably noticed, there is no need to bind minus command, it's executed automatically after you stop holding key that you bound it to.

Useful scripting commands:
Code:
"wait" Stop command parsing until next frame.(if you put a value ex: wait 30 it will wait 30 frames)
"exec" Executes user config
"bind" Binds command to key (bind "F1" "kill")
"unbind" Unbinds command (unbind "F1")

Pyro loadout binds
Equip command doesn't exist since 2009-02-17.

Heavy loadout binds
Equip command doesn't exist since 2009-02-17.

Medic loadout binds
Equip command doesn't exist since 2009-02-17.

Engineer buildables binds
Paste this into Engineer.cfg
Code:
echo **Execing Engineer Config**
bind "KP_ENTER" "build 3" //Builds Sentry
bind "KP_PGDN" "build 0" //Builds Dispenser
bind "KP_DOWNARROW" "build 1" //Builds Teleport Entrance
bind "KP_END" "build 2" //Builds Teleport Exit
bind "KP_PLUS" "destroy 3" //Destroy Sentry
bind "KP_RIGHTARROW" "destroy 0" //Destroy Dispenser
bind "KP_5" "destroy 1" //Destroy Teleport Entrance
bind "KP_LEFTARROW" "destroy 2" //Destroy Teleport Exit

Spy cloak weapon switcher
Code:
alias disg "primaryweapon"
alias primaryweapon "slot1;lastdisguise;alias disg secondaryweapon"
alias secondaryweapon "slot2;lastdisguise;alias disg meleeweapon"
alias meleeweapon "slot3;lastdisguise;alias disg primaryweapon"

bind "b" "disg"

Visual problems fix
You got lagged or you alt-tabbed out of game and you got a visual problems?
That is fix for misplaced items, players holding wrong weapons, invisible players, missing cart indicator and wrong team color models(Blue medic with red needle gun)

Code:
bind "home" "record fix; stop"

Stopping music that is played on server
Admin is playing annoying music and you don't want to disable sounds downloading?
Use that bind to stop music:

Code:
bind "key" "play common/null"

Console commands
Basic gameplay
Code:
"+forward" Move forward
"+back" Move back
"+moveleft" Move left
"+moveright" Move right
"+jump" Jump
"+duck" Duck
"+moveup" Swim up
"+movedown" Swim down
"+attack" Primary attack
"+attack2" Secondary attack
"+reload" Reload weapon
"slot1" Weapon category 1
"slot2" Weapon category 2
"slot3" Weapon category 3
"slot4" Weapon category 4
"slot5" Weapon category 5
"invprev" Previous weapon
"invnext" Next Weapon
"lastinv" Last used weapon
"taunt" Taunt
"dropitem" Drop item(intelligence)
"changeteam" Change team menu
"changeclass" Change class menu
"lastdisguise random" [Spy]Random disguise (no Spy/Scout)

Spy Disguises
Code:
"disguise 1 2" Red Scout
"disguise 2 2" Red Sniper
"disguise 3 2" Red Soldier
"disguise 4 2" Red Demoman
"disguise 5 2" Red Medic
"disguise 6 2" Red Heavy
"disguise 7 2" Red Pyro
"disguise 8 2" Red Spy
"disguise 9 2" Red Engi

"disguise 1 1" Blue Scout
"disguise 2 1" Blue Sniper
"disguise 3 1" Blue Soldier
"disguise 4 1" Blue Demoman
"disguise 5 1" Blue Medic
"disguise 6 1" Blue Heavy
"disguise 7 1" Blue Pyro
"disguise 8 1" Blue Spy
"disguise 9 1" Blue Engi

Communication
Code:
"+voicerecord" Voice communication
"say" Chat message(Public chat)
"say_team" Chat message(Team chat)
"voice_menu_1" 1st Voice menu
"voice_menu_2" 2nd Voice menu
"voice_menu_3" 3rd Voice menu

"voicemenu 0 0" Medic!
"voicemenu 0 1" Thanks!
"voicemenu 0 2" Go go go!
"voicemenu 0 3" Move up!
"voicemenu 0 4" Flank left!
"voicemenu 0 5" Flank right!
"voicemenu 0 6" Yes!
"voicemenu 0 7" No!

"voicemenu 1 0" Incoming!
"voicemenu 1 1" Spy!
"voicemenu 1 2" Sentry ahead!
"voicemenu 1 3" Need a Teleporter here!
"voicemenu 1 4" Need a Dispenser here!
"voicemenu 1 5" Need a Sentry here!
"voicemenu 1 6" Activate UberCharge!
"voicemenu 1 7" (MEDIC) UberCharge Ready!

"voicemenu 2 0" Help!
"voicemenu 2 1" Battle Cry
"voicemenu 2 2" Cheers
"voicemenu 2 3" Jeers
"voicemenu 2 4" Positive
"voicemenu 2 5" Negative
"voicemenu 2 6" Nice shot!
"voicemenu 2 7" Good job!

Netgraph commands
Code:
"net_graph" Enable/disable netgraph (2-4 advanced modes)
"net_graphheight" Height of netgraph
"net_graphpos 3" Position of netgraph (3-left 2-middle 1-right)

Demo commands
Note: Shift+F2 brings demoui
Code:
"cl_demoviewoverride" Override player view when you are playing a demo
"demoui" Show hide demo controlling interface

"demoui2" Show hide demo controlling interface(diffrent look than normal one)
"demolist" Show list of demos
"record demoname" Records a demo (replace demoname with name of your demo)
"stop" Stops demo recording

Server/Multiplayer commands
Code:
"cl_downloadfilter" None-enables downloading files, nosounds-disables downloading sounds, all-disables downloading files
"mp_autoteambalance" Enables/Disables team balance
"mp_decals" Number of rendered decals
"mp_maxrounds" Number of rounds that could be played before map change
"mp_restartround" If non-zero round will be restarted in x seconds
"mp_teams_unbalance_limit" Teams are unbalanced when one team has this many more players than the other team
"mp_timelimit" Time limit per map
"mp_winlimit" Maximal number of rounds that team can win before map changes
"sv_allowdownload" Allows/Disallows downloading files
"sv_allowupload" Allows/Disallows uploading files
"sv_alltalk" Allows both teams to hear each other
"sv_gravity" Determines gravity on server(800 by default)
"sv_lan" Makes your server LAN only
"sv_hltv" Activates HLTV
"sv_password" Sets server password
"sv_pausable" Enables/Disables ability to pause game
"sv_voiceenable" Enables/Disables voice chat

Misc useful commands

Code:
"exit" hmm... Closes game?
"kill" Kills yourself
"explode" Kills yourself(you explode)
"hud_fastswitch" Turns fastswitch (0 disables 1 enables 2 disables [consoles style])
"showmapinfo" Shows info about map
"+showscores" Shows scroreboard
"impulse 201" Sprays your logo
"toggleconsole" Opens console
"screenshot" Makes a screenshot (TGA)
"jpeg" Makes a screenshot (JPEG)
"fps_max" Limits your FPS
"mat_bumpmap" Enables/Disables bumpmapping
"mat_compressedtextures" Enables/Disables textures compression
"mat_dxlevel" Sets DirectX level
"mat_specular" Enables/Disables spectacular lighting
"cl_showfps" Shows fps, but not netgraph statistics (upper left)
"mat_picmip" (-10 min., 4 max) - Changes texture quality, -1 = Very High.
"cl_drawhud" Disalbes the hud, useful for taking screenshots.
"hidepanel all" Hides the panels, useful for taking screenshots.
"jpeg_quality" (0-100) - Changes the qualtiy of jpeg screenshots, 90 = default.

Multithreading commands

Code:
"mat_queue_mode -1" Autodetection, enables threaded rendering if you have multiple cores
"mat_queue_mode 0" Disables threaded rendering
"mat_queue_mode 2" Enables threaded rendering it even if you don't have multiple cores
You can also change those settings in Options > Video > Advanced.


sh@@rk posted at 2014-04-05 02:26:15


©2012 FANUP, INC. ALL RIGHTS RESERVED    powered by