Basics of Scripting Tutorial This first page is for people just starting out with making scripts, aliases, and binds. If any of these terms are unfamiliar to you, this is the place to start. The following topics are covered in this tutorial (click a topic to go there): What is a Bind What is an Alias What is a Script The Console The Files --Autoexec.cfg --Config.cfg Command Line Commands and Keys What is a Bind? Bind is the Half-Life command that assigns a command to a key. It can also assign an alias to a key. Example: bind "x" "+attack" in this example the key "x" is made into the primary attack button What is an alias? An alias is a name YOU make for a command or a group of commands. When you create an alias Half-Life treats it as if it was a normal command within the game. You can now bind it to a key or use it in another alias. Example: alias biteme "say BITE ME YOU JACKASS!!!" by typing this in the console or putting this in a .cfg file you have just created the new HL command "biteme". All that you have to do to use it is type "biteme" in the console or much easier, bind it to a key: bind "d" "biteme" now every time you hit the letter "d" you would say to everyone on the server "BITE ME YOU JACKASS!!!" You can also put several commands into an alias to speed up things or make things like buying in CS easier. The most common example is in buying scripts, for example: alias buymp5 "buy; menuselect 3; menuselect 1" bind "m" "buymp5" Now at the beginning of a round instead of puching the Buy key, then 3, then 1 to buy an mp5, you would merely hit "m". Too easy You can also use aliases inside of other aliases, again I use the weapons buying example. Say you made aliases for all of the weapons and equipment (as I have). A typical amount of money you have at the beginning of a round is $2200. This buys you a kevlar vest, an mp5, and primary weapon ammo. Example of nested alias: alias buymp5 "buy; menuselect 3; menuselect 1" alias buyvest "buy; menuselect 8; menuselect 1" alias ammo1 "buy; m6 " alias buy2200 "buymp5; buyvest; ammo1" bind "n" "buy2200" Again, now at the beginning of a round you merely have to press "n" and you have a vest, mp5, and ammo!!! ROCK!!! Take note of one other thing, if you have more than one command you are binding or aliasing, you must separate them by semicolons as above. What is a Script? A script is a collection of binds and aliases which do more together than they could by themselves. An example is a buying script, or a comms script. There are many of these user made scripts available. Very shortly I will have some posted for you to download. But if you read these tutorials, you will be able to make your own if you want. :) The Console. The console is the screen which you can bring down while in a game. It is a sort of command line within the game. By default it is brought down by the tilde ( ~ ) key. This key is to the left of your number 1 key on the top row of your keyboard. If for some reason your console will not appear, you need to add the command line switch "-console" to your command line executable for Half-Life. See the Command Line Section further down the page if you need more detailed help with this. The Files. The basic files needed to make your own binds, aliases, and scripts are: config.cfg and autoexec.cfg. CONFIG.CFG: Each mod of HL creates a config.cfg by default. This is where the game stores all of your configurations and preferences; keyboard and mouse controls, screen size, sound settings, renderer settings, etc. I recommend for several reasons that you DO NOT use this file to save anything which you make which is custom. i.e. any of your aliases, supercool binds, or commands to execute other files. The simplest reason I will give is that when you reinstall, whatever mod you are reinstalling will OVERWRITE YOUR CONFIG.CFG. If you want to test this, simply make some changes in CS like what keys you use to move and whatnot and then reinstall the latest patch. Your config.cfg will be gone, replaced by the default. 'nuff said about that. I do suggest if you haven't already, that you open your config.cfg with a text editor and check it out. AUTOEXEC.CFG: This file needs to be created by you. This is the only other .cfg file which loads at startup of your game (unless you are running a server). This important to know because if you have other scripts or configuration files which need to be executed at startup, they need to be referenced in this file. What? you don't see a file name autoexec.cfg in your half-life\cstrike directory? As I said, YOU need to make this file. This is simple. Open any text editor like EditPad (my favorite), Notepad, Wordpad, Word, Works, LotusNotes, whatever, make a new document, then from the File Menu, choose Save As. When the Save As dialogue box pops up, choose save as file type: All Files, or Any File. This will give you a blank box hopefully. Then in the file name box type the ENTIRE name: "autoexec.cfg". Notice you include the .cfg . This is important. There you are done. Except just make sure you save it in the counterstrike directory (half- life\cstrike). Later we will actually put some stuff in it. The Command Line The command line is the place where windows actually launches Half-Life. If you open the properties of a HL shortcut you will see the command line. To do this, find a shortcut to CS or HL, right click on it, and choose "Properties". This will bring up the box seen on the left. What you want to look at are the "command line switches", options for Half-Life to set as it starts up. In this case the options are: -console : Starts with the console enabled -noipx : Starts without support for the ipx protocol (makes connecting to servers faster). -game cstrike : Obviously, starts in Counter-Strike instead of Half-Life You also need to apply these setings to your game shortcut in GameSpy if you use GameSpy like most of us. Go to your "Games and Filters" settings by hitting the..."Games and Filters" button. It is in a red box below. You will then be presented with the Games and Filters Menu If you have the full version of Half-Life OR the Counter-Strike retail version this is the same. Click on the button to the left of the "Command Line" options. This button is highlighted in red below: This will bring up the box shown below. Simply type in the command line options you want (in the box highlighted in red) and click the OK button Done! There are many other options you can add to the command line. To see more commands available for the command line go to our Commands Listing Page XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX toggling aliases tutorial Introduction Tired of having too many keys bound to 'on' and 'off'? or other variations? well in this tutorial we will go over how to make a toggling alias, which will allow you to turn on and off the netgraph with only one button. Step one, the basics. First off we need something to toggle between on and off, I would suggest the ever useful net graph for this one =), so now that we have something to toggle, we have to start with the scripting, the first thing we need is alias so plop that down into your cfg, then we need a name for the command we are making, lets go with ngon and ngoff for this example, so so far it should look like this: alias ngon alias ngoff Purdy ain't it? now, for the next part, we need the commands. But we have to decide on whether or not it echo's to the game screen, or just the console, or not at all. We'll start out without it and add it afterwards. Now we need the command for net graph, which is net_graph it has 4 settings, 1, 2, 3, and 0. For now we'll only use 0 and 3. so, add this after ngon: "net_graph 3; So now, it should look like this: alias ngon "net_graph 3; alias ngoff The reason why there is no closing quote is because we are not finished. Now we need a key to have bound through the toggle, the choice is yours but I'll use "n". So now we add the cross bind: alias ngon "net_graph 3; bind n ngoff" And lets complete ngoff now too, fairly simple, change the 3 to a 0, and switch ngon with ngoff, and ngoff with ngon: alias ngoff "net_graph 0; bind n ngon" So, now that we have the commands all done, lets finish it off with a bind KEY command. Final Product: alias ngon "net_graph 3; bind n ngoff" alias ngoff "net_graph 0; bind n ngon" bind n "ngon" Now, everytime you hit "n" it will turn on/off the net graph at setting 3, which reports your frames and any packetloss you may have. Step two, echoing it to your console and screen Well we have this done: alias ngon "net_graph 3; bind n ngoff" alias ngoff "net_graph 0; bind n ngon" bind n "ngon" Were gonna take that and add a few commands to it, lets start with echoing it to the console alone. Now we need something to say, for this lets use "Net Graph on" and "Net Graph off", so the command will be echo Net Graph on and echo Net Graph off, lets add that now: alias ngon "echo Net Graph on; net_graph 3; bind n ngoff" alias ngoff "echo Net Graph off; net_graph 0; bind n ngon" bind n "ngon" There! we did it! now it will report to the console that the net graph is on, or off. Now lets get it to report that to the game screen. To do this we have to use a special command.. which is developer, this command has 3 settings if i'm not mistaken... 0, 1, and 2, setting 1 is three or four lines on screen, and setting 2 probably has double (NOTE: this lets everything the console says be reported to the screen). so before the echo command we need a developer 1 and after it we need a developer 0. Lets add that: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; bind n ngoff" alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; bind n ngon" bind n "ngon" Step three, user friendlizing To make it so it can be added to the control's menu, we need to take out all those alias binds, and change them to an alias. (example: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; BIND N NGOFF") Its not as tough as it sounds. Replace it with alias ng ngoff, and be sure to change the other as well. So now we have this: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; alias ng ngoff" alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon" But this also means we have to add another alias, put this below it: alias ng ngon, so we now have: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; alias ng ngoff" alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon" alias ng "ngon" And now all we have to do is bind ng: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; alias ng ngoff" alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon" alias ng "ngon" bind n "ng" There we go! now to change this toggle all we have to do is change the bind, simple! so we can add this to kb_act.lst (open with notepad): "ng" "Toggle the net graph" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +/- alias tutorial Introduction In this tutorial I'll explain how to make a +/- alias, and its various uses. I'm going to assume you've done the toggle alias tutorial. We'll use the net graph for this one too. the basics. Were going to take what we learned from the toggles, and make it so if we hold down n, it will show the net graph, and let go it will go away (like the scores screen). to do this we must take wat we had at the start: alias ngon "net_graph 3; bind n ngoff" alias ngoff "net_graph 0; bind n ngon" bind n "ngon" Now we don't need that bind in there (the in alias one), but we do need the net graph one, rename ngon to +ng, and ngoff to -ng, then delete those binds from it: alias +ng "net_graph 3" alias -ng "net_graph 0" bind n "+ng" Thats it, its done, simple ain't it? the explanation of this is when you press the key bounds to the +alias, it executes all the commands you have after it, in this case it was just net_graph 3. And when you let go, it executes even more commands, which we had only net_graph 0. You could do many things with this, like make holding tab show your scores and your frames/ sec, lets do that. Add +showscores after the net_graph 3 command, and -showscores after the net_graph 0 one, and bind it to "tab" instead of "n": alias +ng "net_graph 3; +showscores" alias -ng "net_graph 0; -showscores" bind tab "+ng" And yes, the key you use for this can be configured via the in game menu (if you so choose to). XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX cycling aliases tutorial Introduction Tired of having too many keys bound to 1, 2, and 3? or other variations? well in this tutorial we will go over how to make a cycling alias, which will allow you to cycle the net graph through all of its settings with only one button. Step one, making a cycle lets take what we have from step two of the toggle alias, and make it cycle through all the net graph settings, we'll go backwards, 3-0. This is what we have thrus far: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; bind n ngoff" alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; bind n ngon" bind n "ngon" So we need to take what we have and add the other 2 settings, and change a few words to something else, change ngon to ng1 and ngoff to ng4, also edit the echo a little bit, and add these lines between them: alias ng2 "developer 1; echo Net Graph on, setting 2; developer 0; net_graph 2; bind n ng3" alias ng3 "developer 1; echo Net Graph on, setting 3; developer 0; net_graph 1; bind n ng4" So now we have this: alias ng1 "developer 1; echo Net Graph on, setting 1; developer 0; net_graph 3; bind n ng2" alias ng2 "developer 1; echo Net Graph on, setting 2; developer 0; net_graph 2; bind n ng3" alias ng3 "developer 1; echo Net Graph on, setting 3; developer 0; net_graph 1; bind n ng4" alias ng4 "developer 1; echo Net Graph off;developer 0; net_graph 0; bind n ng1" bind n "ng1" There, thats done. now we can cycle through all of the net graph settings. Step two, user friendlizing To make it so it can be added to the control's menu, we need to take out all those alias binds (example: alias ng1 "developer 1; echo Net Graph on, setting 1;developer 0; net_graph 3; BIND N NG2") to do this we need to change that to an alias, its not as tough as it sounds. Replace it with "alias ng ng2", and be sure to change the others as well. So now we have this: alias ng1 "developer 1; echo Net Graph on, setting 1; developer 0; net_graph 3; alias ng ng2" alias ng2 "developer 1; echo Net Graph on, setting 2; developer 0; net_graph 2; alias ng ng3" alias ng3 "developer 1; echo Net Graph on, setting 3; developer 0; net_graph 1; alias ng ng4" alias ng4 "developer 1; echo Net Graph off;developer 0; net_graph 0; alias ng ng1" But this also means we have to add another alias, put this below it: alias ng ng1, so we now have: alias ng1 "developer 1; echo Net Graph on, setting 1; developer 0; net_graph 3; alias ng ng2" alias ng2 "developer 1; echo Net Graph on, setting 2; developer 0; net_graph 2; alias ng ng3" alias ng3 "developer 1; echo Net Graph on, setting 3; developer 0; net_graph 1; alias ng ng4" alias ng4 "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ng1" alias ng "ng1" And now all we have to do is bind ng: alias ng1 "developer 1; echo Net Graph on, setting 1; developer 0; net_graph 3; alias ng ng2" alias ng2 "developer 1; echo Net Graph on, setting 2; developer 0; net_graph 2; alias ng ng3" alias ng3 "developer 1; echo Net Graph on, setting 3; developer 0; net_graph 1; alias ng ng4" alias ng4 "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ng1" alias ng "ng1" bind n "ng" There we go! now to change this toggle all we have to do is change the bind, simple! so we can add this to kb_act.lst (open with notepad): "ng" "Toggle the net graph" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX meta bind tutorial Introduction Ever wonder how you can free up some keys for your ever valuable quick buys? well now you don't have to! In this Tutorial we'll go over how to make a meta bind (a meta bind is something that will rebind keys when you hold down a single key, and bind them back when you let go). be sure and read the +/- tutorial first before you do this one. Meta binds For this one were gonna start fresh, and we need an idea. Lets make holding alt rebind 1-0 to preset weapon buys. we need a command name, lets choose +pset and -pset, and for the presets lets call them preset1-preset10, refer to the writing your first buy alias tutorial for the commands to buy the things you want. lets start by making the presets: alias preset1 "buy; menuselect 4; menuselect 6; buy; menuselect 6; buyequip; menuselect 2" //this buys a AWP, full ammo, and a kelvar + helmet alias preset2 "buy; menuselect 3; menuselect 1; buy; menuselect 6; buyequip; menuselect 1; buyequip; menuselect 7" //this buys a MP5, full ammo, kelvar, and night vision goggles alias preset3 "buy; menuselect 2; menuselect 1; buy; menuselect 1; menuselect 5; buy; menuselect 6; buy; menuselect 7; buyequip; menuselect 2" //my personal favorite, it buys a M3, akimbo beretta's, full ammo, and a kelvar + helmet alias preset4 "buy; menuselect 1; menuselect 3; buy; menuselect 7" //this buys a DE with full ammo alias preset5 "buy; menuselect 4; menuselect 3; buy; menuselect 4; menuselect 2; buy; menuselect 6; buyequip; menuselect 2" //this buys a colt M4A1 if you are CT, and a sig Commando if you are T, full ammo, and a kelvar + helmet alias preset6 "buy; menuselect 5; menuselect 1; buy; menuselect 6; buyequip; menuselect 4; buyequip; menuselect 5" //this buys a Para, full ammo, a HE and a smoke grenade alias preset7 "buy; menuselect 3; menuselect 2; buy; menuselect 3; menuselect 4; buy; menuselect 6" //this will buy either a MAC-10 or the Steyr TMP and full ammo alias preset8 "buy; menuselect 4; menuselect 5; buy; menuselect 6; buyequip; menuselect 2" //the scout, full ammo, and kelvar + helmet alias preset9 "developer 1; echo use your imagination!; developer 0" alias preset10 "developer 1; echo use your imagination!; developer 0" //think of something =) There, thats what we will use, if you want to change anything, feel free. Now we need to make the +pset and - pset aliases, the +pset will bind 1-0 to preset1-preset10, and -pset will bind them all back to slot1-slot0: alias +pset "bind 1 preset1; bind 2 preset2; bind 3 preset3; bind 4 preset4; bind 5 preset5; bind 6 preset6; bind 7 preset7; bind 8 preset8; bind 9 preset9; bind 0 preset10" alias -pset "bind 1 slot1; bind 2 slot2; bind 3 slot3; bind 4 slot4; bind 5 slot5; bind 6 slot6; bind 7 slot7; bind 8 slot8; bind 9 slot9; bind 0 slot0" Ok, now lets put it together and finish it with a bind: alias preset1 "buy; menuselect 4; menuselect 6; buy; menuselect 6; buyequip; menuselect 2" alias preset2 "buy; menuselect 3; menuselect 1; buy; menuselect 6; buyequip; menuselect 1; buyequip; menuselect 7" alias preset3 "buy; menuselect 2; menuselect 1; buy; menuselect 1; menuselect 5; buy; menuselect 6; buy; menuselect 7; buyequip; menuselect 2" alias preset4 "buy; menuselect 1; menuselect 3; buy; menuselect 7" alias preset5 "buy; menuselect 4; menuselect 3; buy; menuselect 4; menuselect 2; buy; menuselect 6; buyequip; menuselect 2" alias preset6 "buy; menuselect 5; menuselect 1; buy; menuselect 6; buyequip; menuselect 4; buyequip; menuselect 5" alias preset7 "buy; menuselect 3; menuselect 2; buy; menuselect 3; menuselect 4; buy; menuselect 6" alias preset8 "buy; menuselect 4; menuselect 5; buy; menuselect 6; buyequip; menuselect 2" alias preset9 "developer 1; echo use your imagination!; developer 0" alias preset10 "developer 1; echo use your imagination!; developer 0" alias +pset "bind 1 preset1; bind 2 preset2; bind 3 preset3; bind 4 preset4; bind 5 preset5; bind 6 preset6; bind 7 preset7; bind 8 preset8; bind 9 preset9; bind 0 preset10" alias -pset "bind 1 slot1; bind 2 slot2; bind 3 slot3; bind 4 slot4; bind 5 slot5; bind 6 slot6; bind 7 slot7; bind 8 slot8; bind 9 slot9; bind 0 slot0" bind alt "+pset" Enjoy! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX