In this tutorial i will teach you about binds and scripting CS 1.6
Binding commands to keysThe first building block of CS scripting - the bind command, used to assign actions to keys or mouse buttons. The syntax is:
bind <key> <command or alias>.
Example:
bind shift "walk"
This command in the console ( open console with "~" ) will make it so that the command Walk is assigned to your shift key.
Example2:
Bind F "weapon_knife"
This command creates a quick draw key to the F key so you just have to press F to access your knife.
Example3:
bind "KP_END" "m4a1; ak47"
This speeds up the buying process to ensure that you just have to press one button for a m4 or ak, whichever one is available
for your team.
Creating an aliasAn "alias" is simply a name you choose for a command or set of commands. You assign commands to an alias with the syntax alias <alias_name> <command1; command2...>. An alias with a + sign in front is run when the key is pressed down, whereas a - sign means it's run when the key is released.
Example:
alias setname "name Peter#iDkB"
bind g setname
This will execute "name Peter#iDkB" when you hit g.
This really only becomes useful when you start stringing together commands.
alias waitlong "wait; wait; wait; wait; wait; wait; wait; wait"
alias +throwHE "weapon_hegrenade; waitlong; +attack"
alias -throwHE "-attack"
bind "1" "+throwHE"
Buy joining together all the needed commands, this script carries out all the steps needed to select and throw an HE grenade, on one key press.
Below is a slightly more complicated script to illustrate the idea - you can automate the whole bomb-planting sequence, and immediately have a gun ready as soon as you let go of the key (handy if you get caught by a CT while planting):
alias waitlong "wait; wait; wait; wait; wait; wait; wait; wait"
alias qwpn "weapon_galil; weapon_ak47; weapon_scout; weapon_sg552; weapon_awp; weapon_g3sg1;
weapon_famas; weapon_m4a1; weapon_aug; weapon_sg550; weapon_m3; weapon_xm1014;
weapon_mac10; weapon_tmp; weapon_mp5navy; weapon_ump45; weapon_p90; weapon_m249"
alias +plantbomb "weapon_c4; wait; +duck; waitlong; +attack"
alias -plantbomb "-duck; -attack; qwpn"
bind z +plantbomb
Line one strings together a few "wait" commands to make a longer pause (you may need to experiment with different lengths to get this working for you). Line 2 declares a crude-but-reliable quick weapon switch alias. Lines 4 and 5 declare the commands to run when the key is pressed down and released - in this case, the +attack and -attack commands simulate pressing and releasing the mouse button to plant the bomb.
Script LocationFor Counter-strike 1.6, scripts must be saved in the root cstrike directory, with the extension .cfg - eg: C:\Steam\SteamApps\user_name\counter-strike\cstrike.
There should be at least two config files there already, config.cfg and userconfig.cfg.
Don't use config.cfg for your own scripts, it is likely to be overwritten by the game if you change your settings in the options menu.
Userconfig.cfg is the preferred location for user scripts - it is never automatically modified, and should be executed at every map change (if it isn't, check config.cfg contains the line "exec userconfig.cfg"
You will likely want to put some smaller scripts in their own files, which you can give any name so long as they have the .cfg extension. This is especially useful for creating binds that include spaces and double quotes, which would fail if you simply aliased them.
More Example CommandsBuy commands:
Pistols:
buy glock (9x19mm Sidearm)
buy usp (KM .45 Tactical)
buy p228 (228 Compact)
buy deagle (Night Hawk .50C)
buy elite (.40 Dual Elites) buy fiveseven (ES Five-Seven)
Shotguns:
buy m3 (Leone 12 Gauge Super)
buy xm1014 (Leone YG1265 Auto Shotgun)
SMG's:
buy mac10 (Ingram MAC-10)
buy tmp (Schmidt Machine Pistol)
buy mp5navy (KM Sub-Machine Gun)
buy ump45 (KM UMP45)
buy p90 (ES C90)
Rifles:
buy galil (IDF Defender)
buy ak47 (CV-47)
buy sg550 (Krieg 550 Commando)
buy famas (Clarion 5.56)
buy m4a1 (Maverick M4A1 Carbine)
buy aug (Bullpup)
buy scout (Schmidt Scout)
buy sg552 (Krieg 552)
buy awp (Magnum Sniper Rifle)
buy g3sg1 (D3/AU1)
Machine Guns:
buy m249 (M249)
Equipment:
buy primammo (Primary Ammo)
buy secammo (Secondary Ammo)
buy vest (Kevlar)
buy vesthelm (Kevlar+Helmet)
buy flashbang (Flashbang)
buy hegrenade (HE Grenade)
buy smokegrenade (Smoke Grenade)
buy nvgs (Nightvision)
buy defuser (Defusal Kit)
Binding to the Keypad:These keys are not used in the default key binds, and (assuming you use WSAD for movement) are free to be bound to other commands. They are all located on the numpad, to the right hand side of a standard keyboard.
KP_INS (the 0 key)
KP_DEL (the decimal point)
KP_ENTER (the Enter key)
KP_PLUS (the Plus key)
KP_END (the 1 key)
KP_DOWNARROW (the 2 key)
KP_PGDN (the 3 key)
KP_LEFTARROW (the 4 key)
KP_5 (the 5 key)
KP_RIGHTARROW (the 6 key)
KP_HOME (the 7 key)
KP_UPARROW (the 8 key)
KP_PGUP (the 9 key)
KP_SLASH (the / key on the numpad)
* (the * key on the numpad)
KP_MINUS (the - key on the numpad)