How To Script #1 Difficulty: Beginner |
| Category: CS:S > Scripting | Author(s): Infallible |

Hello and welcome to my series of How to Script tutorials. First I'll start off with explaining what a script is; a script is generally a console command or a bunch of console commands used to do something ingame.
For example
-A script could be used to restart the game 3 times before the start of a scrim/cal match.
-A script could be used to bind something to a key, for instance both mouse1 and the L key shoot.
-A script could be used to make an automatic weapon fire semi automatic, or burst fire.
-A script could be used to change settings with the press of a button, or toggle something on and off.
Now that you know what a script is, and what they do, lets show you how to make one! Our first project will be to create a script that will restart the game, wait, restart the game, wait, restart the game again, then say a message in the chat box. That's right, we're making a live on three script. Start off by opening a new text document, then renaming it to lo3.cfg. Yes, it's a cfg file, if your computer does not know how to open one (I'm not sure if they do by default) then right click on it and go to open with, then from there open it with notepad or some other text editing program that will open any file format.
Put these lines in:
alias "w1" "wait;"
alias "w5" "w1;w1;w1;w1;w1;"
alias "w10" "w5;w5;"
alias "w15" "w10;w5;"
alias "w20" "w10;w10;"
alias "w25" "w15;w10;"
alias "w50" "w20;w20;w10;"
alias "w100" "w50; w50;"
alias "w200" "w100; w100;"
alias "w400" "w200; w200;"
alias "w500" "w400; w100;"
alias "w750" "w400; w200; w100; w50;"
alias "w1000" "w500; w500;" |
What do they do? Well, the alias command makes any word in the first set of brackets do the command that is in the second set of brackets. What i've done here is made w1 for 1 wait, w5 for 5 w1's, w10 for 2 w5's and so on, going all the way up to 1000 waits by simply typing the word w1000.
Now what does the wait command do? It makes a small pause between console commands that are in a script, or the console. Now because I have 1000 waits, that is a decent sized pause, but we will probably not have to use 1000 waits unless you have a very slow fps server. For accelerated servers we may even have to go down to 100 or 200 waits, but for most average servers 400-750 waits will be fine.
Now after those lines leave a few lines between and put this:
exec cssmatch.cfg
say (YOURNAMEHERE)'s lo3 script executed
w200
say ----====LIVE ON THREE====---- |
The exec command execs the cssmatch.cfg file which contains the rules for the match. We will make one of these later.
The say commands make a message appear in the chat box that appears to be typed by the console.
w200 is one of the alias commands we made earlier, which will cause the server to wait 200 times before doing the next step
After those lines put this:
w400
say ----====RESTART 1====----
mp_restartgame 1
w400
say ----====RESTART 2====----
mp_restartgame 1
w400
say ----====RESTART 3====----
mp_restartgame 1
w400 |
The w400s make the server wait 400 times before it does the next command.
You already know what say does.
mp_restartgame 1 will restart the round each time it is put there, but there must be enough waits inbetween or some will not register.
Next put this:
say ------------
w5
say E-----------
w5
say VE----------
w5
say IVE---------
w5
say LIVE--------
w5
say -LIVE-------
w5
say --LIVE------
w5
say ---LIVE-----
w5
say ----LIVE----
w5
say -----LIVE---
w5
say ------LIVE--
w5
say -------LIVE-
w5
say --------LIVE
w5
say E--------LIV
w5
say VE--------LI
w5
say IVE--------L
w5
say LIVE--------
w5
say -LIVE-------
w5
say --LIVE------
w5
say ---LIVE-----
w5
say ----LIVE----
w5
say -----LIVE---
w5
say ------LIVE--
w5
say -------LIVE-
w5
say --------LIVE
w5
say E--------LIV
w5
say VE--------LI
w5
say IVE--------L
w5
say LIVE--------
w5
say -LIVE-------
w5
say --LIVE------
w5
say ---LIVE-----
w5
say ----LIVE----
w5
say -----LIVE---
w5
say ------LIVE--
w5
say -------LIVE-
w5
say --------LIVE
w5
say E--------LIV
w5
say VE--------LI
w5
say IVE--------L
w5
say LIVE--------
w5
say -LIVE-------
w5
say --LIVE------
w5
say ---LIVE-----
w5
say ----LIVE----
w5
say -----LIVE---
w5
say ------LIVE--
w5
say -------LIVE-
w5
say --------LIVE
w5
say E--------LIV
w5
say VE--------LI
w5
say IVE--------L
w5
say LIVE--------
w5
say -LIVE-------
w5
say --LIVE------
w5
say ---LIVE-----
w5
say ----LIVE----
w5
say -----LIVE---
w5
say ------LIVE--
w5
say -------LIVE-
w5
say --------LIVE
w5
say ---------LIV
w5
say ----------LI
w5
say -----------L
w5
say ------------ |
It spams the server saying the match is live and the waits make each one delayed. This creates a fancy pattern of spamming live messages. Believe me, it's quite fun to watch. Next:
w100
say GL & HF
say Team (YOUR TEAMS NAME HERE)
w100
mp_startmoney 800 |
This concludes the script by saying GL & HF, good luck and have fun, and your teams name. If you do not have a team name you can put your name there instead of Team XXXXXX, or simply delete that line out of the script.
Well, now you know how to make an lo3 script. My next tutorial will show you how to make a config for this lo3.
~Infallible |
| Added: 6 months ago | Tags: how to script, infallible, btl studios, 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. |
 The community's verdict. No assessments made... please vote!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.
 |
Evolution Studios Never stop improving. |
| Membership: Invite Only |
| Primary Skills: 3D Animation, Coding/Scripting, Compiling, Mapping, Modelling, Texturing, UV Mapping, Server Administration |
| Inception: 18 days ago |
Want more? Find related tuts. |