cs madness logo

Monday, June 15, 2009

How to make a script (Super tutorial) :)

Hi Folks! :D
Welcome to Cs Madness guide for the ultimate knowledge of the basics to give you teh uber start to your scripting career for teh Counter-Strike 1.6 game...

have been scripting since CS1.3(NO JOKE, that game didn't even have the sv_restart command!!) and created many original scripts, only few of which can be seen on my submissions page in me profile. This tut will give you the edge over other scripters, a strong base to start off your scripting. By the time you are done reading this tut, you will have complete understanding of scripts in your head; what scripts are? How to use them efficiently? All questions will be answered in the following. This tut is written for the absolute noob and may be boring for vets, so please bear with me or better yet just read the damn tut, maybe you will find something that you don't know!

Okay, here we go!

First you should know..What is a script?

Remember MS-DOS? It also had .bat(batch programs) files, they were basically simple text files with a different extension, they contained a bunch of commands which, upon execution of the .bat file, were carried out simultaneously. Scripts have exactly the same concept!
A script merely is a combination of commands/settings that makes it easier for the users and save them lot of time.

Here is an example of a script, opened in notepad,

Config [+/-]

cs scriptsScripts perform various things from buying multiple items with one button, changing different settings and simplifying in-game actions, so you can spend less time pressing buttons and more time owning your opponents.In Counter-Strike 1.6, scripts are majorly written in NotePad or any other text editor, and are saved in .cfg or .rc formats respectively. (FEW PEOPLE KNOW ABOUT TEH .RC FILES THOUGH!)

How do scripts work?

Scripts are stored in the config files that Counter-Strike1.6 can execute. The only file that we need is the file that we created earlier in this tutorial,


There is a file called valve.rc that automatically executes a few configs files by default every time you load Counter-Strike1.6, such as autoexec.cfg, userconfig.cfg, violence.cfg, etc.

Within autoexec.cfg aliases are stored. An alias is a name given to your custom command that can associate a number of actions or settings when the key bound to that alias is pressed. We will get to it in detail later.

Within userconfig.cfg are your custom binds and your custom commands/settings. This is the config file that is mainly used for scripts.

NOTE: All config files are executed by the game console only!

Learning the language[+/-]

In this part, I will teach you the "language" of scripting, it's nothing major like ANOTHER language, it's the basic techniques used in scripting; such as the alias command mentioned above.
First things first, you now must know how to execute a config file in-game, its fairly simple, while in-game open up the console and type "exec AnyName.cfg", the script/commands within the specified file will be executed immediately.

Now for the "alias" shyt, an example here will certainly clear your head, we will start with something REALLY simple, a script that restarts a round by pressing a key.
Open your AnyName.cfg and type the following code into it:

alias rr "sv_restartround 1"

The alias sets the name of the script to the name that follows.
Which means that the command "sv_restartround 1" can also be executed by just writing "rr". Pretty neat, eh?.
In layman's term, "sv_restartround 1" is the command which is now associated with our alias "rr" that will be executed when we hit the bound key.

Now open userconfig.cfg and enter the following

bind p rr

The bind tells CS1.6 to bind a key to a command.
Now, P is the key we are binding our alias to, "rr" is the name of the alias we defined before and that we are binding to the 'P' key.

If we go into the game at this point and execute the AnyName.cfg file, pressing the P key would restart the round in a key press!

Syntax: alias [nickname] [command]

And secondly, you must know that to every command that has a +(plus) sign next to it also has a -(minus) sign command, such as, +forward
The plus tells us that while the key bound to the plus alias is pressed it will execute teh plus command and when it is released, it will exec the minus command. In the +forward case, the plus alias tells the user to move forward while the minus stops from doing so. Try this to understand it more clearly, while in-game, open up the console and type +forward.
What happened? Your player is running forward mindlessly!! You can't stop him no matter what! Wtf is this? This is happening because only the +forward is being executed (so he's just running!), to stop him type -forward, he stops immediately! Now, do you get it?

For example, you want to watch the scoreboard while walking, +speed tells the user to walk as soon as you release the "shift" key, it execs the minus alias(-speed) which tells the user to stop walking, now, for the example:

alias +skorewalk "+showscores; +speed"
alias -skorewalk "-showscores; -speed"
bind shift +skorewalk

There you go! Works perfectly! But remember to code in the -skorewalk too!! Or you will end up walking and watching your ass-like score for the rest of your pitiful life! xD jk..
Some people get confused and make these types of errors, they fuck up their scripts ultimately messing up their games and the users using their scripts. Here's one idiot i'd like to mention, Pink, who does these kinds errors then tells the users to do it manually.. lOl xD.. Don't git mad on me bra, peace man peace (Y)!

Now for the "separator", in the scripting world ";(semi-colon)" is known as teh separator. How is it used you ask? It is the most important tool in scripting, it allows you to implement multiple commands in a single line! For example:

Type the following and hit Enter,
sensitivity 2; name "Marcu[s]"

You will find that both commands were executed simultaneously! Both the sensitivity and the name were set at once; now this opens up whole new windows of possibilities. xD

Now, last but definitely not the least; the "wait". The wait is a simple command widely used in scripts, it blocks/freezes the execution of ALL commands for a millisecond. I know it sounds like crap but you will know it's importance soon.
By the way, by all commands I mean ALL commands including your own movement and everything related to you(the user).

Lets see what this teenie weenie millisecond can do, lets try something different, let suppose I want to restart my server 3 times and go LIVE for a scrim! xD
What will I do? I will open my config file that I use for my scripts, and start punchin in restart commands like a jackass,

sv_restart 1
sv_restart 1
sv_restart 1

When I am done I will start my game, exec the damned config file, but hey wtf, my server will only restart 1 time, what the #@#$ is this?
See that's were the "wait" comes into the scene, why do we need the wait? Because there is a time-limit to the execution of the restart command, while the server is restarting it doesn't matter if you enter the restart command a million times, it won't respond 'cause it is already restarting! So until the first restart is complete you can't do shit! How to solve this problem? Add the "waits", here is the correct way to do it,

alias w "wait" //--- (First we alias "w" to "wait" for convenience)
alias w5 "w; w; w; w; w" //--- (Now we alias "w5" to the "w" for 5 waits - gives us 5ms)
alias w25 "w5; w5; w5; w5; w5" //--- (Now we alias "w25" to the "w5" for 25 waits - gives us 25ms)
alias w100 "w25; w25; w25; w25" //--- (Now we alias "w100" to the "w25" for 100 waits - gives us 1sec)

sv_restart 1
sv_restart 1
sv_restart 1
say "LIVE [GL---&---HF]"

Now if we exec the config file, the server will restart 3 times after a second of delay and say LIVE! Perfect!
Such a long delay with these waits (1 second) wasn't necessary for each restart, but I want you to grasp the concepts of the "alias", "wait" and the "separator" firmly, all these are your ultimate tools!

Use your brain a skills

The essence of scripting is solely based on imagination, you have to think and discover possibilities. I NEVER found it hard to code, the main hurdle was the idea; the possibility. If can be done by means of scripting then do it! It's that simple.Now that you know what tools you have and what things you can do with them then start thinking of the scripts you can create, the wonders you can perform, script packs, toggles, custom modifications, hacks, tools, integrations and what not!

Now that you now the basic methods of scripting, you should start to explore the game files. Start double-clicking all of the files, open them with the notepad. My rule is, if it is in English, it CAN be customized! ^^Counter-Strike is the only game i've seen that can be FULLY customized, because it's so damned simple! The reason I am telling you to explore is for 'integration' of scripts that I mentioned earlier, you can combine many interesting things with scripting. DO NOT forget to check out the config.cfg file in your cstrike folder, it is a pool of delicious commands that are required for efficient scripting. Also type "cmdlist" in your console to see a complete list of commands for your game!

Click here to see ALL cs scripts and commands

Anyways, my aim was to give you the basic idea of scripting and how it's done, but I think I will give you a few ideas and examples to jump start your scripting career.Here is a simple example of a cheat you can create using scripting, with this you can turn 180' quickly!alias trn180 "fps_max 10; cl_yawspeed 7200; wait; +left; wait; -left; wait; fps_max 140; cl_yawspeed 200"bind mouse3 trn180Now here, cl_yawspeed determines the speed by which you turn left or right using the keyboard, fps_max is the limiter for the maximum fps you can get in your game.

What I did here is limit the fps to 100 thus slowing the game down drastically and increase the yawspeed such that I can turn extremely fast while the game is slow, I stop exactly at 180' (which was calculated with certain amounts of 'waits') and return my fps and the yawspeed to normal.

Please note that this was just an example of the possibilities of scripting. I HATE CHEATS AND THE NOOBS who use them!!There are many types of simple concepts that many scripts revolve around, lets take look on "buy scripts", buy scripts are scripts that allow the users to buy multiple items/weapon with the push of a single button! How is it done? Its quite simple, to create buy scripts you must know the 'buy aliases' of the weapons/items. For example, while in-game drop whatever weapon you are holding, stand in a buyzone, open up the console and type 'hegren', you will buy a "he grenade", here 'hegren' was the ALIAS for the actual "he grenade"! Clear?

First I will give you the list of aliases for each weapon/item, so that you can memorize them all! The list appears below:

Weapon Alias List [+/-]

galil - IDF Defender
ak47 - AK-47
scout - Schmidt Scout
sg552 - Krieg 552
awp - Magnum Sniper Rifle
g3sg1 - G3/AU1
famas - Clarion 5.56
m4a1 - Maverick M4A1 Carbine
aug - Bullpup
sg550 - Krieg 550 Commando
glock - 9x19mm Sidearm
usp - KM .45 Tactical
p228 - 228 Compact
deagle - Night Hawk .50C
elites - .40 Dual Elites
fn57 - ES Five-Seven
m3 - Leone 12 Gauge Super
xm1014 - Leone YG1265 Auto Shotgun
mac10 - Ingram MAC-10
tmp - Schmidt Machine Pistol
mp5 - KM Sub-Machine Gun
ump45 - KM UMP45
p90 - ES P90
m249 - M249
primammo - Primary Ammo
secammo - Secondary Ammo
vest - Kevlar
vesthelm - Kevlar+Helmet
flash - Flashbang
hegren - HE Grenade
sgren - Smoke Grenade
nvgs - Nightvision
defuser - Defusal Kit
shield - Tactical Shield

Where did I get this you ask? I found these in the autobuy.txt file in the cstrike folder. See, this is why I told you to explore. Okay now, on with the example, open up the config file that you usually use and type in the following,

bind p "m4a1; vesthelm; deagle; primammo; secammo; hegren; flash; flash"

Now, standing at the buyzone when you press "P", you buy a lot of stuff, really, really fast! Hey wait, when you are in the

CTs you buy the complete package but when in Ts you have everything except the primary weapon! WTF!?!
Off course you won't have the "m4A1" when your are in the Ts!! What to do? Here is the correct code:

bind p "m4a1; ak47; vesthelm; deagle; primammo; secammo; hegren; flash; flash"

Now when you are in the Ts you get the "AK" and when in the CTs you get the "m4A1", perfect! xD

Okay, here is another concept used heavily these days for convenience, the "Toggle/Cycle Scripts"..
Toggle/Cycle scripts rely almost completely on the alias command. These kinds of scripts will become your best friends once you learn the general pattern they follow. I'll go through one step by step for you.

alias toggler option1
toggler is the name of what needs to be toggled, and what you eventually bind to a key.
option1 refers to the first option to be toggled.

alias option1 "command; alias toggler option2;"
option1 is the name of the first option in the toggler.
command is the command you wish to associate with the first toggle option.
"alias toggler option2;" tells the toggler bind to change to option2 on the next key press.

alias option2 "command; alias toggler option1;"
option2 is the name of the second option in the toggler.
command is the command you wish to associate with the second toggle option.
"alias toggler option1;" tells the toggler bind to change back to option1 on the next key press.

bind v toggler

You can use this concept for as many options as you wish to include, as long as the final option refers to the first option, creating an endless cycle or loop.

A working example of this follows,

alias NameTogg MyName1
alias MyName1 "name Mista_Pee; alias NameTogg MyName2"
alias MyName2 "name Marcu[s]; alias NameTogg MyName3"
alias MyName3 "name Perisher; alias NameTogg MyName1"

bind v NameTogg

Now, when you go in-game, pressing the 'v' key several times will change your name differently each time!
When you press it once your name will be changed to "Mista_Pee" and the alias to the toggle, NameTogg, will be changed to the next name, MyName2 which is "Marcus[s]". Press it again and your name will be changed to "Marcus[s]" the NameTogg will be changed to the next name, MyName3 which is "Perisher". Press it again and your name will be changed back to "Perisher" and so the NameTogg will be changed back to the first name, MyName1 which is "Mista_Pee". Thus creating an infinite loop, clear?

This was the ultimate Toggle and Buy Scripting techniques that you've just learned, I think thats enough for you to start scripting with enthusiasm!

I hope this tut helped you and now you got game! It was alot of fun writing this tut! Go kick ass bra!


2 comentarios:

Anonymous said...


Anonymous said...

:) thX

:) ;) :$ :D :( -.- xD :p :@ :# o.o

Post a Comment

Select NAME/URL to comment and don't spam


Contact me
©  template by Blogspot tutorial