/r/Tf2Scripts
Come here for all your TF2 scripting needs. Please don't post anything except content associated with scripting.
For readability,
please format scripts and snippets.
Begin each line with 4 spaces
Bulk formatting:
If you need more help, reply directly to the response comments, not a general reply.
We have a tutorial on the wiki! Check it out if you want a primer on Source commands.
Reset all binds: exec config_default
Reset all cvars: steam://runsafe/440
Make sure to read the rules before posting. Read the Rules
New to scripts? Script got you stumped? Start here.
If it's 2D and on your screen, it's not a script.
Can't remember the name of that command? Want to know if something is possible?
Can't find something previously requsted?
Show off your work. Tools are also welcome.
Found a new command/cvar? Want feedback or opinions? Discuss!
/r/Tf2Scripts
I made these crosshairs that im using as "indicators" for my engineer script so you know what building you chose from the scrollwheel, they work just fine in my own custom match but there missing textures in casual, also they disappear from the crosshair picker https://youtu.be/smMUCCFhoVk video to demistrate what im talking about, does anyone know how i can build 5 custom crosshairs into a hud, then switch them using a script so it works in casual?
Hello, I wonder if you can help me write a script to put in my autoexec file please?
Requirements:
mouse5 equips the weapon in slot1
mouse4 equips the weapon in slot3
When mouse5 and mouse4 are pressed simultaneously, the weapon in slot2 is equipped.
Any help appreciated
Trying to have some varied sensitivities between both weapons and classes. I'm a crusty little spy main sorry people and I need more knife sens for those surf stabs. Here's what I have in all my class cfgs
bind "MOUSE5" "slot1; sensitivity 0.85; r_drawviewmodel 0"
bind "e" "slot2; sensitivity 0.85; r_drawviewmodel 1"
bind "c" "slot3; sensitivity 1; r_drawviewmodel 1"
How do I make that work with
bind "q" "lastinv"
I mostly use q to switch weapons, but occasionally I use my normal binds (mouse5, e, c, and 4). For people wondering why it's so weird, it's so I can moving or autosap etc without letting go of wasd.
Also, I have a great dmg_sound randomizer script if people want that for fun.
Thanks!
This is the pyro script to remove viewmodels for primary, but not for secondary and melee. I am using Mastercomfig!!
//Start of Script
exec reset
bind 1 eq_slot1
bind 2 eq_slot2
bind 3 eq_slot3
alias set_slot1 "viewmodel_fov 1"
alias set_slot2 "viewmodel_fov 90"
alias set_slot3 "viewmodel_fov 90"
alias eq_slot1 "slot1; set_slot1; alias eq_invnext eq_slot2; alias eq_invprev eq_slot3; qs_slot1; alias set_lastinv alias eq_lastinv eq_slot1; alias qs_slot1 ; alias qs_slot2 set_lastinv; alias qs_slot3 set_lastinv"
alias eq_slot2 "slot2; set_slot2; alias eq_invnext eq_slot3; alias eq_invprev eq_slot1; qs_slot2; alias set_lastinv alias eq_lastinv eq_slot2; alias qs_slot1 set_lastinv; alias qs_slot2 ; alias qs_slot3 set_lastinv"
alias eq_slot3 "slot3; set_slot3; alias eq_invnext eq_slot1; alias eq_invprev eq_slot2; qs_slot3; alias set_lastinv alias eq_lastinv eq_slot3; alias qs_slot1 set_lastinv; alias qs_slot2 set_lastinv; alias qs_slot3"
eq_slot1
alias eq_lastinv eq_slot2
r_drawviewmodel 1
//End of script
However, not only does this mean that for every other class when I equip my primary there are no viewmodels, it also means that my binds for equipping slot 1, 2, 3 etc don't work until I pick pyro.
How do I make it so this script only applies to Pyro, and furthermore I can switch slots on other classes before picking Pyro?
Me and u/-oOAegisOo- were coming up with different iterations of what has most recently become this script, and during the course of playtesting I expiremented with something akin to-
bind "4" "slot4;bind T Die;lastdisguise"
(disclaimer: Can't recall if that was the exact code)
-and for a moment it actually worked on a random-arse casual server. While disguised as engineer, my disguise took out its PDA and was holding it while I had my cigarrete case up.
The problem I bumped into shortly afterward was that pressing 4 while disguised as a pyro caused the disguise kit to come up and immedietely close, with my disguise reverting to its melee weapon. After that happened, I couldn't get it to work on engineer again, even after restarting the game multiple times now. The only thing I can think of that's different is the server was originally empty when I first tested the slot4;lastdisguise code, then some people joined, I swapped to pyro for a sec to get some nuisance off our spawn and after that it's never functioned again. Might be connected, might not, idk enough spaghetti to riddle this one out. All I know is I'd like to pretend I'm about to build something as an engineer when I'm really up to no good.
Could someone that can make vtf files (crosshairs) put the following text next to the provided crosshair?
5 in total
i have this engineer script that lets me select the building on the scroll wheel and i was wondering if it was possible to make custom text appear next to the cursor
Hi I enjoy playing TF2 on a controller. But Valve force controller players to use building menu from xbox 360.
Can I bind build and destroy buildings to F1 F2 F3 and F4 keys? If so it would be possible to bind these 4 commands into controller.
So I looked online for scripts doing just that. it seems that the scripts I've found so far only works for when I switch weapons via number keys, and I don't. I use the mouse wheel to cycle through weapons. If this is even possible at all, please let me know if you have solutions. Thank you
For example i want to use the dot crosshair or "crooshair 5" on sniper but i want to use the default on on scout
Do vscripts count as tf2 scripts? Hopefully I'm in the right subreddit.
I'm making a custom map, and would like a hitscan gun that shoots perfectly accurately with a high fire-rate. I tried addcond 91 sniper rifle as well as addcond 96 kleaner's carbine, but the former is still too slow and the latter still too inaccurate.
Since I'm making the map I can mess with the netprops, so I have been attempting to manually shoot the sniper rifle faster than the game normally lets me. I have been somewhat successful with the following:
...
NetProps.SetPropFloat(weapon, "m_flNextPrimaryAttack", 0)
weapon.PrimaryAttack()
...
...but the issue is when I break the fire-rate floor using the above code, it kind of breaks all of the sniper animations - the sniper no longer has muzzle flash, a shooting animation, a gunfire sound (there's some slight clicking noise still), no bullet trace and no bullethole at the impact location. Triggering a resupply locker fixes the issue.
I suppose if the resupply locker restores everything, I could try to just, destroy my gun and then re-equip a new one after shooting it? Maybe that'll fix the animations, but that sounds pretty scuffed. Then again, everything I'm doing is already pretty damn scuffed.
Anybody know how I can trigger all of the animations and sound effects via script when I shoot? I've been looking through the developer wiki and also the source code leak back from 2020 but I'm without a lead I'm wandering around in the dark.
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.
USING MASTERCONFIG LOW
Followed the steam guide to get the custom main menu music and it’s not working and a could videos related to it and still nothing https://steamcommunity.com/sharedfiles/filedetails/?id=1511463814
I remember it working pre x64 when I did it following the guide and wanted to do it again to save my updated config to my google drive so I don’t have to tweak everything a thousand times when I switch my OS
Troubleshooting I did
I have them in the proper format and size 192kbs 44100hz .mp3
They are In my custom as /custom/menumusic/sound/ui/gamestartup1.mp3 All the way to 32 just like the guide says attempted to move them to the base /tf folder
Took everything out of custom accept music and nothing plays
Looked for posts like this all seemed to be unanswered or got it working and never explained how they did
(Edit just came up with an idea as to why it could not be working relating to my preloading script for custom animations will test this tomorrow since the music will stop playing if you happen to boot a map and go back to the menu)
I was on a valve server and when i typed the fix weaponspread command It didnt work and a message popped up (you can see It under the image), someone know how to fix It?
This script is supposed to switch weapons and fire when pressing the appropriate mouse button. However when I tried to use it last night it seemed to do nothing. The echo command also did not print
**Running Heavy**
as it should have. I am running mastercomfig. All class config files are in tf/cfg/overrides which is where I understand they belong. The script is written as follows:
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"
Original source is Gamebanana, the echo command added by myself to make sure the script is actually running.
Yes the script lacks exec reset. Mastercomfig has a game_overrides.cfg that runs before every class config where I have placed the exec reset command to run my reset.cfg
I also posted about this on r/tf2scripthelp/ but have not gotten much help there as of yet.
I missed the old days of people having a chat bind for when they get a kill. Anyone remember "Meatshot"?
So I made one
When I decided to make one initially, it was just for soldier. It would cycle through 11 soldier inspired insults on the same key, T
During my testing, another gamer said "I wonder what he says when he dies", and so I decided to make a set of death lines, bound on the right alt key.
I then wondered if I could make a set of lines for engineer but also have those on T
I haven't made the lines yet, which is the only thing missing from this script excluding the 'cycle-script' that goes with the lines, but I ended up preparing it for every class. There's an empty setup for Scout though which can be copy pasted and then edited a little.
I needed a way to switch between the classes, at first I thought to just write whatever class-set you wanted to use in console, 'scout', 'soldier' and so on, which would just switch it.
But that wasn't super user-friendly, so I added numpad keybinds, but I don't have a numpad, so it wasn't useful for me, and therefore I needed a third method, which ended up turning my x key into both voice_menu 2, but also the class changer, inspired by u/DeltaEks
Just a little bit of fun, I hope you liked the little script, and that some of you might find some fun in this as well.
i need some help, so, i have a medic scrip what says "uber used, push now" when i uber, but when i use the vax, i dont want it to spam, so i was wondering if theres a way to toggle my medic ubercharge script?
current settings
in game sens 1.00
software dpi 1400
ratio 4:3
in game res 1280 x 1024
using masterconfig w/flat mouse addon
hello all, i recently attempted to configure my game again to make a new tf2 customization folder for my google drive the last thing on my list was changing my zoom_sensitivity_ratio to be a more accurate 1:1 to zoom_sensitivity_ratio_mouse 0.818933027098955175 unscoped for my sniper however it seems that maybe this command has changed names as i get an error in the game that the command does not exist however i was able to input it as zoom_sensitivity_ratio 0.818933027098955175 but i don't feel a difference and it is not 1:1 just like how the default of zoom_sensitivity_ratio_mouse 1 isnt 1:1 i have also tried zoom_sensitivity_ratio 0.793471413188092
followed these guides through discussion on https://www.teamfortress.tv/35467/on-the-correct-value-of-zoom-sensitivity-ratio
https://www.reddit.com/r/GlobalOffensive/comments/43urd4/why_0818933027098955175_is_the_best_zoom/
Every time I try launching into my tf2 server, it says processing time exceeded..how can I fix this?
I'm not sure if it is possible but I'm looking to bind my left, down and right arrow keys to change my binds for demoman, hybridknight and demoknight loadouts. I have some basic binds for demoman but for demoknight i want to bind q and e to turn left/right, i then want to undo it for hybrid and full demo, also instead of lastinv i have set slot switches between slot1 and slot2 but for hybrid i want to change that to slot1 and slot3. If this is at all possible i would be very grateful. I've been messing around a bit with this code, but it doesn't work.
I watched a video on how to change my fov and viewmodle fov but now there's nothing on my screen but the hud I can still shoot and use items but I can't see my arms or the gun is there a way to reset my settings I'm ther command console or am I screwed im not to tech savvy
Recently started a dedicated server for me and my friends. I have a server.cfg in my cfg file aswell as source mod and meta mod, which also states I'm admin of the sever. However, when I join my sever with my rcon password, it says "bad rcon password" and doesn't let me do any commands. The server also says "Server.cfg not found:Not executing". Any help on how I can use commands and how to get server.cfg and rcon to work
I already has a script for senrty at 1, dispenser at 2, tele in and out in 3 and 4. But what is the command for the extra mini sentry engineer can build in mvm? I would like to put that at 5 button.
I use mastercomfig and have been delving into class configs lately to change up my binds. The biggest switches for me are when playing demoknight and so I’ve made a bind in my demoman config that allows me to toggle the use of a demoknight.cfg file. What I would really rather have is the ability to switch between a demoman and demoknight class cfg on the fly, which would allow me to change to net_hitscan settings (as per mastercomfigs network aliases) because the way I have it right now I’m stuck with projectile network settings on a hitscan subclass. As far as I am aware it is not possible to change network settings mid game, as you can only bypass the necessity to enter spectate mode when doing so via class configs. Mastercomfig has a section https://docs.comfig.app/latest/customization/custom_configs/#optional-aliases that explains the possibility of multiple same-class configs but it’s gone over my head to be honest. Any help is greatly appreciated, cheers
I can't find a tutorial
(PLEASE USE PICTURES)
(I don't exactly know how binds work, but I'm lazy, so I came here.) I have a backup set of binds for spy to disguise as each different class on the opposite team, but I'm wondering if it's possible to make a key to toggle my team and the opposite? This is what I have.
bind "KP_HOME" "disguise 1 -1"
bind "KP_UPARROW" "disguise 2 -1"
bind "KP_UP" "disguise 3 -1"
bind "KP_LEFTARROW" "disguise 4 -1"
bind "KP_5" "disguise 5 -1"
bind "KP_RIGHTARROW" "disguise 6 -1"
bind "KP_END" "disguise 7 -1"
bind "KP_DOWNARROW" "disguise 8 -1"
bind "KP_PGDN" "disguise 9 -1"
I'm completely new to scripting and I was wondering how to script the detonator so that right mouse click does a JUMP + CROUCH + FIRE + SELF DET. Since this bind would completely change the button to self detonate, I want to be able to change the SELF DET to left mouse click as well. So both the left mouse button is the button responsible for Primary Fire and Self Detonating, the self detonate will occur only after I have pressed the left mouse button a second time when the primary fire has already been pressed
I want it to work with the stabby stabby viewmodel script.
For reference
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
I want it to work on a -input without auto-firing after. The zooming and firing can be separate or together, I don't have a preference but it would be nice to have both.
so i was watching some theory-y to get a better hang of med, and i notice he said something about a bind where q was bound to swap to fire res, pop, and switch back to bullet (when on bullet), and e for explosion res bubbles, and it was something he could switch on and off when/if he was using vax. i wanted to replicate this (so q would switch to fire res, pop a bubble, and switch back to bullet extremely fast, and e for blast res).