TF2 Scripting Tutorial

AciD

Newbie
Joined
Jul 2, 2007
Messages
1,498
Reaction score
2
Welcome to my scripting guide!

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.

After you made/paste all scripts you want, save your config as myconfig.txt than click on file in explorer and change txt to cfg.(You of course can place your own name instead myconfig.

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 .txt 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



Its just assigning commands to keys
Code:
bind "key" "command"
If you want to assign multiple commands divide them by ;
Code:
bind "key" "command; command; command"
1# You want to bind reload to a specified key:
Code:
bind "key" "+reload"
2#You want to bind taunt and explode
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)

1# You want to change sensitivity from one to twenty with 2 points jump.
Code:
bind "key" "incrementvar sensitivity 1 20 2"
2# You want to switch between 3 basic net_graph positions with one click.

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

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.


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.

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"
3# You and your friend are playing at same PC, both of you have diffrent keybindings. There is a easy solution for this!
Code:
alias configsw "yourconfig"
alias yourconfig "exec yourconfig; 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"
Useful scripting command:
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.


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

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

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

Engineer bulidables 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
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 3-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

Those commands can make your game unstable, if you have problems with your game stability, simply remove them

Code:
"mat_queue_mode 2"
"r_threaded_client_shadow_manager 1"
"r_threaded_particles 1"
"r_threaded_renderables 1"
"cl_threaded_bone_setup 1"
"cl_threaded_client_leaf_system 1"
"host_thread_mode 1"
Some additional commands by Omega_K2
 

Para

Newbie
Joined
Jul 19, 2003
Messages
682
Reaction score
0
From all these only the voice menu would "enhance" my gameplay experience if I used those things for anything else than taunting anyway.

*sigh* Guess I'm just too pessimistic...
 

Pesmerga

Newbie
Joined
Dec 31, 2004
Messages
10,092
Reaction score
2
Something I always found useful was this little alias that I made myself...

Tiny Talk
Code:
alias +tinytalk "+voicerecord; volume .05"
alias -tinytalk "-voicerecord; volume 1"

bind q "+tinytalk"
Quiets your game while you talk over the mic, helpful for those with standalone mics and speakers so as to avoid feedback.
 

Hectic Glenn

Site Director
Staff member
Joined
Aug 8, 2004
Messages
12,233
Reaction score
238
I think AciD's guide is great, especially the numpad access to the 'load out' screen. I just played with them working as a pyro. Just by pressing 4 or 1 I could switch between the flamethrower airblasting and the backburner for different attack methods.

It's so much quicker and gets you right back in the fight. Stickied!
 

Hectic Glenn

Site Director
Staff member
Joined
Aug 8, 2004
Messages
12,233
Reaction score
238
I see you've updated the heavy script, cheers.

Another good thing about this guys, when Steam friends goes down, TF2 can't access your achievements so you can't access your unlocks when friends goes down. With AciDs scripts regardless of what happens you can still get to Natascha :D
 

DEATHMASTER

The Freeman
Joined
Aug 3, 2005
Messages
12,759
Reaction score
151
Is there a way to bind text speech? Like press "O" to text "My initials look good carved into your back."
 

Pesmerga

Newbie
Joined
Dec 31, 2004
Messages
10,092
Reaction score
2
bind o "say My initials look good carved into your back."
 

kabo0m

Newbie
Joined
Nov 1, 2008
Messages
6
Reaction score
0
Cześć AciD! I only use Notepad + + when editing my configs as well but didn't know all the direct sounds for TF2. Thanks for posting these! Because of this thread I signed up to this forum.
 

AciD

Newbie
Joined
Jul 2, 2007
Messages
1,498
Reaction score
2
Boom! Equip command was removed in todays update, so loadout binds are not working from now.
 
Joined
Aug 19, 2011
Messages
53
Reaction score
19
cl_drawhud is cheat protected (at least in TF2), that should be noted x)
 
Top