Source 101: Buy Scripts
As always, if you have something you would like to see covered, either post in the Source 101 Forum Thread or send me an email at yankeedeuce [at] straferight.com.
To start your buy script, open up a text editor like notepad. Personally I use PSPad as my text editor. Once you have your editor open go to C:\Program Files\Steam\SteamApps\USERNAME\counter-strike source\cstrike\cfg and open up your autoexec.cfg (If you don't have one, read Source 101 - Getting Started)
Binds
For our first script, we are going to bind your F1 key to buy an M4. At the bottom of your autoexec, type bind "F1" "buy m4a1". Now when you are ingame, pressing F1 will buy an M4. However, you still have to buy your ammo, armor, and grenades. To bind multiple commands to a button, seperate them using a semicolon (;). To buy ammo with your M4, change the line to bind "F1" "buy m4a1; buy primammo"
Since you can only buy an M4 as a CT, let's change our bind to the following: bind "F1" "buy m4a1; buy ak47; buy primammo". Now when you press F1 you will buy either an M4 or AK47 with full ammo depending on what team you are on.
Using this script you can buy any combination of weapons and equipment, as long as you have the money available. Also, be sure not to buy an M4 and AUG, or any 2 weapons you can buy normally, or it will buy both. Only have a CT weapon and T weapon bound to the same key. Below is a list of the CVARs to use when buying weapons.
| CVAR | Weapon | CVAR | Weapon | |
| glock | Glock | m249 | M249 | |
| usp | USP | scout | Scout | |
| p228 | P228 | g3sg1 | T Autosniper | |
| deagle | Desert Eagle | sg550 | CT Autosniper | |
| elite | Dual Elites | awp | AWP | |
| fiveseven | FiveseveN | primammo | Full Primary Ammo | |
| mac10 | MAC 10 | secammo | Full Pistol Ammo | |
| tmp | TMP | secammo | Full Pistol Ammo | |
| mp5 | MP5 | buyammo1 | 1 Clip of Primary Ammo | |
| ump45 | UMP | buyammo2 | 1 Clip of Pistol Ammo | |
| p90 | P90 | defuser | Defuse Kit | |
| m3 | Shotgun | flashbang | Flashbang | |
| xm1014 | Autoshotty | hegrenade | HE Grenade | |
| galil | Galil | smokegrenade | Smoke Grenade | |
| famas | FAMAS | vest | Kevlar Vest | |
| ak47 | AK47 | vesthelm | Kevlar Vest and Helmet | |
| m4a1 | M4 | nvgs | Night Vision Goggles | |
| sg552 | Krieg | |||
| aug | AUG |
Aliases
Aliases are another part of creating your buyscript. You can use an alias to give a CVAR name to a command or series of commands to use. I have more on aliases later as general things to make it easier for you. For now, the basics:
To create an alias type alias "rifle1" "buy m4a1; buy ak47". Now when creating your buyscript, instead of typing buy m4a1; buy ak47, you can just type rifle1. I generally set up aliases for tmp/mac10, fiveseven/elite, famas/galil, m4a1/ak47, aug/sg552, the autosnipers, and full primary/secondary ammo.
The way I have my buyscript set up is so I use my keypad. I use a basic setup with my weapons, equipment, and ammo seperate so I can get exactly what I need. While having a setup where you buy everything with one key would work in a pub, in matches where money is an important part of your strategy, having everything seperate gives you a little more control.
Here is the actual script that I use, with comments showing exactly what the binds do.
bind "DEL" "buy defuser" //Buys a defuser
bind "KP_HOME" "buy scout" //Buys a Scout
bind "KP_UPARROW" "buy_autosniper" //Buys an Autosniper depending on team
bind "KP_PGUP" "buy awp" //Buys an AWP
bind "KP_LEFTARROW" "buy_rifle1" //Buys a FAMAS or Galil depending on team
bind "KP_5" "buy_rifle2" //Buys an AUG or Krieg depending on team
bind "KP_RIGHTARROW" "buy_rifle3" //Buys a M4 or AK depending on team
bind "KP_END" "buy_ammo" //Buys full ammo
bind "KP_DOWNARROW" "buy deagle" //Buys a Desert Eagle
bind "KP_PGDN" "buy mp5" //Buys a MP5
bind "KP_ENTER" "buyammo1" //Buys 1 Clip of Primary Ammo
bind "KP_INS" "buy vesthelm" //Buys full armor
bind "KP_DEL" "buy vest" //Buys light armor
bind "KP_SLASH" "buy flashbang" //Buys a flashbang
bind "KP_MINUS" "buy smokegrenade" //Buys a Smoke Grenade
bind "KP_PLUS" "buyammo2" //Buys 1 Clip of Pistol Ammo
Things to make your life easier
Here are a couple of scripts that I use that make a few things easier. I use my MOUSE4 to switch to my primary weapon and MOUSE5 to switch to my secondary. Instead of binding both MOUSE4 and 1 to slot1, I use these aliases:
alias use_primary "use weapon_mp5navy; use weapon_m4a1; use weapon_m249; use weapon_p90; use_primary2"
alias use_primary2 "use weapon_scout; use weapon_awp; use weapon_g3sg1; use weapon_sg550; use_primary3"
alias use_primary3 "use weapon_sg552; use weapon_aug; use weapon_tmp; use weapon_mac10; use weapon_ak47; use_primary4"
alias use_primary4 "use weapon_ump45; use weapon_xm1014; use weapon_m3; use weapon_famas; use weapon_galil"
alias use_secondary "use weapon_usp; use weapon_glock; use weapon_deagle; use weapon_p228; use weapon_elite; use weapon_fiveseven"
alias buy_ammo "buy primammo; buy secammo"
Now I can have 1 bound to slot1 and bind MOUSE4 to use_primary. When I press either button it will switch to my primary weapon. Same thing with 2 and MOUSE5 after using the alias, either one will switch to my pistol.
Another thing I use aliases for is joining servers. I know you have gone to play on your favorite strafeRight server and found that all of your Favorites are gone. This makes it so you can always join your favorite servers. All you need to know is the servers IP and the password if it is a private server.
alias "/roto" "connect 209.40.96.71:27015"
alias "/office" "connect 209.40.96.71:27016"
alias "/assault" "connect 209.40.96.71:27023"
alias "/private" "connect 209.40.96.70:27020;password serverpwd"
Now whenever you want to join the strafeRight 24/7 Office Server, just type /office in your console, hit enter and you're in.
The other 2 scripts that I use are for demos and movie making. They allow me to push 1 button to start recording, a second push to stop, and a third push to start recording another demo or movie, so on for up to 50 demos.
Also, instead of placing all my aliases in my autoexec, I made another config with all the aliases in it and added a single line to my autoexec: exec alias.cfg. I do the same with my demo and movie scripts so my config files are short and clean.
It is now 4:20AM, so I am off to grab a little sleep (or more likely go play some Source) before work tomorrow. If you have any questions about scripts, binds, or aliases let me know and I'll do my best to answer it. As always, if you would like to see something in Source 101 be sure to let me know.



del.icio.us
Digg
Comments (0 posted):
Post your comment