An Introduction to Scripting

Hello, and welcome to my introduction to Scripting! This is quite a hard subject to get into, so just bear with me and follow it through. I hope it is easy to understand and makes sense. I'm going to start by 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, I am going to 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, I know which one I use ;)

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, I 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:

say - Used to say a mesage to everyone on the server.

say_team - Used to say a message to teammates only.

So concludes this tutorial, I hope you enjoyed reading it, and any queries/comments can be emailed here.

Comments

D.Turpin
02:14 19/12/2001
Nice and clear .. cheers [ Comment: Report | IP: Logged ]
AznMAtrix
01:41 24/12/2001
Yeah nice... I actually understood it the first time I read it [ Comment: Report | IP: Logged ]
Chris
21:44 4/1/2002
Great Guide!! I know how to get the console working now. And to write scripts YIPEEE!!!! [ Comment: Report | IP: Logged ]
TwonkyOverkill
12:22 10/1/2002
REALLY amazing guide!!! very simply put and incredibly easy to understand! Thank you scripting San! [ Comment: Report | IP: Logged ]
MuDgE
20:15 10/1/2002
Thankyou for the nice comments ;)

I'm glad this guide helped you, any feedback is appreciated ;D [ Comment: Report | IP: Logged ]
KraZieFoo
01:51 1/3/2002
didnt really read it all but thanks for fixing my console =) [ Comment: Report | IP: Logged ]
André
19:05 13/6/2002
..well written, easy to understand...it helped me to fix some things...thx a lot! [ Comment: Report | IP: Logged ]
[DK]Blackdog
11:47 27/6/2002
wow, nice guide understood it first time. I will practice it then 8) [ Comment: Report | IP: Logged ]
=RC=Immortalize
22:54 15/7/2002
I must say, this is very nice, understood it perfectly, and now I can figure out how to do a lot of the stuff I've been trying to figure out how to do, like buy commands and such.
Thnx [ Comment: Report | IP: Logged ]
[FEAR] =Snerk=
12:55 16/7/2002
thx m8y!! very easy to understand!! [ Comment: Report | IP: Logged ]
-*sephirot**
14:44 20/8/2002
you explained it very well but i still don't know a few things like you have the commands impulse 201 for spraying something. i gues there are still more of those things. like weapon_knife: this selects your knife.
i'm became pro to scripting.

[-P-]*sephirot [ Comment: Report | IP: Logged ]
@lvo ThE F@g!*
13:15 7/10/2002
HEY! thanks mate! i got the idea but even i changed the problem, my CONSOLE still doesn't f***ing come OUT!!!!!!! [ Comment: Report | IP: Logged ]
Mr. Wiskers
20:19 8/10/2002
excellent tutorial...thanks [ Comment: Report | IP: Logged ]
holle_inDaHouse
18:18 8/11/2002
Really good, short and spicy!
...nitty-gritty... [ Comment: Report | IP: Logged ]
hampster
16:47 17/11/2002
how do you fix that a message in swowen i console when you exec the script... ex...

---== Buy script loaded ==--- [ Comment: Report | IP: Logged ]
61indM3lon
03:14 7/12/2002
do you know how to emulate key presses in the game? more specifically this is for the command menu where entering slot1 and menuselect1 dont work. ive tried 1, +1 but i cant seem to get the menus to navigate. laterz. [ Comment: Report | IP: Logged ]
Woody
19:52 7/12/2002
cant i go somewhwere and DOWNLOAd this buyscript?
im lazy so ya... [ Comment: Report | IP: Logged ]
-=FRAGLESS MONKEY=-
02:12 17/12/2002
Thanks man! that helps a lot [ Comment: Report | IP: Logged ]
hiryu
13:25 22/12/2002
every time i get flashed it lastfor around 10 to 12 seconds it never used to be that long how can i change any help would be really cool [ Comment: Report | IP: Logged ]
E|em@n
13:07 2/1/2003
that depends on the server normally as some make the flashes last for ages. [ Comment: Report | IP: Logged ]
DannY
18:06 22/1/2003
thanks for the help but only thing is that the buy menu pops up wen i do this but it buys the weapon....i put bind , "buy; menuselect 3; menuselect 1; menuselect 0" i thought that this would turn off the buy menu but it stays up and also i see ppl that announce the gun the have...what do i attatch to the alias?...

Thanks [ Comment: Report | IP: Logged ]
unknown
14:22 18/3/2003
Im having the same problem as like a previous posted forum. I binded my keys but after it works my buy menu still stays up. Ive tried menuselct 0....or 0 in general. Nothing gets the buy menu off....please help. Email me back at unathrizd@hotmail.com. Thanks!!! [ Comment: Report | IP: Logged ]
confusled
05:39 26/3/2003
what file do I put aliases in? autoexec.cfg?? [ Comment: Report | IP: Logged ]
Bubba
22:35 23/4/2003
to close the menu its slot10

to add a say command type

;say then what ever [ Comment: Report | IP: Logged ]
Shafted
18:04 26/4/2003
Hey Im just curious, So i can go into the game and just start typing the aliasses?? I really just wanted the Grenade script, but since i saw I can buy everything I want w/ one simple touch... I have to have that too... Just curious tho if it takes anything special to get them working, or if I can just get into the game and start typing them.... Thank!!! ~ [ Comment: Report | IP: Logged ]
MCHammereD
14:05 6/5/2003
very, interesting, i myself am a fairly new CS player, and dont understant this scripting s**t properly, but your article has made me start thinking, and for that you haqve my thanks. [ Comment: Report | IP: Logged ]
[Smoker]-=Bl@ckB!rd=
13:55 10/8/2003
GOT MY BINDS WORKING NOW THNX 2 U :D all the dutch sites R crappy @ this :) gonna smoke a blunt in honnor of U man ...... happy csing [ Comment: Report | IP: Logged ]
~|Fl@m3_7hRoWeR_009|
09:37 9/11/2003
Gr8 tut man!!!!! Newbz only though! UkTerrorist is the best CS Guide website! Keep it up... [ Comment: Report | IP: Logged ]
nijsdude
21:20 27/1/2004
i never tried scripting myself i just downloaded scripts
now i can make my own
tnx dude [ Comment: Report | IP: Logged ]
Lord DarkGame
18:23 11/2/2004
Nicely written mate, dont think it could have been explained better than that [ Comment: Report | IP: Logged ]
r3c^
17:32 19/3/2004
top quality, i'm a full time nub and aint got time fer long confusing articels, ur is succint and clear. joo rock :D ty [ Comment: Report | IP: Logged ]
OLO
07:10 20/3/2004
i cant believe how easy this is.. i knew nothing literaly nothing about binding or scripting until i read this. whoever wrote this ..thanks it was real clear and i understood every bit of it. [ Comment: Report | IP: Logged ]
Add comment

Menu

News
Features
Events
Site
Search UKT:

User



Register here

Shoutbox

Zechs_
*sniff*
04:40 3/9/2008

X
JESUS CHRIST ITS A LION
23:33 27/8/2008

`NWA
lol @ this shoutbox going stron 2 years after the last news item was posted.
02:22 27/8/2008

w1ckedz
I wrote that Culexus comment Myers hahahaha
21:32 25/8/2008

tiz
Stealing is terrible I know! Some ****er even had the cheek to put it on ebay... [ [ expand ]