{"id":111,"date":"2004-08-28T21:22:37","date_gmt":"2004-08-29T02:22:37","guid":{"rendered":"http:\/\/192.168.33.66\/wp\/?p=111"},"modified":"2004-08-28T21:22:37","modified_gmt":"2004-08-29T02:22:37","slug":"cs-scripts-howto","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=111","title":{"rendered":"cs scripts howto"},"content":{"rendered":"<p>Counter Strike &#8211; Scripting<\/p>\n<p>CS Scripting guide by ethereal<\/p>\n<p>Half-Life Counter-Strike Scripting<br \/>\nWelcome to the Counter-Strike scripting guide. This guide is meant for all the<br \/>\npeople who want to optimize their config and use clever and useful script to<br \/>\nenhance their Counter-Strike game. This guide covers the scripting aspect from<br \/>\nthe very simple and general up to the advanced and specific. You can go as far<br \/>\nas you want in this, but if you finish reading the guide you should be able to<br \/>\nmake your own advanced scripts.<\/p>\n<p><!--more--><\/p>\n<p>The Scripting Environment<br \/>\nBefore we start playing around with the scripting language, it is important to<br \/>\nknow how to actually enter these scripts and use them in Counter-Strike. The<br \/>\nmain scripting command processor is the console. When you press the ~ or ` key<br \/>\non your keyboard, it brings down the console and shows you all past commands<br \/>\nand<br \/>\nhappenings in the game. You could consider it the raw text format of everything<br \/>\nyou do in the game. The console is also used to enter text commands into. All<br \/>\nscripts discussed below can be entered straight into the console and used<br \/>\nthereafter. However, to prevent you from having to type slabs of text, it is<br \/>\neasier to use configs. A config file will be of the format <name>.cfg and<br \/>\nplaced<br \/>\ninto your cstrike dir. It can be simply opened with the Windows text file<br \/>\neditor, and can be created by making a new text document <name>.txt and<br \/>\nchanging<br \/>\nit to <name>.cfg. Counter-Strike itself uses the file config.cfg to store all<br \/>\nthe binds, keys and settings. However, since Counter-Strike creates this file<br \/>\nand is not able to store elaborate scripts in it, you are advised to make your<br \/>\nown config file.<\/p>\n<p>A config file is actually not much more than a list of commands that will be<br \/>\nentered into the console. In stead of typing in all the commands in your config<br \/>\none by one, you simply type:<\/p>\n<p>exec <configname>.cfg<\/p>\n<p>into the console, and the console will then execute all the commands in the<br \/>\nconfig file. Alternatively, if you want Half-Life to automatically execute your<br \/>\npersonal config file on startup, you should add the following command to your<br \/>\ncommand line:<\/p>\n<p>+exec <configname>.cfg<\/p>\n<p>If you have the Half-Life icon on your desktop, right-click it, press<br \/>\nproperties and edit the &#8220;Target&#8221; box. It will be something alike to:<\/p>\n<p>D:\\games\\halflife\\halflife.exe -game cstrike.<\/p>\n<p>Simply add +exec <configname>.cfg to the end and the game will run your config<br \/>\non startup.<\/p>\n<p>Now that you know how to use config files and execute scripting commands into<br \/>\nthe console, it&#8217;s time to get scriptin&#8217;!<\/p>\n<p>The Bind and the Alias<br \/>\nWe start off with the most basic of scripting commands: the bind and the alias.<br \/>\nA bind is a command that links a keypress to a command. If you open your<br \/>\nconfig.cfg in the cstrike directory with the text editor, you will see it<br \/>\nstarts<br \/>\noff with a whole list of binds. All binds are in the same format:<\/p>\n<p>bind &#8220;<key>&#8221; &#8220;<action>&#8220;<\/p>\n<p>or, if more actions have to be bound to the same key, the ; can be used to<br \/>\nseperate actions:<\/p>\n<p>bind &#8220;<key>&#8221; &#8220;<action1>;<action2>;<action3>;:;<actionx>&#8220;<\/p>\n<p>as an example, you could warn teammates about you going to throw a flashbang:<\/p>\n<p>bind &#8220;c&#8221; &#8220;use weapon_flashbang; say_team Watch it! I&#8217;m throwing a flashbang!&#8221;<\/p>\n<p>The list of keys that can be used to bind actions to, can be found here. It is<br \/>\nusually wise to assign the most important binds (the ones you use most often)<br \/>\nto<br \/>\nkey that are easy to reach. All the different actions that can be bound will be<br \/>\ndescribed in the next piece of this guide. First, we have to take a look at the<br \/>\nalias.<\/p>\n<p>The Alias<br \/>\nAn alias is a actually a way of grouping commands under a new name, which<br \/>\nallows for more advanced scripting as we will see lateron. This new alias name<br \/>\nis also a new command word, which executes all the actions in the bind. The<br \/>\nalias is used in the following format:<\/p>\n<p>alias &#8220;<aliasname>&#8221; &#8220;<action1>;<action2>;<action3>;:;<actionx>&#8220;<\/p>\n<p>Pretty much the same as a bind, only it allows you to make a new name for it in<br \/>\nstead of immediately binding it. The aliasname could be anything you can think<br \/>\nof, but two things should be kept in mind. First of all the alias name should<br \/>\nbe<br \/>\ndiscriptive, so you know by looking at the name, what alias it is and what it<br \/>\nis<br \/>\nused for. Second, you should never use existing commands or keys for an alias<br \/>\nname. The flashbang warning and selection bind as shown above, can be rewritten<br \/>\nusing the alias command:<\/p>\n<p>alias &#8220;select_fb_grenade&#8221; &#8220;use weapon_flashbang&#8221;<\/p>\n<p>alias &#8220;give_fb_warning&#8221; &#8220;say_team Watch it! I&#8217;m throwing a flashbang!&#8221;<\/p>\n<p>bind &#8220;c&#8221; &#8220;select_fb_grenade; give_fb_warning&#8221;<\/p>\n<p>The C key is now bound to execute the select_fb_grenade alias, and then execute<br \/>\nthe give_fb_warning alias. In this example, it may all seem a bit elaborate<br \/>\nsince the simple bind works just as well. However, aliasing allows more<br \/>\nadvanced<br \/>\nand comprehensive scripting as we will see lateron.<\/p>\n<p>\nThe Comment<br \/>\nThe last basic scripting command that should be discussed is the comment. You<br \/>\ncan add comments to your command lines in your config file, by simply adding<br \/>\nwhatever text you like after two slashes: \/\/. The console ignores all text<br \/>\nwritten after two slashes. For examply, you could comment on the flashbang<br \/>\nscript:<\/p>\n<p>\/\/ This is the flashbang script, which warns my team before throwing a<br \/>\nflashbang<\/p>\n<p>alias &#8220;select_fb_grenade&#8221; &#8220;use weapon_flashbang&#8221;<br \/>\n\/\/ This part selects the grenade in hand<\/p>\n<p>alias &#8220;give_fb_warning&#8221; &#8220;say_team Watch it! I&#8217;m throwing a flashbang!&#8221;<br \/>\n\/\/ This part warns the team<\/p>\n<p>bind &#8220;c&#8221; &#8220;select_fb_grenade; give_fb_warning&#8221;<br \/>\n\/\/ This part binds the two actions to the C key<\/p>\n<p>The Basic Commands<br \/>\nEvery action you do in the game can also be done executing a command in the<br \/>\nconsole. You could actually play Counter-Strike simply by typing commands into<br \/>\nthe console. It probably wouldn&#8217;t get you very far though ;-). What you do have<br \/>\nto realise is that every keypress you make in the game can actually be<br \/>\nautomated. If you find yourself making the same series of keypresses time and<br \/>\ntime again in the game, then why not automate it? For instance, to buy an MP5<br \/>\nyou would press the &#8220;buy&#8221; key, the &#8220;3&#8221; key and the &#8220;1&#8221; key. Why not simply<br \/>\nassign one key to buy an MP5 for you? And why not add a kevlar vest, HE grenade<br \/>\nand primary ammo to that as well?<\/p>\n<p>All you really need is a list of keys and a list of commands, and your own<br \/>\nimagination to link the keys to the commands. The command list provides you<br \/>\nwith<br \/>\nmost of the commands used in common scripting. I haven&#8217;t added every last video<br \/>\nand setting command since the list could go on for ages. The current command<br \/>\nlist should fulfill all your scripting and automating needs. However, some<br \/>\ncommands aren&#8217;t as simple as your standard say and say_team, and will be<br \/>\ndiscussed below.<\/p>\n<p>The Press\/Release command<br \/>\nFirst of all there is the + and &#8211; type command. For instance, the attack<br \/>\ncommand comes as &#8220;+attack&#8221; and not simply &#8220;attack&#8221;. Why? Well the + indicates<br \/>\nthat the following command will be executed at keypress, while it&#8217;s &#8211;<br \/>\ncounterpart will be executed at key release. This means that when you press<br \/>\nyour<br \/>\nattack key (most likely mouse button 1), the console executes the +attack<br \/>\ncommand (fire the gun) and when you release the mouse button, the console<br \/>\nexecutes the -attack command (stop firing the gun). The +attack command<br \/>\nactually<br \/>\nkeeps firing until the -attack command is given. Try typing +attack into the<br \/>\nconsole just for fun, you will see that you will remain firing forever! Well<br \/>\nuntil you run out of ammo that is (this doesn&#8217;t work with the pistols as they<br \/>\ndon&#8217;t have continuous firing). The same is true for the duck command. If you<br \/>\ntype +duck in the console, you will remain in crouching position until the<br \/>\n-duck<br \/>\ncommand is given.<\/p>\n<p>The Menu Selection commands<br \/>\nNext there is the menuselect and slot10 commands. The menuselect command<br \/>\nselects a menu item by toggling the correct number. The command &#8220;menuselect 2&#8221;<br \/>\nselects the 2nd item from the menu. This menu includes teamchoosing menus,<br \/>\nbuying menus and radio sound menus. The &#8220;slot10&#8221; command is used to close any<br \/>\nmenus that are still open. So the script to buy an MP5 would be:<\/p>\n<p>\/\/ An MP5 buying script<\/p>\n<p>alias &#8220;mp5_buy&#8221; &#8220;buy; menuselect 3; menuselect 1; slot10&#8221;<br \/>\n\/\/ Buys MP5 and closes the menu<\/p>\n<p>bind F1 &#8220;mp5_buy&#8221;  \/\/ Binds the script to the F1 key<\/p>\n<p>The Echo command<br \/>\nThe third special command type is the &#8220;echo&#8221; command. This command echoes the<br \/>\ntext written behind it directly to the console. It is most often used to<br \/>\nconfirm<br \/>\nthe loading of a config. You are advised to add something like this to the end<br \/>\nof your new config file:<\/p>\n<p>\/\/ Confirm Config Loaded<\/p>\n<p>echo <myconfigname>.cfg has been loaded<\/p>\n<p>\nThe Wait command<br \/>\nThe last special command type is the &#8220;wait&#8221; command. This command forms a delay<br \/>\nof one game tick, which is actually a very short period of time. Why wait would<br \/>\nyou say. Well sometimes a whole line of commands in a row will get a bit<br \/>\nclogged<br \/>\nup and especially if your connection is a bit laggy, you might find that some<br \/>\ncommands in your script have been skipped or lost. If your script is<br \/>\nmalfunctioning, remember to try and put some waits in. They can be considered<br \/>\nthe &#8216;oil&#8217; of a script. More waits generally make it run smoother. Waits can<br \/>\nalso<br \/>\nbe used to actually put some time in between commands. One can think of a<br \/>\nscript<br \/>\nthat plants the C4 bomb (requiring some time to plant the bomb) which says<br \/>\n&#8220;guarding the bomb&#8221; after it has been planted. However, since a wait is a very<br \/>\nshort time, you are advised to make a longwait, as discribed in the Easy<br \/>\nScripting section below.<\/p>\n<p>Toggle, Cycle and Press\/Release Scripts<br \/>\nThere are three special types of scripts that can be used to fulfill your<br \/>\nadvanced scripting needs. They will be discussed below<\/p>\n<p>The Toggle Script<br \/>\nThe first is the toggle script. This type of script can be used to switch a<br \/>\ncertain setting on or off with only assigning one key to it. Pressing it once<br \/>\nput the setting on, pressing it again puts the setting off. It can be<br \/>\nconsidered<br \/>\nas a switch. The setup for this type of script is quite simple<\/p>\n<p>\/\/ Toggle Script<\/p>\n<p>alias &#8220;toggle_on&#8221; &#8220;<command to switch setting on>; alias toggle toggle_off&#8221;<br \/>\n\/\/ Toggle ON<\/p>\n<p>alias &#8220;toggle_off&#8221; &#8220;<command to switch setting off>; alias toggle toggle_on&#8221;<br \/>\n\/\/ Toggle OFF<\/p>\n<p>alias &#8220;toggle&#8221; &#8220;toggle_on&#8221; \/\/ Initiate the first keypress to be Toggle ON<\/p>\n<p>bind &#8220;<key>&#8221; &#8220;toggle&#8221; \/\/ Bind a key to the toggle script<\/p>\n<p>Take a look at this script and try to understand it. The key bound to &#8220;toggle&#8221;<br \/>\nwill execute the &#8220;toggle&#8221; alias when pressed. The first time the key is<br \/>\npressed,<br \/>\nthe toggle alias will in its turn execute the &#8220;toggle_on&#8221; alias, as Initiated<br \/>\nin<br \/>\nthe script. The toggle_on alias actually executes the desired command, and<br \/>\nchanges the &#8220;toggle&#8221; alias to execute the &#8220;toggle_off&#8221; alias the next time it<br \/>\nis<br \/>\nused. The next time the key is pressed, the &#8220;toggle_off&#8221; alias is executed,<br \/>\nwhich itself changes the script to execute the &#8220;toggle_on&#8221; alias the next time<br \/>\nagain. The switching script has been made. A common usage for the toggle script<br \/>\nis to assign a key to changing the weapon from the right to the left hand and<br \/>\nback. This script would look like this:<\/p>\n<p>\/\/ Weapon Handedness Toggle Script<\/p>\n<p>alias &#8220;handtoggle_right&#8221; &#8220;setinfo lefthand 0; alias handtoggle handtoggle_left&#8221;<br \/>\n\/\/ Toggle to Right Hand<\/p>\n<p>alias &#8220;handtoggle_left&#8221; &#8220;setinfo lefthand 1; alias handtoggle handtoggle_right&#8221;<br \/>\n\/\/ Toggle to Left Hand<\/p>\n<p>alias &#8220;handtoggle&#8221; &#8220;handtoggle_left&#8221; \/\/ Initiate first keypress to change to<br \/>\nleft hand<\/p>\n<p>bind &#8220;v&#8221; &#8220;handtoggle&#8221; \/\/ Bind the V key to the handtoggle Script<\/p>\n<p>\nThe Cycle Script<br \/>\nThe next type of script is the cycle script. This script cycles between a range<br \/>\nof options and returns to the first option after the last one has been reached.<br \/>\nQuite similar to the toggle script, it will look like this:<\/p>\n<p>\/\/ Cycle Script<\/p>\n<p>alias &#8220;cycleoption1&#8221; &#8220;<command for option 1>; alias cycle cycleoption2&#8243;<br \/>\n\/\/ Command 1 and Cycle to 2<\/p>\n<p>alias &#8220;cycleoption2&#8221; &#8220;<command for option 1>; alias cycle cycleoption3&#8243;<br \/>\n\/\/ Command 2 and Cycle to 3<\/p>\n<p>alias &#8220;cycleoption3&#8221; &#8220;<command for option 1>; alias cycle cycleoption4&#8243;<br \/>\n\/\/ Command 3 and Cycle to 4<\/p>\n<p>:<\/p>\n<p>alias &#8220;cycleoptionx&#8221; &#8220;<command for option x>; alias cycle cycleoption1&#8243;<br \/>\n\/\/ Command x and cycle back to 1<\/p>\n<p>alias &#8220;cycle&#8221; &#8220;cycleoption1&#8221; \/\/ Initiate the Cycle at cycleoption1<\/p>\n<p>bind &#8220;<key>&#8221; &#8220;cycle&#8221; \/\/ Bind a key to the cycle script<\/p>\n<p>As you can see, a toggle script is actual a cycle script with only 2 options. A<br \/>\ncommon usage for the cycle script is to cycle between the different types of<br \/>\ngrenades you are holding. It would look like this:<\/p>\n<p>alias &#8220;cycle_he&#8221; &#8220;use weapon_hegrenade; alias grencycle cycle_fb&#8221;<br \/>\n\/\/ Select HE and cycle to FB<\/p>\n<p>alias &#8220;cycle_fb&#8221; &#8220;use weapon_flashbang; alias grencycle cycle_sg&#8221;<br \/>\n\/\/ Select FB and cycle to SG<\/p>\n<p>alias &#8220;cycle_sg&#8221; &#8220;use weapon_smokegrenade; alias grencycle cycle_he&#8221;<br \/>\n\/\/ Select SG and cycle to HE<\/p>\n<p>alias &#8220;grencycle&#8221; &#8220;cycle_he&#8221; \/\/ Initiate script to start at selecting HE<\/p>\n<p>bind &#8220;g&#8221; &#8220;grencycle&#8221;<\/p>\n<p>The Press\/Release Script<br \/>\nThe last type of special script is the press\/release script. This script is<br \/>\nused like the press\/release commands in Half-Life (like +attack and +duck). It<br \/>\nexecutes a range of commands on keypress, and executes another range of<br \/>\ncommands<br \/>\non the release of that same key. It will look like this:<\/p>\n<p>\/\/ Press\/Release Script<\/p>\n<p>alias &#8220;+scriptname&#8221; &#8220;<command1>;<command2>;:;<commandx>&#8220;<\/p>\n<p>alias &#8220;-scriptname&#8221; &#8220;<command2-1>;<command2-2>;:;<command2-x>&#8220;<\/p>\n<p>bind &#8220;<key>&#8221; &#8220;+scriptname&#8221;<\/p>\n<p>Counter-Strike itself will automatically execute the -scriptname alias when the<br \/>\nkey is released, preventing you from having to make the link yourself. One of<br \/>\nthe best press\/release scripts I have come upon is the C4 planting script:<\/p>\n<p>\/\/ C4 Planting Script<\/p>\n<p>alias &#8220;+plant_c4&#8221; &#8220;weapon_knife; weapon_c4; +duck; wait; +attack; say_team I am<br \/>\nplanting the bomb!; slot10&#8243; \/\/ Plant the C4<\/p>\n<p>alias &#8220;-plant_c4&#8221; &#8220;-attack; -duck&#8221; \/\/ Get up after planting the C4<\/p>\n<p>bind &#8220;backspace&#8221; &#8220;+plant_c4&#8221; \/\/ Bind a key to the C4 planting script<\/p>\n<p>The script selects the knife first to be sure that you don&#8217;t waste any ammo,<br \/>\nshould the script skip the weapon_c4 selection part. It ducks, places the bomb<br \/>\nwhile the backspace key is held and gives a warning to the team. At key release<br \/>\nit gets up again.<\/p>\n<p>Easy Scripting<br \/>\nThere are a couple of smaller scripts that make life a bit easier for the<br \/>\nscripter. First of all there is the longwait. In stead of having to type<br \/>\nwait;wait;wait;wait etc in your scripts, you can alias it to make it all a bit<br \/>\neasier:<\/p>\n<p>alias &#8220;longwait&#8221; &#8220;wait; wait; wait; wait; wait&#8221;<\/p>\n<p>alias &#8220;longerwait&#8221; &#8220;longwait; longwait; longwait; longwait; longwait&#8221;<\/p>\n<p>alias &#8220;verylongwait&#8221; &#8220;longerwait; longerwait; longerwait; longerwait;<br \/>\nlongerwait&#8221;<\/p>\n<p>The average mathematician can see that the verylongwait encompasses 125 waits,<br \/>\nwhich is actually STILL a very short time in-game.<\/p>\n<p>Another time and text saver is the shortening of the menuselect commands:<\/p>\n<p>alias ms1 &#8220;menuselect 1&#8221;<br \/>\nalias ms2 &#8220;menuselect 2&#8221;<br \/>\nalias ms3 &#8220;menuselect 3&#8221;<br \/>\nalias ms4 &#8220;menuselect 4&#8221;<br \/>\nalias ms5 &#8220;menuselect 5&#8221;<br \/>\nalias ms6 &#8220;menuselect 6&#8221;<br \/>\nalias ms7 &#8220;menuselect 7&#8221;<br \/>\nalias ms8 &#8220;menuselect 8&#8221;<br \/>\nalias ms9 &#8220;menuselect 9&#8221;<br \/>\nalias ms0 &#8220;menuselect 0&#8221;<\/p>\n<p>It&#8217;s easier to make buying scripts by just using the ms0-9 commands. Also when<br \/>\nclosing a menu, you will often find that when you just use the &#8220;slot10&#8221;<br \/>\ncommand,<br \/>\nit will skip it and leave the menu open. To be sure your scripts operate<br \/>\nsmoothly, use the clmenu alias:<\/p>\n<p>alias clmenu &#8220;slot10; wait; slot10; wait; slot10; wait; slot10; wait; slot10;<br \/>\nwait; slot10; slot10; slot10; slot10; slot10&#8243;<\/p>\n<p>By adding the clmenu command at the end of all menu-using scripts, you are<br \/>\nensured the menu closes after the script has finished. Still not closing? Just<br \/>\nput two clmenu commands at the end ;-).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Counter Strike &#8211; Scripting CS Scripting guide by ethereal Half-Life Counter-Strike Scripting Welcome to the Counter-Strike scripting guide. This guide is meant for all the people who want to optimize their config and use clever and useful script to enhance &#8230; <a class=\"more-link\" href=\"http:\/\/www.wildow.com\/blog\/?p=111\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=111"}],"version-history":[{"count":0,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}