Writing CFG Mods Tutorial 2 - Command Strings

Command Strings


You should now have a basic understanding of configs right? We have dvars and commands and commands and … Well, you know what I mean.

So, what if I want RB to toggle godmode AND noclip (noclip is a command that will make your player ignore the games physics so you can fly around and through walls and whatnot). Well, we would do the following:

bind button_rshldr “god;noclip”


Take note that the button for RB is button_rshldr. We separate commands with a semicolon. And when I say commands, I mean all commands. So what if we wanted the right shoulder to toggle godmode, toggle noclip, AND set player_sustainammo to 1? Well, simple:

bind button_rshldr “god;noclip;set player_sustainammo 1”


Or, maybe we want to do:

bind button_rshldr “god;noclip;bind button_lshldr notarget”


Button_lshldr is the name of the left shoulder, or LB. Notarget is a command that will stop the enemy ai from targeting you. Now, what if we want to use RB to bind LB to two things? What if we want LB to be notarget AND dropweapon? Dropweapon is another command, hopefully you can figure that one out on your own... You might try:

bind button_rshldr “god;noclip;bind button_lshldr notarget;dropweapon”


Looks good right? WRONG. Each semicolon is separating the commands of button_rshldr, dropweapon will be a part of the RB bind, NOT part of LB. But what if we REALLY wanted to make RB bind LB to two things? Well, we MUST separate commands with semicolons, so logic would follow that if we want something to have two commands, we MUST use a semicolon. But we also know that if we use a semicolon, it will make whatever is after it another command for button_rshldr. So, you would want to do:

bind button_rshldr “god;noclip;bind button_lshldr “notarget;dropweapon””


This, or so you would hope, would tell the game “ignore that semicolon, it’s part of the value of the LB bind”. But alas, as mentioned before, putting that quote there will end the value of the RB bind. There is a solution, but you will learn about that later.

Remember that the entirety of bind button_rshldr “god;noclip;bind button_lshldr notarget” is, in itself,  a command. In config files, we separate these commands by putting them on different lines. We would bind other buttons like so:

bind button_rshldr “god;noclip;bind button_lshldr notarget”
bind button_back “set player_sustainammo 1”
bind button_a “set player_sustainammo 0”
bind button_b “set g_gravity 100”
set g_speed “300”


G_speed is the movement speed of players and g_gravity is the dvar for… well… gravity… The buttons that those button names correspond to should be pretty obvious. When we press back, we have unlimited ammo, when we press A, we don’t. These aren’t the most efficient binds, as the A and B buttons are used for jumping and knifing or crouching, but that was merely an example.

Like I said earlier, commands are separated by semicolons, so you could also do:

Bind button_rshldr “god;noclip;bind button_lshldr notarget”;bind button_back “set player_sustainammo 1”;bind button_a “set player_sustainammo 0”;bind button_b “set g_gravity 100”

That would work, but that looks really messy, and it makes it a lot easier to screw up. I should also clarify, you can’t do:

bind button_rshldr “god


…and expect it to make the commands part of the button_rshldr bind. When you go to a new line, it’s a new command. A COMPLETELY new command. The semicolons were separating the values of the RB bind, inside the value part of the bind command, so going to a new line would mean that we are no longer inside the value of the bind command.



 You should now know how to add multiple binds and set multiple dvars inside a config and to have multiple commands for those binds.


Click here for the next tutorial, other commands and other dvar domains.