/r/tf2scripthelp
Come here to learn how to write scripts for the game Team Fortress 2. Please don't post anything except content related to scripting. To request scripts, check out r/TF2Scripts.
Lines starting with four spaces are treated like code. You can format your scripts here by highlighting your entire script and pressing tab.
alias +crouchjump "+jump; +duck; spec_mode"
alias -crouchjump "-jump; -duck"
bind space +crouchjump
Reset all binds:
exec config_default
Reset all cvars: steam://runsafe/440
Make sure to read the rules before posting. Read the Rules
If you're new in town, start here.
New to scripts? Ask a question! Ask a question
Script got you stumped? Get help! Get help
Show off your work. Submit a script
If it's 2D and on your screen, it's not a script. Get HUD help
/r/tf2scripthelp
first one to have a button switch between bind the mousewheel to weapon switch and jump:
alias togglemw0 "bind MWHEELDOWN +jump; bind t togglemw1"
alias togglemw1 "bind MWHEELDOWN invnext; bind t togglemw0"
togglemw1
second one to skip the PDA's while playing engineer:
alias shotgun "slot1; bind MWHEELUP wrench; bind MWHEELDOWN pistol" alias pistol "slot2; bind MWHEELUP shotgun; bind MWHEELDOWN wrench" alias wrench "slot3; bind MWHEELUP pistol; bind MWHEELDOWN shotgun" shotgun
both scripts work fine on their own, i just don't know how to combine them well.
Is there any way of organizing the commands of an alias vertically instead of all in one line?
I have a long alias in a config file and looks like this
alias Example "command1; command2; command3; ect......"
I'm wondering if there is a way to write is out more like this
alias example "command1; command2; command3; command4; ect....."
edit: looks like I can't show what I mean here lol. I want every command in the alias to take up one line in the config file. So I won't have to scroll sideways to read the whole thing.
How can I spawn 2 bots to do the square dance taunt with each other?
so im trying to do 2 things:
fix my engineer scrollwheel
get my voiceline script (which lets me just press 3 buttons, then says a voiceline) to show the voicemenu on the first key press
ill start with 1 first;
so currently, i have this in my engineer.cfg
alias shotgun "slot1; bind MWHEELUP wrench; bind MWHEELDOWN pistol"
alias pistol "slot2; bind MWHEELUP shotgun; bind MWHEELDOWN wrench"
alias wrench "slot3; bind MWHEELUP pistol; bind MWHEELDOWN shotgun"
shotgun
and this in my reset.cfg
unbind "MWHEELUP"
unbind "MWHEELDOWN"
bind "MWHEELUP" "invprev"
bind "MWHEELDOWN" "invnext"
i believe i could get this working/working better with trial and error, but i've only managed to get MWHEELDOWN to work on other classes, so i think i have something spelt wrong. if so, could someone tell me what to put instead?
secondly, my voiceline script. im not gonna put it here since it's kinda long, but ill put it i the comments. basically i wanna see the voicemenu when i press either C, V, or B so i know what to press, but im doing something wrong and i don't know what. sorry for the kinda long post/bad grammar (it's 9:40pm as of writing this) but could someone help?
so a while ago, i got a script to only have to press C,V, or B depending on which voicelines wanted from each voiceline menu, but now i want to see the voicemenus when i press one of the buttons.
and that should be quite easy (but i'll take suggestions for how to do it), except since im not choosing one of the options, im just press the buttons, so it will only go away after a couple seconds. ik this isn't that much of an issue, but if anyone knows how to modify the voice menu's timer or make it go away when i say the voiceline, it's be greatly appreciated.
here's the voiceline script for anyone who wants it/wants it for suggestions:
//===========Concise Voicemenu===============
//keys
bind ctrl resetcvm // Change the mouse4 to any key you want to use to reset your key-combination.
bind c vc_0 //first voice menu, z by default
bind v vc_1 //second voice menu, x by default
bind b vc_2 //third voice menu, c by default
//voice menu 0
alias vc_0_0 "voicemenu 0 0;resetcvm"
alias vc_0_1 "voicemenu 0 1;resetcvm"
alias vc_0_2 "voicemenu 0 2;resetcvm"
alias vc_0_3 "voicemenu 0 3;resetcvm"
alias vc_0_4 "voicemenu 0 4;resetcvm"
alias vc_0_5 "voicemenu 0 5;resetcvm"
alias vc_0_6 "voicemenu 0 6;resetcvm"
alias vc_0_7 "voicemenu 0 7;resetcvm"
//voice menu 1
alias vc_1_0 "voicemenu 1 0;resetcvm"
alias vc_1_1 "voicemenu 1 1;resetcvm"
alias vc_1_2 "voicemenu 1 2;resetcvm"
alias vc_1_3 "voicemenu 1 3;resetcvm"
alias vc_1_4 "voicemenu 1 4;resetcvm"
alias vc_1_5 "voicemenu 1 5;resetcvm"
alias vc_1_6 "voicemenu 1 6;resetcvm"
alias vc_1_7 "voicemenu 1 7;resetcvm"
//voice menu 2
alias vc_2_0 "voicemenu 2 0;resetcvm"
alias vc_2_1 "voicemenu 2 1;resetcvm"
alias vc_2_2 "voicemenu 2 2;resetcvm"
alias vc_2_3 "voicemenu 2 3;resetcvm"
alias vc_2_4 "voicemenu 2 4;resetcvm"
alias vc_2_5 "voicemenu 2 5;resetcvm"
alias vc_2_6 "voicemenu 2 6;resetcvm"
alias vc_2_7 "voicemenu 2 7;resetcvm"
//voicemenusubsets
//vc0
alias vc0_02 "alias vc_0 vc_0_0; alias vc_1 vc_0_1; alias vc_2 vc_0_2"
alias vc0_35 "alias vc_0 vc_0_3; alias vc_1 vc_0_4; alias vc_2 vc_0_5"
alias vc0_67 "alias vc_0 vc_0_6; alias vc_1 vc_0_7; alias vc_2"
//vc1
alias vc1_02 "alias vc_0 vc_1_0; alias vc_1 vc_1_1; alias vc_2 vc_1_2"
alias vc1_35 "alias vc_0 vc_1_3; alias vc_1 vc_1_4; alias vc_2 vc_1_5"
alias vc1_67 "alias vc_0 vc_1_6; alias vc_1 vc_1_7; alias vc_2"
//vc2
alias vc2_02 "alias vc_0 vc_2_0; alias vc_1 vc_2_1; alias vc_2 vc_2_2"
alias vc2_35 "alias vc_0 vc_2_3; alias vc_1 vc_2_4; alias vc_2 vc_2_5"
alias vc2_67 "alias vc_0 vc_2_6; alias vc_1 vc_2_7; alias vc_2"
//General Bindings
alias vm0 "alias vc_0 vc0_02; alias vc_1 vc0_35; alias vc_2 vc0_67"
alias vm1 "alias vc_0 vc1_02; alias vc_1 vc1_35; alias vc_2 vc1_67"
alias vm2 "alias vc_0 vc2_02; alias vc_1 vc2_35; alias vc_2 vc2_67"
//initiate
alias initz "vm0; voicemenu 0"
alias initx "vm1; voicemenu 1"
alias initc "vm2; voicemenu 2"
alias resetcvm "alias vc_0 initz; alias vc_1 initx; alias vc_2 initc"
resetcvm
My autoexec right now is very unorganized and some commands don't even work.
mat_specular 0
mat_bumpmap 1
sv_allow_point_servercommand always
cl_mute_all_comms 0
voice_enable 1
fps_max 500
viewmodel_fov 90
tf_use_min_viewmodels 1
bind "KP_END" "join_class scout"
bind "KP_DOWNARROW" "join_class soldier"
bind "KP_PGDN" "join_class pyro"
bind "KP_LEFTARROW" "join_class demoman"
bind "KP_5" "join_class heavyweapons"
bind "KP_RIGHTARROW" "join_class engineer"
bind "KP_HOME" "join_class medic"
bind "KP_UPARROW" "join_class sniper"
bind "KP_PGUP" "join_class spy"
bind k "kill"
bind j "explode"
bind q "+attack3"
tf_use_min_viewmodels 1
cl_cmdrate 66
cl_interp 0
cl_interp_ratio 2
cl_lagcompensation 1
cl_pred_optimize 2
cl_smooth 0
cl_smoothtime 0.01
cl_updaterate 66
rate 60000
hud_combattext_batching 1
cl_enable_text_chat 1
tf_hud_target_id_alpha 255
tf_hud_target_id_offset 0
cl_crosshair_file "crosshair7"
m_customaccel 0
m_customaccel_max 0
m_customaccel_scale 0
m_customaccel_exponent 1
m_forward 1
m_filter 0
m_yaw .022
m_pitch .022
m_side .8
m_mouseaccel1 0
m_mouseaccel2 0
m_mousespeed 0
m_rawinput 1
[I use Mastercoms and have all 9 "class.cfgs" and the "autoexec.cfg" in the //Overides folder]
So I recently learned about scripts and had a ton kf fun customizing viewmodels and binds and all sorts of shit.
However I have a few problems with the current rocket jump script I have. Allow me to elaborate.
I use this script to allow me to rocket jump with the simple push of a button.
| alias +rocketjump "+jump; +duck; wait; +attack"
| alias -rocketjump "-jump; -attack; wait; wait; wait; -duck"
| bind "mouse3" "+rocketjump"
This is where the complications start. Yesterday I would tell you I had no problems and was perfectly fine with this.
Until I realized that, after I swap off Soldier, this bind stays on all the other classes.
Which is a problem considering I want a script for Detonator Jumping on the Pyro. I believe that all the same inputs are necessary, but with an additional input of holding m2 so that the detonator instantly pops after firing, sending me flying farther in my desired direction.
I feared these two binds would conflict with each other, since the Cow Mangler has an m2 input and I use that weapon.
I also want feedback on if I'm using configs with Mastercomms correctly. From what I read when people want to use configs for that the files should be put in the overides folder.
I believe I have thought of a solution to the Pyro Soldier thing, adding an "unbind m3" to the beginning of the script.
So when I begin on Soldier, my rocket jump only uses M1 to fly. But then when I swap to Pyro, m3 is unbound and rebounded to use both keys and then unbounds again whenever I swap to soldier.
Question 1: How can I stop my Rocket Jump Soldier bind from bleeding into the other classes. (possible solution is to add unbind command in beggingging)
Question 2: Need a Detonator jump script (people said you have to hold down both M1 and M2 so that the flare detonates instantly)
Question 3: Clarify how Mastercom interacts with scripts.
Thanks so much, hopefully I'll see yalls comments in the morning.
im sure it has something to do with making a demoman.cfg file, but im not sure exactly what to put in there to make it work. im trying to bind m4 and m5 to +left and +right respectively, any help is appreciated
I’ve been trying to make a resupply bind that doesn’t change my loadout but whenever I press the bind it goes to my first loadout.
Okay so I have my class .cfgs set up like this:
exec reset
[class specific binds]
For example, in reset.cfg
, I have bind g +taunt
. But in sniper.cfg
, I want to use g for quick Huntsman tauntkill attempts, so I have bind g "taunt 0"
For some reason, sometimes I'll be playing Sniper, and then my g button will bring up the taunt menu, as if it were set to +taunt instead of "taunt 0". I have to go into console and exec sniper
to get it to reset.
Same thing happens to Engineer. In reset.cfg
, I have a certain button set to a "Nice shot" voice command bind home "voicemenu 2 6"
. But for Engineer, I have it set to bind home "voicemenu 2 7"
; this is Engineer's "Good job" voice command, which is unusually quiet, so I use this voice command to mask me moving/building stuff. However for some reason sometimes when I'm in the middle of playing Engi it'll change to the "Nice shot" voice command, as if it went to the reset.cfg
, and again I have to go into console and exec engineer
to get it to work again. I do not change class or die, it just seems to happen in the middle of a life. I have exec reset
at the very beginning of my class.cfgs, so it happens before any class specific rebindsm and no other exec
is anywhere else in there.
For clarity this is the entirety of my sniper.cfg
if it helps -
exec reset
sniper_respawn_default
alias item_preset_a "alias sniper_respawn load_itempreset 0;load_itempreset 0"
alias item_preset_b "alias sniper_respawn load_itempreset 1;load_itempreset 1"
alias item_preset_c "alias sniper_respawn load_itempreset 2;load_itempreset 2"
alias item_preset_d "alias sniper_respawn load_itempreset 3;load_itempreset 3"
alias sniper_respawn_default ""
bind g "taunt 0"
bind del sniper_respawn
Has anyone experienced this? Any idea what's up?
I am running Mastercomfig. I have downloaded the templates from here and the templates are in tf/cfg/ where they belong according to that document.
I haven't played TF2 or messed around with scripting for it for quite a long time now so it's possible I've forgotten to do something or used an obsolete script that wouldn't function due to changes with how things are done.
Here is a one of my shorter scripts that is not functioning.
Echo **Running Heavy**
alias +heavy_shoot "slot1; +attack"
alias -heavy_shoot "-attack"
alias +heavy_sandvich "slot2; +attack"
alias -heavy_sandvich "-attack"
alias +heavy_melee "slot3; +attack"
alias -heavy_melee "-attack"
bind mouse1 "+attack"
bind mouse2 "+attack2"
bind mouse3 "+heavy_melee"
bind mwheelup "+heavy_shoot"
bind mwheeldown "+heavy_secondary"
Aside from the bindings not functioning the echo command is not printing Running Heavy* when it should be running the script.
Not only was the script not doing what it should when I switched to playing a different class I was unable to use any of their weapons. I just hit the mouse button to fire and nothing would happen. Am I missing a command that would clear rebound keys between switching classes or something?
Edit: Me being unable to use my weapons may in fact be a problem I was having with the server I was on. It continued to happen even when I deleted all the scripting leaving the scripts blank. Attempting again with exec config_default in the pre-comfig.cfg file and all other scrips blank to see if resetting everything not effected by Mastercomfig fixes it. I doubt Mastercomfig itself is at fault because other than the heavyweapons.cfg not running everything else was working fine.
Edit: I have solved the issue with no longer being able to use my weapons by use of exec config_default. Currently still having the issue of my class.cfg files not seeming to function. Will see what I can do about that later in the day.
Can't join my own server, says "Processing time Exceeded" and doesn't let me join. How can I fix this? Is there a way to change net_chan_limit_msec?
I can't find a tutorial that shows me it with pictures
I am using mastercomfig, and on this 3 year old post from this subreddit it said make the execs in tf/cfg/user
Created a folder named user but it still won't work.
Besides that, will this work? I have some experience from creating autoexecs in csgo, and I want to hide pyro's flames
exec autoexec in every class
Autoexec:
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
r_drawviewmodel 1
Pyro:
exec autoexec
unbind "1"
unbind "2"
unbind "3"
alias "flamethrower" "slot1; r_drawviewmodel 0; viewmodel_fov 1"
alias "flaregun" "slot2; r_drawviewmodel 1; viewmodel_fov 90"
alias "hammer" "slot3; r_drawviewmodel 1; viewmodel_fov 90"
bind "1" "flamethrower"
bind "2" "flaregun"
bind "3" "hammer"
Whenever I hit "q" to do a quickswap, it always defaults to sapper and knife. Is there a way to make quickswap work as intended or at the very least swap from pistol to knife?
This is my spy.cfg.
unbind mouse1
exec config
exec custom
unbind mouse2
bind mouse2 +attack2
bind mwheelup "+jump"
bind mwheeldown "+jump"
hud_combattext_batching_window .5
unbind n
slot3
r_drawviewmodel 1
knife_vm_mode
// replace [KEY] with the your Keybinds for the sapper♥♥♥♥♥♥♥ambassador/watch
bind "2" +equip_sap // Key/button for sapper
bind "3" +equip_knife // Key/button for knife
bind "1" +equip_amby // Key/button for ambassador
bind "mouse2" "+watch;spec_prev" // Key for watch (mouse2 default)
//re-bind mouse1
alias knife_vm_mode "bind mouse1 +viewmodel_knife" // binds mouse1 to turn viewmodel on when attacking (for knife knife)
alias amby_vm_mode "bind mouse1 +viewmodel_amby" // binds mouse1 to turn viewmodel off when attacking (for amby)
alias sap_vm_mode "bind mouse1 +viewmodel_sap" // binds mouse 1 to turn viewmodel on when attacking and off when not (for sapper)
// causes viewmodel to go off or on when you shoot
alias +viewmodel_knife "+attack;r_drawviewmodel 1;spec_next" // attacks, turns viewmodel on
alias -viewmodel_knife "-attack;r_drawviewmodel 1" // finishes atack, turns viewmodel on again as safeguard
alias +viewmodel_amby "+attack;r_drawviewmodel 0;spec_next" // attacks, turns viewmodel off
alias -viewmodel_amby "-attack;r_drawviewmodel 0" // finishes attack, turns viewmodel off again as a safeguard
alias +viewmodel_sap "+attack;r_drawviewmodel 1;spec_next" // shows sapper when sapping
alias -viewmodel_sap "-attack;r_drawviewmodel 0" // hides sapper when mouse1 released
// Equip item, turn vm on/off, set vm toggle for attack
alias +equip_knife "slot3;r_drawviewmodel 1" // Equips knife, turns viewmodels on
alias -equip_knife "knife_vm_mode;r_drawviewmodel 1" // Sets viewmodels to turn ON when stabbing (makes sure it stays on)
alias +equip_amby "slot1" // Equips amby
alias -equip_amby "amby_vm_mode" // Sets viewmodels to turn OFF when shooting
alias +equip_sap "slot2;r_drawviewmodel 1" // Equips sapper, turns viewmodels on
alias -equip_sap "sap_vm_mode" // Sets viewmodels to turn on while firing, and off when not
alias +watch "+attack2;r_drawviewmodel 1" // watch up/cloak on/secondary attack + viewmodels on
alias -watch "-attack2;r_drawviewmodel 1" // viewmodels on again as safeguard
bind Q quickswap
I recently enjoyed playing heavy but my right click kinda broke, probably because i been holding it down too hard but it's not entirely broken and i can still click it but it made heavy unplayable since i can't rev up for long periods, can anyone help me to toggle my mouse2 for heavy so i don't have to hold it down and break my mouse even further?
i recently made a post asking about how to fix my config (which you might be able to find cause GODDAMN this sub moves so slow) which got resolved.
i'll just get to the point, basically the title but im curious what i can/should do with configs. they seem quite helpful, and it could be nice to know my options.
like i already did a script which skips the engineer's (and for some reason also spy's) PDA'S, so that's nice.
i have no idea what im doing but i tried doing what one post said (to create autoexec.cfg, all the class ones, etc, etc...) and once i did that the game would just crash once i picked a class. no error warning or anything else, it just closes. i did have this line of code in every single one of them though:
map_background preload_room; wait 10; disconnect
i do have things in my custom folder that have to do with viewmodels (like horsie's and all of my classes have viewmodel mods.) can anyone help?
I was watching this video and I saw that when he shot out particles from the flame thrower using his mouse button. It changes his fob because it hides the particles and when he releases the button it became normal. How do you get this bind??? The link: https://youtu.be/G7p-NsU9eWw?si=Mve1QVvl3xix-VGP Time stamp: 5:34-5:36
Recently in a casual match, in spawn, I saw this demo execute his primary taunt, then halfway though it, teleport to his side and repeat this over and over again. It was honestly pretty funny and I've been trying to replicate it.
However, I can't seem to get close to the speed that he did it at, which leads me to believe this might be an exploit/external script, does anyone know more about this or know of a way to implement this using the console?
For reference this is what I came up with:
alias taunt_spam ts_start
alias ts_start "alias taunt_spam ts_stop; alias ts ts_loop; ts_loop"
alias ts_stop "alias ts; alias taunt_spam ts_start"
alias ts_loop "taunt; wait 200; join_class random; wait 109; join_class demoman; wait 192; ts"
If the latter two wait commands are used with any lower values, the script starts being inconsistent and some taunts might be skipped (tested on local server). The first wait command needs a value of 200 to cutoff the taunt at the correct time.
i have a config with lots of scripts and aliases and not a single one will work, i put the .cfg files in the cfg directory and .vpks in custom but they never work. it might have something to do with this message i got in the console but im not sure: Steam config directory: D:\steam games\steamapps\common\Team Fortress 2\platform\config
i would greatly appreciate some help
I use a server which has ping kick and i get kicked due to high ping. The server types message in chat that it is my 10th warning before kicking me. I want to be able to execute retry when it detects the particular message about ping kick. It should be possible i think. Any help is appreciated!
sec;prim
bind 1 "-attack2;slot1;sec;prim"
bind 2 "-attack2;sec2;prim2;slot2"
bind 3 "-attack2;sec2;prim2;slot3"
bind mouse4 "-attack;-attack2"
alias toggle "enable"
alias enable "alias toggle disable; +attack2"
alias disable "alias toggle enable; -attack2"
alias ptoggle "penable"
alias penable "alias ptoggle pdisable;+attack"
alias pdisable "alias ptoggle penable;-attack"
alias sec "bind mouse2 toggle"
alias prim "bind mouse1 ptoggle"
alias sec2 "bind mouse2 +attack2"
alias prim2 "bind mouse1 +attack"
I have this script so I can toggle my reving and shooting for heavy.
After the summer update when I press secondary fire the minigun doesn't rev when I click mouse2. The bind for mouse 2 is literally the same and it doesn't work.
is there a way i can make it so when i take out my sapper i can have z,x,c say a custom voicechat line like "tele down push" or something along those lines i saw a vid but it didnt work and i cannot figure it out. but i do have my z,x,c binded to voicelines i just want it to be when i take out my sapper that i can use the team ones that i wrote down myself can anyone help? i am new to tf2
Is there a way to do a script each time you respawn?
I have a rev toggle and when I respawn it automatically revs because I didn't unrev before death and it's really annoying.
alias toggle "enable"
alias enable "alias toggle disable; +attack2"
alias disable "alias toggle enable; -attack2"
alias ptoggle "penable"
alias penable "alias ptoggle pdisable; +attack"
alias pdisable "alias ptoggle penable; -attack"
alias b bind mouse1 ptoggle
alias d bind mouse2 toggle
alias c bind mouse1 +attack
alias e bind mouse2 +attack2
alias f bind mouse2 "+attack2"
b;d
bind 1 "slot1;b;d"
bind 2 "slot2;c;f"
bind 3 "slot3;c;e"
How do I make so after throwing a lunchbox item it uses the slot specific bind?
alias autoalt "startalt"
alias startalt "+attack2;alias autoalt stopalt"
alias stopalt "-attack2;alias autoalt startalt"
bind mouse2 "autoalt"
This is script is supposed to make so I can toggle reving up.
But instead I can only rev up but not unrev.
Idk why.
I want a single button to toggle voice_enable, and for it to correctly post in my console that VC is either ON or OFF.
Is there a way to do that?
i have this medic specific script
alias Uber_Ready "say_team Ze Uber is zeady my friend; voicemenu 1 7"
bind t Uber_Ready
to bind uber ready in chat with the uber charged voiceline but now after i switch to medic it also stay binded for all the other class. Is there a way to make this script specifically only for the medic?