Counter-Strike v1.6 Scripting: A Complete Tutorial Difficulty: Beginner
Category: CS > Scripting Author(s): Rolnaaba
Counter-Strike v1.6 Scripting: A Complete Tutorial
Table of Contents
Who is this for?
This tutorial is set up to be for the beginning scripter who wishes to learn how to create, use, and possibly publish Scripts for Counter-Strike v1.6. This article is set up to give a quick lesson from beginning to end of the Script creation process. This article is also written in a modular format, meaning that it can be either 1) read from beginning to end, or 2) used as a reference and be skipped around through. For example, someone who knows how to install scripts but not write them would read the "Scripting Basics," and "Creating your first Script" sections, but not the "Loading/Installing your Script" section. I am creating this tutorial in the hopes that better quality Scripts can be made.
Introduction
Welcome, to Counter-Strike v1.6 Scripting: A Complete Tutorial. In this tutorial you will learn the basics of scripting, what it is, how it works, why it works, and how to use it. Putting this into practice you will create your own script, and install it. Finally, you will take your script, and if it works ;), release your script to be used. So enough chit-chat, lets get to the good stuff!
Scripting Basics
CS "Scripting," as used in this tutorial, is the art of manipulating the way the game uses its command structure by injecting your own comands to simplify a previously dificult task. SOunds difficult huh? Not at all, Counter-Strike v1.6 is played through a use of text comands, similar to a text based game in the DOS days. The only difference is that this game has a GUI front-end. when we use a text command the game visually does something. Now most of you are thinking, "I dont type n-e txt commands wen I play Counter-izzle yo?!" But here is the thing: You may not be typing them, but everytime you press a key that key is "bound" to a command, and that comand is sent to the game engine. For example your "w" key is defaultly bound to the "+forward" command, which forces your graphic character to move forward. The game binds your key automatically when you install/run the game for the first time. So most people dont even know these commands exsist.
In-game you have access to the developer console by pressing your tilde ("~") key. This is your passport to success as a Scripter. This console is a gateway to the stream that your commands are being sent along. By typing commands into this console you can control your gameplay via text, though i will be much more difficult! Any comand that can be placed in console, can be placed in Script, and visa-versa. With that in mind really what you are doing when you script is using console commands to be played automatically in a sequence!
Creating your first Script
Now for the good stuff! To create your Script open up notepad. (Start > Run, type "notepad.exe"; or Start > All Programs > Accessories > Notepad) The basic rule of thumb for scripting is to 1) create a single alias that does what you want to do, even if you call multiple aliases from this one alias, then 2) bind a key to this alias. Confused on what an "alias" is? It is like a function, you designate a name for it and code to be executed when it is "called." Lets create a simple alias to start:
alias fire "+attack2;wait;wait;wait;wait;+attack1"
Ok, so what we just did was this: created an alias called "fire" which makes the player proccess attack2 (which is zoom if you can), then shoot their weapon (+attack1). We added those waits in there because if you send commands too quickly the engine will ignore certain ones to prevent an "overflow" error. As of now though it does nothing, lets make it do something:
alias fire "+attack2;wait;wait;wait;wait;+attack1;"
bind fire p
Now what this did was bind your "p" key to the fire alias so that when you press "p" you will zom in and immediately fire.
NOTE:
This script will probably not work, because it will send the attack1 command too fast before the zooming is complete and the engine will ignore the attack1 command. to fix this create what I call multi-waits:
alias wait10 "wait;wait;wait;wait;wait;wait;wait;wait;wait;wait;"
alias wait50 "wait10;wait10;wait10;wait10;wait10;"
alias wait250 "wait50;wait50;wait50;wait50;wait50;"
alias wait1000 "wait250;wait250;wait250;wait250;"
Or something to that effect ;)
Loading/Installing your Script
Now that we have written our script in notepad, we have to install or load it into our game. To do this navigate via your favorite method to your cstrike folder (defaultly this is: "C:\Program Files\Steam\steamapps\**UserName**\counter-strike\cstrike", where **UserName** is your user name). Open your "config.cfg" file with notepad and ensure that at the bottom it says "exec userconfig.cfg", add it if it does not. Now open a new text document by going to start > blah, blah, again. This will open a new instance of notepad and keep your original script intact. Copy over your script into this file, and save it as "userconfig.cfg". Now your script will be loaded everytime CS opens! :D
Testing your Script
Here is the easiest part! Open Steam, login, go to CS, and when you get in-game you should be able to press "p", to zoom and fire, providing ofcourse that your current gun can zoom (some weapons use attack2 to put on a silencer), and that you changed the waits as previously prescribed (you may not need 1000 waits I have no idea how many you would actually need).
Release your Script
Ok, maybe this is the easiest part. If you think you have a brand new, shinny, original script submit it to FPSBanana's Script Area . But please do NOT upload a bunch of zoom fire scripts, or repeats of already subbmitted scripts!
Resources
Added: 3 months agoTags: script , counter-strike , installing , coding , code
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 recorded
You cannot stamp yet! Stamps let you apply characteristics to submissions to help others understand them.
To stamp this submission
register or login.
Want more? Find related tuts.