Search
Username:
Password:

Register or Reset Password

SUBMISSIONS
Counter Strike
   New Maps
   New Tutorials
   New Skins
   New GUI's
   New Sounds
   New Threads
Other
   Media
   Gamers
   Clans
   Studios
A complete guide to scripting by J2K!
Difficulty: Beginner
Category: CS:S > ScriptingAuthor(s): J2K

//===================================
//A complete guide to scripting by J2K!
//===================================


Hey all!

Welcome to J2K's guide to all that is scripting in Counter-Strike Source!

I have been scripting since CS 1.5 and have created many original scripts which can be accessed through my submissions page of my profile. Hopefully, by the time you have read this tutorial, you will have had some of your own ideas go through your head and have a good idea how to implement them!

//====================================
//Part 1 - Required files
//====================================


Before we get started, lets make the necessary files!

Go to your Counter-Strike Source directory
C:\Program Files\Steam\SteamApps\UserName\Counter-strike Source

If it does not exist, create a folder named cstrike

In the cstrike folder, if it does not exist, create a
folder named cfg

Now to create the blank config files to work with, open NotePad and click
File > Save as...

For the name type
"autoexec.cfg"

For the file type select
All Files

Save it into the cfg folder

Repeat the process to create "userconfig.cfg"

You should now have 2 files within the cfg folder

autoexec.cfg
userconfig.cfg

//====================================
//Part 2 - What is a script?
//====================================


A script is a combination of commands and / or settings that make life easier for the user and save a lot of time and effort.

Scripts perform things from buying multiple items in one button, changing network and control settings quickly and simplifying in game actions so you can spend less time pressing buttons and entering settings, and more time fragging your opponents.

//====================================
//Part 3 - How do scripts work
//====================================


Scripts are stored in config files that Counter-Strike Source can execute. The only two files that you need are the two we created earlier in this tutorial;

autoexec.cfg
userconfig.cfg

There is a file called avalve.rc that automatically executes the above two files every time you load Counter-Strike Source.

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.

Within userconfig.cfg are bindings for your custom commands.

//====================================
//Part 4 - The alias command
//====================================


In this step, we will make our first alias to be bound to a key. We will start with something simple, a script that buys a pistol and some armour in one button.

Open autoexec.cfg and type the following into it:

alias deaglearmour "buy deagle; buy vest;"

alias sets the name of the script to the name that follows.
deaglearmour is the name of the script and what we will bind to a key later.
"buy deagle; buy vest;" is the commands associated with our alias that will be performed when we hit the bound key.

Now open userconfig.cfg and enter the following

bind P deaglearmour

bind tells CS: Source to bind a key to a command.
P is the key we are binding our alias to.
deaglearmour is the name of the alias we set up before that we are binding to the P key.

If we go into the game at this point, pressing the P key would result in the purchasing of a Desert Eagle pistol and a Kevlar Vest in a single key press!

//====================================
//Part 5 - Toggle and cycle scripts
//====================================


Toggle and cycle scripts rely heavily on the alias command. It becomes second nature making toggle scripts once you learn the general pattern they follow. I'll go through one step by step for you.

For simplicity's sake i will make a fake script first, and write a real one afterwards.

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 = toggler

You can do this for as many options as you wish, as long as the final option refers to the first option, creating an endless cycle.

A working example of this is below.

alias namechanger name1
alias name1 "name Name 1; alias namechanger name2;"
alias name2 "name Name 2; alias namechanger name3;"
alias name3 "name Name 3; alias namechanger name1;"

bind = namechanger


Now when you go into the game, pressing the = key several times will change your name differently each time!
Added: 1 year agoTags: guide, scripting, alias, bind, toggle, cycle
Feedback (18)
Page of 2   1 2 Next Page
Infy! .
C++ ProgramerY2M
Posted 2 days ago
Posted by anarchyOWNz

Ok..are scripts considered "hacks" in any way? like awp autoswitch, burst firing, bunnyhop scripts, auto spin or anything else? hacks at all? is it possible to be banned/vac banned for using them?
No, no, no, no no and no.
- C++ Programer
anarchyOWNz .
Pro at lifeY2M
Posted 2 months ago
Ok..are scripts considered "hacks" in any way? like awp autoswitch, burst firing, bunnyhop scripts, auto spin or anything else? hacks at all? is it possible to be banned/vac banned for using them?
- Pro at life
roryos01 .
I r tah suxorz!!!Y2M
Posted 4 months ago
I have a question what does -attack do? I know what +attack and wait does
- I r tah suxorz!!!
Buttons .
Bananite FTW?!Y2M
Posted 6 months ago
Nice tut! In a previous tut. I learned how to make a LO3.cfg (I don't know if that's well known, but it stands for LIVE ON THREE) which is used in scrims/cals.

I had a hard time following the toggler. Though the namechanger was slightly simple. (Gah, I hate typing with my left-hand, when I'm right-handed -_-)

I was also wondering if anyone could post the names for weapons? ALl I'm looking for is the AWP, Auto Shotty, Shotty, Dualies, AK47, HE, Flashbang, Smokegrenade, Nightvision, Helmet, M4A1 (I wonder if weapon-scripts work for oppisite sides? ;P). Sorry for the long list; I like lots-o-weapons.
- Bananite FTW?!
rickstar121 .
Bananite Fun Sun ProtectionY2M
Posted 6 months ago
Lol ncie job man
jeezyourecool .
BananiteY2M
Posted 7 months ago
Ok dude im confused, so i did all that, but what if i want more then 1 script? do i put it in the same files or somehting, and like the ones ppl have alread ymade, how do i use those, like for http://www.fpsbanana.com/scripting/158 , do i put the text in that into auto, and then bind then the first thing after alias to a letter?
- Bananite
specter99 .
BananiteY2M
Posted 7 months ago
Very Very nice! I was confused about all of this before but you cleared it up for me thanks a lot.
- Bananite
.
Thinkin outside the box. ;)Y2M
Posted 7 months ago
Thanks very well written, nicework.
hotmayo .
Wonder ShowzenY2M
Posted 8 months ago
I understand, thank you for this tutorial.
guddipuddi .
BananiteY2M
Posted 9 months ago
Thanks alot man best tutorial ive ever seen
- Bananite
Page of 2   1 2 Next Page
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.
Assessment
The community's verdict.
User Rating [+]
9.6/10
bScore
9.6/10
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.
Stamps
This Tutorial in a nutshell...
Well Written & Helpful
You cannot stamp yet!
Stamps let you apply characteristics to submissions to help others understand them.

To stamp this submission register or login.

Brought to you by...
Sabotage Studios
Originality, Creativity, Simplicity
Membership: On Request
Primary Skills: ?
Inception: 2 years ago
Vote for Studio
Like this tut? Vote Sabotage Studios for one or more monthly awards.
You must login or register to access this!
Related Tutorials