CS Buy Binds (CS:S) – Weapon And Scripting
CS Binds - How to make buy binds
Before you start trying to make CS buy bind, you will need to know the basics of scripting in CS:S, this basically means the use of the commands "alias" and "bind". You may think you know about the bind command already, and even used it, but you probably don't know about the use of + and - in binds, it can be confusing (Or just hard to remember) at first, but I'll try to explain it as best as possible.
Alias is used to group a bunch of commands together so you can execute them all at once instead of typing them out one at a time, this is the same kind of thing as a function in programming, but without parameters and return values. You can use an alias like any other command, and bind it to any key, and creating one can even overwrite source commands such as "quit" (You can try this if you want, but not recommended. Type "alias quit" into console and you can't get out!). The syntax for creating an alias is below:
alias <Alias Name> "<Commands to execute>"
The parts in angled brackets are the parts you have to change, the name is the string (text) that you want to type into console to execute the commands in the alias. You can have as many commands as you want in the commands to execute section, but they must be separated by a semi-colon ( ; ). A good example of an alias is a buy alias:
alias ak47 "buy weapon_ak47"
Now everytime you type ak47 into your console (assuming this is in your config file) source will run the command "buy weapon_ak47" therefore buying you an AK-47.
CS Binds are fairly simple and are similar to aliases in a way. The syntax for key binds is:
bind <key> "<Commands to execute>"
Where key is a key from the keyboard. An example is shown below, linking with the alias in the previous example.
bind F1 "ak47"
This will execute the alias we created (ak47) every time you press the F1 key.
I will now explain to you some of the advanced options available with scripting, alternatively you can just skip ahead to the last section if you just want to create your buy binds already! The 2 concepts I am going to explain now are the use of + and - in aliases and binds, and using aliases to change the bind for themselves.
+ and -
+ basically means when the key is pressed and - means when the key is lifted. This can be extremely useful at times, for example I use this for my buy config to switch from counter-terrorist weapons to terrorist weapons by just holding down alt. Lets get started. We need to create 2 aliases, with exactly the same name but one with + infront of it and the other with -. Then you can type whatever commands you want. Now that you have the 2 aliases setup to bind the one to the key being pressed and the other to it being lifted is very simple, you just bind the key to the first alias you made (+something). An example is shown below.
alias +keyDown "impulse 100"; alias -keyDown "impulse 100"; bind p +keyDown;
Try copying and pasting that script into your console, then create a server and press p a few times to see what happens.
NOTE: You cannot use + and - commands in console or in the same alias without using waits, and servers can block them (Match servers do). If you do type a + command in console (like +attack) make sure you enter the appropriate - (-attack)
Aliases to change the bind for themselves
This has the same effect as the + and -, but instead of the 2nd command executing when you release the key, it executes the next time you press the key. This is pretty straightforward, just a concept that you should understand if you understood everything I've said so far. Here is the example:
alias +method1 "+attack"; alias -method1 "-attack;bind mouse1 +method2;"; alias +method2 "+reload"; alias -method2 "-reload;bind mouse1 +method1;"; bind mouse1 "+method1"
As you can see, everytime you release mouse1 the bind changes to the other alias so that you shoot then reload then shoot then reload etc.
The CS key binds, finally...
To make this easier, just copy and paste the following into your config:
alias galil "buy galil;";alias ak47 "buy ak47;";alias scout "buy scout;";alias sg552 "buy sg552;";alias awp "buy awp;";alias g3sg1 "buy g3sg1;";alias famas "buy famas;";alias m4a1 "buy m4a1;";alias aug "buy aug;";alias sg550 "buy sg550;";alias glock "buy glock;";alias usp "buy usp;";alias p228 "buy p228;";alias deagle "buy deagle;";alias elite "buy elite;";alias fiveseven "buy fiveseven;";alias m3 "buy m3;";alias xm1014 "buy xm1014;";alias mac10 "buy mac10;";alias tmp "buy tmp;";alias mp5navy "buy mp5navy;";alias ump45 "buy ump45;";alias p90 "buy p90;";alias m249 "buy m249;";alias primammo "buy primammo;";alias secammo "buy secammo;";alias vest "buy vest;";alias vesthelm "buy vesthelm;";alias flashbang "buy flashbang;";alias hegrenade "buy hegrenade;";alias smokegrenade "buy smokegrenade;" ;alias nvgs "buy nvgs;";alias defuser "buy defuser;"
This basically makes aliases for each of the weapons, just so you don't have to type in "buy" everytime. Below is the list of commands you can now use:
- galil; (Defender)
- sg552; (Krieg)
- g3sg1; (Terrorist auto sniper)
- famas; (Clarion)
- aug; (Bullpup)
- sg550; (Counter-terrorist auto sniper)
- m3; (Shotty)
- xm1014; (Auto shotty)
- vest; (Kevlar)
- vesthelm; (Kevlar and Helmet)
- nvgs; (Nightvision)
So now, to make F1 buy an M4, you can do this:
bind F1 "m4a1;"
My CSS buy config is shown below, what I usually do at the start of the round is buy my gun then just F2 and F3 (they are probably my dirtiest keys)
- My buy config
alias "fone" "m4a1; primammo;";
alias "ftwo" "primammo; vesthelm; vest; defuser; secammo; defuser;";
alias "fthree" "flashbang; hegrenade; flashbang; smokegrenade;";
alias "ffour" "awp; primammo;";
alias "ffive" "deagle; secammo;";
alias "fsix" "mp5navy; primammo;";
alias "fseven" "scout; primammo;";
alias "feight" "flashbang; flashbang; secammo; defuser;";
alias "fonealt" "ak47; primammo;";
alias +wep "bind F1 fonealt; bind F2 rebuy;";
alias -wep "bind F1 fone;bind F2 ftwo;bind F3 fthree;bind F4 ffour;bind F5 ffive;bind F6 fsix;bind F7 fseven;bind F8 feight;bind F9 defuser;";
bind ALT +wep;
Another bit of fun to do with weapon binds is what I call a glocksplosion, create a server with $16000 starting money and try this bind:
alias gs "use weapon_glock;drop;buy glock;"; alias glocksplosion "gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs; gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs;gs; gs;gs;gs;gs;gs;gs;gs;say gLoCkSpLoSiOn!!!"; bind p "glocksplosion";
Press P, then watch...
If you find anything that you find is confusing or could be improved please leave a comment and I'll try and change it accordingly
Also I might make a site where you can dynamically create your keybinds pretty soon, check here for any updates.