Counter-Strike Introduction to Scripting  

Posted in , ,

--



Introduction to Scripting

This is quite a hard subject to get into, so just follow it through. It`s easy to understand and makes sense. Introducing you to the world of scripting and it's uses.

The point of scripting is to make things easier for yourself by using just one key to do more than one thing; of course this isn't the only reason, but I think it is the main one. Imagine this situation: you've just lost the previous round, you only have a pistol, the enemy have all their best weapons and you need to get all your weapons, ammo, grenades and armour. If you were to use the buy menu, this would take more than your alloted time, thus you would be wasting valuable round time. This is where the scripts come in, one button press, and it buys ALL of these, simple eh? This is why people script, or use other people's scripts to help them in the game. Although the Buy Script is not the only usage for scripts, I think it is the most commonly used, other common scripts include the Plant C4 Script, Jump/Crouch Script and Grenade Scripts. These are just common examples, obviously there are more, but when you've read through this, hopefully you'll be able to make your own scripts with a litte imagination.

What is a Bind?

A bind is something Counter-Strike or Half-Life uses to give an action to a key. It 'binds' the 'key' to the 'action'. Here is an example:


bind "SPACE" "+jump"
"SPACE" is the 'Key', this is the key we press to perform the action. "+jump" is the action performed when we press the key. 'bind' is the command we use to bind the key to the action, we need to put this infront of the key and action so that Counter-Strike knows what we are trying to do.

What is an Alias?

An 'alias' is something to make it simpler to use a group of commands, you simply put all the commands you want in the 'alias' and just call that one alias, making it much easier. Here is what an alias would look like with multiple commands:


alias aliasname "command1; command2; command3"
If you look at the above alias, it is set out in much the same way as a bind - the 'alias' command infront of the whole thing, then the name of the alias followed by the actions or commands you want to be performed. Using aliases, you can bunch lots of commands into one alias, making it easier to call that alias, here is an example:


alias buymp5 "buy; menuselect 3; menuselect 1"
'buymp5' is the name of the alias, if we were to type 'buymp5' into console it would execute the commands in the second section of the alias. For this example, this would buy an MP5. If you notice, the commands are separated by a semi-colon and a space. The semi-colons tell Counter-Strike that there is a new command starting. You don't have to put a space after the semi-colon, some people don't, it's entirely up to you. I like to put spaces because it makes it easier to read if you have any problems with the alias. To bind a key to an alias it follows the same technique as in the 'What is a Bind?' section of this guide.

If, for example you wanted to buy an MP5, Full Ammo and Full Armour, you would have to write the aliases separately for each of them first, then collect them all in a new alias.


alias buymp5 "buy; menuselect 3; menuselect 1"
alias buyammo "buy; menuselect 6"
alias buyarmour "buy; menuselect 8; menuselect 2"

alias buyallstuff "buymp5; buyammo; buyarmour"
If you follow that through, the first three aliases set themselves up to buy an MP5, Ammo and Amrour respectively. The 4th alias buys them all together by calling all the original aliases and grouping them together, remember - they are separated by a semi-colon.

What is a Script?

A script is a collection of binds and aliases that work together to form a package e.g. A 'Buy Script' would include lots of aliases and binds that would enable you to buy all the weapons available for example.

The Files

In Half-Life and Counter-Strike there are 2 main files that are used in scripting, these are the 'config.cfg' and 'autoexec.cfg'. You may have noticed these 2 files inside your Counter-Strike directory before, Show you how to use them and what they do.

Config.cfg

This is automatically created by the game, this is the file with all your setup controls in. If you load up CS --> Config. --> Controls then you will be met with a list of commands, and next to them what you want to press to execute that commands. All this information is kept inside the 'config.cfg' file along with all your preferences and settings. Here is an example of the 'config.cfg':


bind "w" "+forward"
bind "x" "radio2"
bind "y" "messagemode"
Only put your binds in here, aliases will go in a different file. To add binds to this file, read the second section 'What is a Bind' and simply copy the end result into this file.

Autoexec.cfg

You may need to create this file yourself. Do this by opening up a new .txt file and save it as a .cfg file e.g. for the filename when you save, put filename.cfg. this file is executed automatically after the config.cfg when you start to play. This is the file where you should put all your 'aliases' and command to execute other .cfg files.

Other .cfg Files

Sometimes if you have downloaded, say a Buy Script for example, it won't come in the form of an 'autoexec.cfg' file. It will more likely come in it's own .cfg file. This makes it easier to search through your work, by putting separate things in separate files. For example, you could have all your Taunts/Comments in one file, and your Buy Script in another. These files will NOT be executed automatically by Half-Life/Counter-Strike, they will need to be executed by you. There are 2 ways to do this:
  1. Go into your game, open console and type in - "exec filename.cfg" without the qoutes.
  2. Or, open up your 'autoexec.cfg' and type in - "exec filename.cfg" without the quotes.
With the first method, you will need to type it everytime you go on a new map, and start a new game. If you put it in your 'autoexec.cfg' it will automatically execute it for you every time you play.


Things You Need To Know



If you made it through all that, this should be easy. Here are some commands and useful information for you when you decide to start scripting, or are looking at any script examples:

Console - Where all commands are typed into, to use the console press the tilde key '~' underneath the 'ESC' key. If your console does not work, open up your 'config.cfg' and find the line that says 'console 0.00000' or something similar, and change the '0.00000' to '1'. Then, right click on your Counter-Strike Shortcut on your desktop, where it says 'Target' add onto the end -console. A scripting command to add on the end of this is '-zone 4096', this will allocate more memory for files used with Half-Life, recommend adding this.

Menuselect # - This is a command used mainly in Buy Scripts. When you open your buy menu in Counter-Strike, you notice all the options with a number next to them, you use this command followed by the number of those menu's to access them automatically. So to open the First Menu, you would put 'menuselect 1'.

Wait - A command used to put a space between commands in an alias.

exec - The command used to execute other scripts, usage; 'exec filename.cfg'

Bind - Command used to bind a command to a key, read up for more information.

Alias - Used to make using multiple commands easier, read up for more information.

Slot # - Used to open up the chosen weapon slot, for example 'slot 1' would open up the pistol slot on the main HUD.

weapon_ - Used to bring out the specified weapon. Weapon names:
  • Pistols - glock18/usp/deagle/p228/elite
  • Submachineguns - mp5navy/p90/tmp/mac10
  • Assault Rifles - ak47/sg552/m4a1/aug
  • Shotguns - m3/xm1014
  • Sniper Rifles - scout/awp/g3sg1
  • Machinegun - m249
  • Grenades - flashbang/hegrenade/smokegrenade
  • Other - c4/knife
say - Used to say a mesage to everyone on the server.

say_team - Used to say a message to teammates only.



--

0 comments

Visitors

Counter