Forums

Pages: [1]
Author Topic: Binding keys.  (Read 1390 times)
img  rush
Guest
It saddens me to post something like this, because it isn't very hard to do, or to understand, but it seems it's needed.

This is pretty much standard on games that utilize a console, and here's how to do it.

bind <key> <command>

That's it, very simple, yes? No? Further explanation? Fine...

bind means to bind a command to a key so you would replace <key> and <command> with real stuff, and you don't need to add in the < and >.
So now we have:
bind space +jump

Which means every time you use space bar it will jump, and this is the basics of binding keys.

   
Maggot
**

Posts: 8
Washed Up Nobody
Allow me to supplement this with a little bit.

First things first:

So, you want to bind a key, but there isn't an spot for it in the options?

How do we go around doing something like that?



Not exactly the most complicated task, but it does require a little insight.

Here is a quick, 3 step (more or less), program to having more bound buttons:



Step 1: The Console

The first step is to make sure you can even access the most important part to this tutorial, the console.

Hit the ~ key to open the console.  If nothing happens, you need to "Enable [the] Developer Console."

This image should get you on your way.  (From top to bottom.)





Step 2: The Console II

Now that that's out of the way, you'll only have to do Step 2 and 3 whenever you wish to bind something.

Pretty spiffy.

Now, hit the ~ key to open up the console.  If you did Step 1 right, you should have something that looks like this.





Step 3: The Binding

Now that you have the console open you're ready to be a big boy.

The way you bind something would be: bind key command

Bind is the command that set's whatever you want to whatever key you chose.  Very straight forward. (You will always type bind when setting your keys)
Key is the key that you wish to bind.  You can set this to any key that you want, even mouse buttons!
Command is the action you wish to happen whenever you press your button of choice.  Some of those would be: +jump, kill, or chooseteam

Let's say that I want to bind control to duck.  I would type something like this:





Once you're committed, hit enter and you're good to go (if you typed in everything correctly).

How does it feel to be a big boy?


                                                   


Some other examples of common binds would include:

bind key +conc :This is for CrancK's Concussion Grenade plugin being used on the Jump iT server.  I use mouse2.



(I can create a TL;DR version for use in the server / lazies if needed.)
   
Maggot
***

Posts: 10
Hmm, I would get in the habit of adding quotations around the command.

While you guys are on binds, might as well delve further into aliases, scripts, and perhaps editing the configuration files for a customized setup.
« Last Edit: December 26, 2010, 10:03:01 PM by cownaetion »
   
Maggot
**

Posts: 8
Washed Up Nobody
Hmm, I would get in the habit of adding quotations around the command.

While you guys are on binds, might as well delve further into aliases, scripts, and perhaps editing the configuration files for a customized setup.

The quotes start helping once you start getting into "advanced" console usage, so I left them out for the time being.  I'll get around to covering everything like that eventually, it's just a matter of what people would like to see first.
   
Offline  Kap
Maggot
*

DERP
Posts: 42
How to get started
To actually write somewhat complex scripts by yourself you have to create a config in your cfg folder which you can find here:
Code: [Select]
Steam\steamapps\YourAccountName\team fortress 2\tf\cfgNormally you should have an "autoexec.cfg" in this folder. If you dont, create a normal textfile and just change the extension to .cfg (Do NOT edit the config.cfg).
You should write all your scripts into this file, as everything in there will be executed everytime you start TF2.

Aliases
Aliases just combine multiple commands into a single command. Example:
Code: [Select]
alias fovb "viewmodel_fov 75;sensitivity 3"
bind <key> fovb  // If you press your designated key your viewmodel FOV will change to 75 and your sensitivity will change to 3

Of course you can also nest aliases:
Code: [Select]
alias rushs "say rush sucks"
alias fovb "viewmodel_fov 75;sensitivity 3;rushs"
bind <key> fovb  // Same as above plus you will tell the truth everytime you press your key!

Toggles
Toggles are quite useful as they just use up one key and you can switch between multiple "phases" of, for example, your FOV. They're quite easy to create as they're only a chain of aliases. This is the structure of a toggle:
Code: [Select]
alias start "option1" // set the starting point of your toggle
alias option1 "command1;command2;alias start option2" // change the starting alias to the second option
alias option2 "command3;command4;alias start option3" // change the starting alias to the third option
// [...] do this as often as you want until your last option, theres a little change
alias option9 "command5;command6;alias start option1" // change the starting alias to the first option again, so your toggle loops through your command list
bind <key> start  // bind your designated key to the starting alias. Everytime you press this key the toggle will go to your next option

Specific example:
Code: [Select]
alias fovtg "vmodels"
alias vmodels  "viewmodel_fov 54;viewmodel_fov_demo 54;alias fovtg vmodelb"
alias vmodelb  "viewmodel_fov 75;viewmodel_fov_demo 75;alias fovtg vmodels"
bind uparrow "fovtg"
// Sorry, couldn't think of a more creative example :(
This toggle will switch your viewmodel FOV between the values 54 and 75 each time you press your key. (Source Keylist: http://imgur.com/tFE9M.jpg)

Theres also a built-in command for a toggle that switches between the values 0 and 1 on keypress:
Code: [Select]
Syntax:
BindToggle <key> <cvar>
Example:
BindToggle h volume  // On keypress you dis- or enable your sound

Incrementvar
Another quite nifty command is "incrementvar". Syntax:
Code: [Select]
bind <key> "incrementvar cvar MinimumValue MaximumValue Delta"
Each time you press your key, your designated cvar will increase by the given delta, starting from minimum value specified going up to the given maximum value. When it reached the maximum value it will start at the minimum value again (-> Infinite Loop).
Example:
Code: [Select]
bind <key> "incrementvar volume 0 1 0.1" // Each time you press your key your volume will increase by 0.1, starting from 0 going up to 1
« Last Edit: December 27, 2010, 11:10:10 AM by Kap »
   
Offline  dellort
Rocketeer
****

Video Maker Extraordinaire
Posts: 294
Some useful scripts/binds:

Crouch Jump Script:

alias "+jumpeh" "+jump; +duck"
alias "-jumpeh" "-duck; -jump"
bind "space" "+jumpeh"

Movement Script (when pressing two opposite movement keys they no longer negate each other, instead the most recently pressed key overrides the other):

bind w +mfwd
bind s +mback
bind a +mleft
bind d +mright

alias +mfwd "-back;+forward;alias checkfwd +forward"
alias +mback "-forward;+back;alias checkback +back"
alias +mleft "-moveright;+moveleft;alias checkleft +moveleft"
alias +mright "-moveleft;+moveright;alias checkright +moveright"
alias -mfwd "-forward;checkback;alias checkfwd none"
alias -mback "-back;checkfwd;alias checkback none"
alias -mleft "-moveleft;checkright;alias checkleft none"
alias -mright "-moveright;checkleft;alias checkright none"
alias checkfwd none
alias checkback none
alias checkleft none
alias checkright none
alias none ""

Net_graph Toggle:

bindtoggle "v" "net_graph"

Just some popular scripts I've found, I know crouch jump scripts are frowned upon but remember you can't effectively duck tap while using one. :p
   
0 Members and 1 Guest are viewing this topic.
Pages: [1]
« previous next »


spirit Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC