|
|
Everything about scripting Difficulty: Beginner |
| Category: CS:S > Scripting | Author(s): |

Hi and welcome to Daemons scripting tutorial.
In this tutorial you will learn all the basics, from aliases, bindings, buying equipment, guns and grenades.
To teach you this I am going to make a simple buy m4a1/ak47 script.
1. Setting up autoexec.cfg
First off you want to go to : C:\Program Files\Valve\Steam\SteamApps\YOUR ACCOUNT NAME\counter-strike source\cstrike\cfg\
You should see there a config.cfg file.
Now open up NotePad, don't write anything, just save it in yout folder as an any type file and the name has to be exactly "autoexec.cfg" (with the ""s). So you should see an autoexec.cfg file appear in the cfg folder.
Now right-click on that autoexec.cfg file and click properties.
Then set it so that that type of file opens with NotePad all the time.
2. Starting scripting
--2.a. Comments
Comments are words, phrases that won't be used in the code tho they are written there, they are generally used to not have one big blob of text and not having a clue where anything is.
To start my script, i'll write :
//------------------------------
// buy an M4A1/AK47
//------------------------------
as easy as that, as you may have noticed, comments are parsed if there is a // in front of it.
--2.b. aliases
Aliases are like variables when you come to think of it.
They contain bits of information for further use.
For instance, the next line of my script will be :
//says to team
alias sayrifle "say_team -+=M4A1/AK47+ammo=+-"
So here I have a comment, which tells me that the next line will be the alias to tell the team that I have bought a certain thing.
Aliases are presented like this :
alias ALIASNAME "what the alias does"
an alias can have a few different functions :
alias functions "func1;func2;func3;func4"
seperated by a ";"
an alias can contain another one :
alias this "that"
alias thisandthat "something;this"
Back to our script, as you can see, there is a command called say_team, this is the command that will send a message to your team ONLY.
So in this case it will tell your team :
-+=M4A1/AK47+ammo=+-
Please note this alias isn't in use it, it is only defined !
--2.c. alias and buying commands
Next line for my script :
//Buys the rifle
alias buyrifle "buy m4a1;buy AK47;buy primammo;sayrifle"
So as you see, we have now defined a new alias called buy rifle, this alias (when called, used) will buy an m4a1, an ak47, ammo for the gun and it will call the function sayrifle (see above).
Note : terrorists can only buy ak47 and Counter-terrorists can only buy m4a1's so this script will buy the gun depending on if the person is a T or a CT !
Now, this script is all nice but it doesn't do anything yet.
--2.d. Binding your alias
Next line :
//Binds KeyPad 1 to buy the m4a1/ak47
bind kp_end "buyrifle"
This line will bind kp_end (on the numpad it is number 1) to buyrifle, which will buy the gun, buy ammo, and tell the team that you have bought that gun !
The hole script till now :
//------------------------------
// M4A1/AK47
//------------------------------
//says to team
alias sayrifle "say_team -+=M4A1/AK47+ammo=+-"
//Buys the rifle
alias buyrifle "buy m4a1;buy AK47;buy primammo;sayrifle"
//Binds KeyPad 1 to buy the m4a1/ak47
bind kp_end "buyrifle"
You can experiment with other things for instance :
//------------------------------
// Awp+deagle
//------------------------------
//says to team
alias sayawp "say_team -+=AWP+Deagle+ammo=+-"
//Buys the awp and deagle
alias buyawp "buy AWP;buy deagle;buy primammo;buy secammo;sayawp"
//Bind KeyPad 2 to buy the awp+Deagle
bind kp_downarrow "buyawp"
Here buying an awp, a deagle, ammo for both and telling the team.
Experiment with all sorts of things.
Daemon |
| Added: 2 years ago | Tags: everything, about, scripting |
 Add Feedback Provide constructive feedback. What is "constructive"?You cannot post yet!Get involved on FPSB by posting your thoughts. Give authors your feedback to help them develop. To post in this submission register or login. |
 You cannot assess yet!Moderating FPSB is in your hands - when you assess a submission your vote determines its success or failure. To vote on this submission register or login. This Tutorial in a nutshell... No stamps recordedYou cannot stamp yet!Stamps let you apply characteristics to submissions to help others understand them. To stamp this submission register or login. None foundWant more? Find related tuts. |