First most people know what impulse commands are but just in case you don't I will give you a quick run down. Impulse commands are essentially cheat codes most common know is impulse 101 which gives you all the weapons.
So there is 2 requirements for making these cheats, first they must have a unique case value, already used values are 99, 100, 201, 76, 101, 102, 103, 104, 105, 106, 107, 195,196, 197, 199, 202, 203. The second requirement is the value must be a number no letters. We will be doing this whole tutorial in player.cpp server side code.
Lets get started with the weapon/ item spawn first search case 101 and you should see the impulse commands scroll above one of them and add these lines of code.
case 1:
GiveNamedItem( "item_suit" );
GiveNamedItem( "item_battery" );
GiveNamedItem( "item_battery" );
GiveNamedItem( "item_battery" );
GiveNamedItem( "item_battery" );
GiveNamedItem( "item_battery" );
break;
This is very simple, case 1 sates that when the player types impulse 1 into the console it will activate this command. The GiveNamedItem( "item_suit" ); tells it to give player a suit, change item_suit to what ever item you want to spawn or what ever weapon. See how simple that was
Now lets do the harder code, we are going to spawn a monster like impulse 76 were it spawns a human grunt. We are going to spawn a rat to annoy code stealers it will be really easy to do your self if you actually read this. Here is the basic code we need to add in the player.cpp
case 7:
{
if (!giPrecahceRat)
{
giPrecahceRat = 1;
ALERT(at_console, "You must now restart to use Sawn-o-matic.\n");
}
else
{
UTIL_MakeVectors( Vector( 0, pev->v_angle.y, 0 ) );
Create("monster_rat", pev->origin + gpGlobals->v_forward * 128, pev->angles);
}
break;
}
Lets see what we have now. giPrecahceRat is seen 2 times the both have to be the same, this tells the code to set giPrecahceRat to 1 instead of 0 which we will add in a minute. and monster_rat is what it is going to spawn. ALERT(at_console, "You must now restart to use Sawn-o-matic.\n"); is suppose to tell the console to say restart but it does not work. Now search int gmsgShake = 0; and add this right above it
int giPrecahceRat =1;
this is the code I was talking about a minute ago, if this value is 0 then the spawner is off, when you enter the command it will turn on but if you enter it again to spawn the monster it will kick you out of the game because you did not restart. If you set it to 1 like we just did enter the command 1 time will spawn the monster with no restart required. Now go to your client.cpp and scroll down to you see
extern int giPrecacheGrunt;
and above that add
extern int giPrecahceRat;
Now we need to precache it scroll down till you see if if
(giPrecacheGrunt)
UTIL_PrecacheOther("monster_human_grunt");
and under that add
if (giPrecahceRat)
UTIL_PrecacheOther("monster_rat");
Now you are all done have fun with your new cheats
Really nice!