(wL) Forums

Full Version: Binds & Scripts (Easy Mode)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
So here it is! Another thread to add to my AUTOEXEC thread series! What's the topic this time? BINDS!!!

Lets just get straight into it, shall we? NOTE : Yes I did post this as a reply in a previous thread, but I felt I should expand a little on the topic. There is new information here that I haven't previously said, so give it another read if you want to know some things and stuff and things and stuff and things and stuff and......


HOW DO I SHOT BINDS?!?!?!?!?!?


Using the scripting language provided in most Source games, you can bind pretty much any command to any key. The format usually works like this :

Code:
bind "key" "action"

You'll type this in console, or you can add it to your autoexec file (located in C:/Program Files/Steam/steamapps/OneTakeThomson/counterstrikesource/cstrike/cfg, where "OneTakeThomson" is your account name. For non Steam users, this would be in Counter Strike Source/cstrike/cfg). If you don't know what an autoexec file is, you can find out about it in the extensive thread I wrote here. That thread tells you how to create one, where to store it, and just the basic commands you can use in it. There is also another thread that is linked on there, which gives extensive client side cvars to tweak your graphics.

WHAT DO I DO NEXT?!?!?!?!

So now you have your autoexec open, and you want some binds. If you were clever, you'd have a binds section in your autoexec, like I have in that thread. There are a few ways you can use binds :

- Generally just binding one key to do one action. You already have several binds, you just wouldn't realise it. Pressing W to go forward is a bind. Pressing Y to text chat is a bind. There is an action behind each key, and by writing a tiny line of code, you can set any key on the keyboard to do any action in game.

- You can bind one key to do several actions. This is called a "script". The script will run when you press the key that is bound to it. For example, I have this "toggle chat" bind key, so that when I press Caps Lock once, it starts to transmit voice on my mic, and when I press it again, it turns it off.

- You can also bind values to increase/decrease by increment. Usually you'd just have one key, and pressing this key would cycle through several functions that you've set. One I can think of is if you wanted to have your cmdrate to cycle through, depending if you visit different servers. Pressing the key once would set it to 33, once again would set it to 66, and once more to 100.


Now with just those 3 types of binds, you can do quite a bit. Lets start with buying.


BUY BINDS

Using The Binds Built In To The Buy Window

So we all know that it's a long task buying things when you spawn in CS:S. There are 4 binds you can use through the games buy window. You buy the equipment you need, then click on which preset you want it to be saved to, so when you're in the buy window you can just press S, D, F or G.

For example, I have all 4 of mine set up like this :

- Pressing "S" in the buy menu will buy me - deagle, kevlar and helmet and a defuse kit
- Pressing "D" in the buy menu will buy me the previous, plus an M4/AK (depending on which team)
- Pressing "F" in the buy menu will buy me the "S" bind, plus a Scout
- Pressing "G" in the buy menu will buy me the "S" bind, plus an Awp.

Now the reason I have it set like this is because my "S" bind is my primary loadout. I have always played with these piece of equipment as soon as I could afford it. I'd usually use this buy bind on the 2nd or 3rd round of a scrim, and then buy an MP5 (b 3 2). Since I already know the mp5 code, there is no need for me to bind it. I can add any primary weapon that I'd usually use because I know the bind codes, and be ready to leave spawn in 2 seconds because the bulk of the equipment is bought with that 1 bind. So I could either press "b s", or press "b 1 4, b 6 2, b 6 6". You tell me which is easier Tongue

Along with remembering certain combinations to buy other weapons (such as B 2 1 for Pump Shotgun, B 1 5 for Dual Elites on T side, B 3 1 for TMP on CT side), you can effectively cut down the time it takes to buy your kit to just a few seconds. Whilst everyone else is clicking (lol) the weapons that they want, you're already out of spawn and getting frags! There is no need to use this in your autoexec, it's configurable straight from the buy window. If you want to configure this, I suggest creating your own server on your machine, going in and just sorting it out from there.

THATS NOOB! SHOW ME THE REAL CODES!!!
How To Bind Using Autoexec

So if you dont want to use the Source buy window binds, then that's fair enough. You're limited to just 4 preset loadouts, so I wouldn't blame you if you wanted a bit more. What I'd suggest is using your keypad, binding a load of weapons to that. The keypad is pretty much useless (I use it for taunts), so it would make sense to just load it up with buy binds, right? You can also use arrow keys, the 6 above the arrows (Home, Insert etc), the "useless keys" (like []';#/,.), pretty much any key that isn't already used.


So lets say, you want to bind the key "P" to buy you a deagle. You'd open up your autoexec, and  make a new section marked "Binds" :

Code:
\\Binds//

Once you have that at the top, you know that everything below that is related to binds. That way you won't end up with a messy autoexec (I have seen some terrible ones). So then you'd type :

Code:
\\Binds//

bind "p" "buy deagle"  //Buys Night Hawk

That's literally it. I put the "//Buys Night Hawk" at the end because using "//" at the end of any line of script in your autoexec will stop console reading anything passed that point (only on that line though). It's just so you can make notes in your autoexec that you don't want console to try and load. It's helpful if you have a line of command that you might forget what it does.

So let me load you up with my keypad template, and I'll throw in a few weapon binds :

Code:
\\Binds//

////Numberpad (0-9)


bind "kp_ins" "buy deagle"   //0 - Buys Night Hawk
bind "kp_end" "buy ak47"   //1 - Buys CV-47
bind "kp_downarrow" "buy m4a1"  //2 - Buys M4 Carbine
bind "kp_pgdn" "buy awp"   //3 - Buys Magnum Sniper Rifle
bind "kp_leftarrow" "buy flashbang"    //4 - Buys Flashbang
bind "kp_5" "buy hegrenade "    //5 - Buys HE Grenade
bind "kp_rightarrow" "buy smokegrenade"   //6 - Buys Smoke Grenade
bind "kp_home" "buy defuser"    //7 - Buys Defuse Kit
bind "kp_uparrow" "buy vesthelm"    //8 - Buys Helmet & Kevlar
bind "kp_pgup" "buy m3"    //9 - Buys Pump Shotgun

That's just the only weapons I could think that I would need binded, plus all the grenades and defuse kit. So now you have all your binds, and they're all in your autoexec. All you do now is save the autoexec, and they'll be ready to use next time you play CS:S. Simples!

Feel free to use that template and replace any of the weapon names with weapons that you would like to have bound to your keyboard. Here is a list of all the weapons in game :

Code:
galil (Defender)
ak47
scout
sg552 (Terrorist bullpup)
awp
g3sg1 (Terrorist auto sniper)
famas (Clarion)
m4a1
aug; (Bullpup)
sg550 (Counter Terrorist auto sniper)
glock
usp
p228
deagle
elite
fiveseven
m3 (Pump Shotty)
xm1014 (Auto shotty)
mac10
tmp
mp5navy
ump
p90
m249
vest (Kevlar)
vesthelm (Kevlar and Helmet)
flashbang
hegrenade
smokegrenade
nvgs (Nightvision)
defuser

Using that list and the template I provided you with, you will be able to bind any combination of purchases to your keypad, and make some use of that useless part of the keyboard!

What Else Can You Bind?

Well if you want to be specific, that's pretty much it for basic binds. There isn't much to bind that you'd use in your normal gameplay. The only other thing I can think of is scripts. So let's say that you don't want to use your entire keypad to load up all these binds, or you can think of several other loadouts that you'd like. Well, you can write a quick script to purchase these loadouts for you. I'm going to go into some very basic scripting here, but I will make my next thread (or the one after) about more of the scripts that you can write in CS:S. Okay, here it goes......


Alias Commands And You!

In Source scripting, there is a very handy command called "alias". It basically lets you set several values under one name. It's hard to explain, so I will just show you. Lets say that you want to buy my primary loadout, which is a Deagle, K&H and a Defuse Kit. You could set it out like this :

Code:
alias loadout1 "buy deagle;buy vesthelm;buy defuser"

That means that in that script, whenever you use the term "loadout1", you'll actually be executing the commands within the quote marks. If you wanted that bound to a key, you'd then go like this :

Code:
alias loadout1 "buy deagle;buy vesthelm;buy defuser"
bind "kp_end" "loadout1"

So now, that alias (and therefore the buy bind) is now bound to 1 on the keypad. I'd probably have it a little neater myself, something like :

Code:
////Buys Primary Loadout (1 On Keypad)
alias loadout1 "buy deagle;buy vesthelm;buy defuser"
bind "kp_end" "loadout1"

So then I could have my other loadouts underneath, and it would be all organised. I'll show you an example now :

Code:
//Loadout Binds\\

////Buys Primary Loadout (1 On Keypad)
alias loadout1 "buy deagle; buy vesthelm; buy defuser"
bind "kp_end" "loadout1"

////Buys M4A1 Loadout (2 On Keypad)
alias loadout2 "buy m4a1; buy deagle; buy vesthelm; buy defuser"
bind "kp_downarrow" "loadout2"

////Buys Scout Loadout (3 On Keypad)
alias loadout3 "buy scout; buy deagle; buy vesthelm; buy defuser"
bind "kp_pgdn" "loadout3"

////Buys AWP Loadout (4 On Keypad)
alias loadout4 "buy awp; buy deagle; buy vesthelm; buy defuser"
bind "kp_leftarrow" "loadout4"

So that's my Counter Terrorist loadouts that I mentioned earlier, just bound to the keypad. It's pretty easy to understand. You can use these as a template, just make sure that you change the "alias" for multiple binds. If you set every alias to be "loadout1", then you'd end up buying a lot of gear >.< What you call the alias really doesn't matter, but generally the shorter the better, because you might end up typing a lot of stuff Tongue If you have any questions about this kind of script, feel free to ask, I'll attempt to answer any questions.

I'll edit this thread and include a link to my next thread about scripting. It will use this "alias" feature as a basic foundation, but I'll be showing you some other stuff that you can do with it Tongue


Thanks for reading, comments and questions are welcome below Big Grin
Re: Binds And Binds And Binds And Binds!

bade
Re: Binds And Binds And Binds And Binds!

Mawped Wrote:bade

Code:
alias mawpedsucks "say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade"
bind "mouse1" "mawpedsucks"
Re: Binds And Binds And Binds And Binds!

I, The Rival Wrote:
Mawped Wrote:bade

Code:
alias mawpedsucks "say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade; say mawpedisbade"
bind "mouse1" "mawpedsucks"

k
Still bade
Re: Binds And Binds And Binds And Binds!

nice job Rival!!!! i will try some binds because I never used binds before  :o
Re: Binds And Binds And Binds And Binds!

so how do I bind weapons again?









waiting for the rage. ;D

Edit: Anyway seriously, I think you could add binds of using weapons, in addition of buying them.
Re: Binds And Binds And Binds And Binds!

Spartacus Wrote:Edit: Anyway seriously, I think you could add binds of using weapons, in addition of buying them.

Well yeah, I can do that. Can you give me a scenario where you'd want a script written for that? Most of the little teachings I do revolve around situations where it would make it easier for you by using a certain autoexec tweak Smile I think the one I have seen the most is people wanting a quickswitch to knife, but that's as easy as mapping the 3rd inventory slot button to something easier to reach.
Re: Binds And Binds And Binds And Binds!

I, The Rival Wrote:
Spartacus Wrote:Edit: Anyway seriously, I think you could add binds of using weapons, in addition of buying them.

Well yeah, I can do that. Can you give me a scenario where you'd want a script written for that? Most of the little teachings I do revolve around situations where it would make it easier for you by using a certain autoexec tweak Smile I think the one I have seen the most is people wanting a quickswitch to knife, but that's as easy as mapping the 3rd inventory slot button to something easier to reach.

PM'ed.
Re: Binds And Binds And Binds And Binds!

TLBig GrinR

lol j/k

I'll read it when I get a chance. Thanks for the research and sharing.
Re: Binds And Binds And Binds And Binds!

JayCat Wrote:TLBig GrinR

lol j/k

I'll read it when I get a chance. Thanks for the research and sharing.

Haha Big Grin Probably not worth reading unless maybe you want to know some basic stuff about binding/scripting in CS:S Tongue I have already started writing my next thread on a few more script commands.
Pages: 1 2