So, you're an engineer sitting inside your base, and all of the sudden you see a spy! You want to call out to your team with the voice commands to let them know, "That Pyro's a Spy!", but those extra few seconds you spend fumbling with your keyboard give the spy enough time to sap your stuff and kill you.
One way to help this sort of situation is to use what are called binds to assign keys to common in-game actions. For me, if I ever see a Spy, I hit my thumb button on my mouse (I have 2, we'll get to that), which is bound like this:
bind "MOUSE4" "voicemenu 2 0"
This will activate the voicemenu, selecting the third menu, and the first item in that menu. Note that these numbers are not typos, but instead start counting from 0.
Anyway, let's get into it.
In short, enabling the console. This is something very simple, yet easily overlooked. To enable the console, from the main menu:
Options -> Keyboard -> Advanced -> Enable Developer Console
After you've done this, you can now open up the console by pressing tilde (` or ~ to the left of the 1 on your keyboard). All commands you'll see here need to be done in the console or in the configuration files - do not type them in chat or you'll be laughed out of the server.
Binding can be defined as simply assigning a key to an action. The general format of a bind is:
bind
Where
A few more examples are:
bind p "say Visit the Deadly Pandas website at www.deadlypandas.com !"
bind MWHEELDOWN "+jump"
The first bind will say the above text in the public chat. If you want to do teamchat, do say_team instead of say. Some of these useful commands can be learned by looking at your config.cfg, which we'll get to in the Configuration Files section.
The second bind will set your mousewheel to make your character jump when you scroll it down. This is obviously not something everyone would want, but useful for some (for instance, I don't use mousewheel for changing weapons, so I use that for jump). Another cool thing about this is that you can have multiple keys doing the same command. Without using binds you wouldn't be able to set, say SPACE and MWHEELDOWN to jump.
NOTE: The jump command isn't simply a one-shot command! The plus "+" in front of it denotes that it is a two-state command. The + state is used when the command is activated, and the - state is used when the command is deactivated. So, when you press your left mouse button (bind MOUSE1 "+attack"), you start attacking, and it doesn't stop until you release your mouse button (which when executes -attack).
Here's another example - this one executes multiple commands:
bind MWHEELDOWN "+jump; say Visit the Deadly Pandas website at www.deadlypandas.com !"
As you can likely tell, this will make your mousewheeldown cause you to jump and shamelessly advertise to everyone on the server as you jump. To use multiple commands with one bind, just use a semicolon ";" between each command.
The alias command is used to give names to an action or a series of actions. The general format of an alias is:
alias "
So, I can do exactly what I did above, except making things a bit easier on the binding process:
alias "advertise" "+jump; say Visit the Deadly Pandas website at www.deadlypandas.com !"
bind MWHEELDOWN "advertise"
This will do the same thing, except in a bit of a cleaner fashion. Let's get into a real use for aliases...a script a friend wanted - something that will quickly switch to your knife or other melee weapon and stab an enemy:
alias "+stab" "slot3; +attack; wait; -attack; wait; +attack"
alias "-stab" "-attack; wait; lastinv"
bind MOUSE3 "+stab"
This script will execute the "+stab" command when you middle click with your mouse, and then the "-stab" command when you release your mouse button. The "+stab" command will change to your melee weapon (slot3), attack (select the weapon, in this case - like clicking after rolling your mousewheel), wait for a moment, stop attacking, wait for a moment, and then begin swinging your weapon.
Located (for me) in C:\Program Files\Steam\steamapps\sarcius\team fortress 2\tf\cfg
or,
For these games (Source-based games) the config file(s) should be in the same general location.
These are text files containing all of your settings (see config.cfg) and binds. As a rule, I always back up my config.cfg before I manually make any changes to it, as you can mess things up pretty bad and have to reconfigure all of your settings!
Team Fortress 2 is special, as it has a config file for each class. Whenever you switch to that class, the config file is loaded up. So, you could potentially have completely different controls for each of the classes. Some things you might want to tweak per class may include chat binds, sensitivity, or other useful binds. Be aware that when you swap from a class, those binds will still be in effect for your next class, unless you rebind the buttons in the new class's config, or do something like execute config.cfg to reset your configurations.
Using the alias example above, I'm going to modify my spy and engineer to change to their melee weapon and attack when I middle click (I wouldn't recommend doing this with MOUSE2 (right click), because right click is used for a lot of things, like spy cloak, and engineer sentry rotate).
- Open the spy.cfg and engineer.cfg with Wordpad (should use Wordpad instead of Notepad).
- Copy the lines above, or write your own
- Save, and you're done with those.
BEWARE: By default, TF2 uses MOUSE2 (right click) for "+attack2", which is for detonating stickies, spooling up the heavy's minigun, ubercharging as medic, zooming as sniper, etc! If you bind this to MOUSE2 instead of MOUSE3, go into each of those config files for the previously mentioned classes and put:
bind MOUSE2 "+attack2"
See this page for more detailed information: http://tf2wiki.net/wiki/Scripting