Portal Review

8 User(s) Online





 Counter-Strike Scripting

By Garmer

Part one: What are bindings & aliases

Most of the 3D shooters today give you the opportunity to use socalled bindings. A binding makes you able to do something, with a key of your choice. An example:

bind a "say Hello"

In the game you will say "Hello" when pressing the A key. It's nice but not something amazing...yet. This is where the aliases come in. An alias sets a number of instructions to a name of your choice. One binding in itself can't do much but if you combine an alias with a binding, the possibilities are almost endless. Lets say i'm playing Counter-Strike as a terrorist. The round begins and this is what i buy: AK47, 3x ammo, Kevlar Vest + Helmet, a HE grenade. This would take me some time to buy especially if i'm not sure what buynumber the stuff have. This could cost important seconds.
One alias & binding will make you able to buy all this, by hitting one key!

The alias:

alias ak47 "buy; menuselect 4; menuselect 1; buyammo1; buyammo1; buyammo1; buy; menuselect 8; menuselect 2; buy; menuselect 8; menuselect 4"

The binding:

bind n ak47

What i do is create an alias named ak47. Take a look an try to figure out what it does. The "buy" command brings up the buy menu. "menuselect 4" chooses the rifle menu. And "menuselect 1" buys the AK47. The rest of the alias is the same concept. Then there's only left to bind a key to the alias name - in this case ak47.
You might notice the menu stays on screen when using the script, so we need a function to close it down. A second alias can do it:

alias clrmenu "wait; wait; wait; slot10; wait; wait; wait; wait; wait; slot10; slot10; slot10; wait; slot10"

The "slot10" is the command which closes the menu, but due to possible lag/delay on the internet it's a good idea to add some "wait" in between. Now all you have to do is add your new "clrmenu" alias to the buyscript:

alias ak47 "buy; menuselect 4; menuselect 1; buyammo1; buyammo1; buyammo1; buy; menuselect 8; menuselect 2; buy; menuselect 8; menuselect 4; clrmenu"

  


Part two: The CFG files

If you look in your cstrike directory you should see these two files:
config.cfg and autoexec.cfg. The config.cfg contains your Half-Life settings + your key bindings, and autoexec.cfg is where you can put various commands and aliases. Make sure you have a BACKUP of them, before you start messing around. If you don't have an autoexec.cfg you can simply create one yourself.

Usually autoexec.cfg is initialized when CS loads. If it doesn't add this line to your config.cfg:

exec autoexec.cfg

So...let's finish the example above. This is what you put in autoexec.cfg

alias ak47 "buy; menuselect 4; menuselect 1; buyammo1; buyammo1; buyammo1; buy; menuselect 8; menuselect 2; buy; menuselect 8; menuselect 4; clrmenu"

And this should be in config.cfg

bind "x" "ak47" - where x is a key of your choice.

It's possible the key you choose is already binded, so make sure it's nothing important.


config.cfg example


Next --> Part three: Using + and - in aliases
Copyright 2001 - 2014 Spilzonen.dk - code & design by Garmer