Weapons on Spawn: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "This is a copy and paste tutorial that will allow you to give a player weapons on spawn. This has been tested with Source 2007 Single Player (Orangebox). This may work in Source...")
 
No edit summary
Line 77: Line 77:
</source>
</source>


Have fun! [[User:Bitl|Bitl]]
Have fun! - [[User:Bitl|Bitl]]

Revision as of 08:54, 29 May 2013

This is a copy and paste tutorial that will allow you to give a player weapons on spawn.

This has been tested with Source 2007 Single Player (Orangebox). This may work in Source 2006 Single Player (Episode 1). This tutorial does NOT apply to multiplayer mods since the player already spawns with weapons (see hl2mp_player.cpp for more information).

Requirements

  • Source 2007 Single Player (Orangebox) OR Source 2006 Single Player (Episode 1)
  • A brain.

Implementing

Open up player.cpp in your server project and find this line:

ConVar  player_debug_print_damage( "player_debug_print_damage", "0", FCVAR_CHEAT, "When true, print amount and type of all damage received by player to console." );

Under it add:

ConVar	sk_player_weapons( "sk_player_weapons","0" );

Then find:

void CBasePlayer::Spawn( void )

And add this at the end:

if (sk_player_weapons.GetBool())
{
	// Give the player everything!
	GiveAmmo( 255,	"Pistol");
	GiveAmmo( 255,	"AR2");
	GiveAmmo( 255,	"SMG1");
	GiveAmmo( 255,	"Buckshot");
	GiveAmmo( 32,	"357" );
	//#ifdef HL2_EPISODIC
	//GiveAmmo( 5,	"Hopwire" );
	//#endif		
	GiveNamedItem( "weapon_smg1" );
	GiveNamedItem( "weapon_crowbar" );
	GiveNamedItem( "weapon_pistol" );
	GiveNamedItem( "weapon_ar2" );
	GiveNamedItem( "weapon_shotgun" );
	GiveNamedItem( "weapon_357" );	
}

Here's all weapons and all ammo types (from line 6055 in player.cpp)

		GiveAmmo( 255,	"Pistol");
		GiveAmmo( 255,	"AR2");
		GiveAmmo( 5,	"AR2AltFire");
		GiveAmmo( 255,	"SMG1");
		GiveAmmo( 255,	"Buckshot");
		GiveAmmo( 3,	"smg1_grenade");
		GiveAmmo( 3,	"rpg_round");
		GiveAmmo( 5,	"grenade");
		GiveAmmo( 32,	"357" );
		GiveAmmo( 16,	"XBowBolt" );
		
		GiveNamedItem( "weapon_smg1" );
		GiveNamedItem( "weapon_frag" );
		GiveNamedItem( "weapon_crowbar" );
		GiveNamedItem( "weapon_pistol" );
		GiveNamedItem( "weapon_ar2" );
		GiveNamedItem( "weapon_shotgun" );
		GiveNamedItem( "weapon_physcannon" );
		GiveNamedItem( "weapon_bugbait" );
		GiveNamedItem( "weapon_rpg" );
		GiveNamedItem( "weapon_357" );
		GiveNamedItem( "weapon_crossbow" );

Have fun! - Bitl