Creating simple pickup

From Valve Developer Community
Jump to: navigation, search
Note.pngNote:This was made for Orange Box version

First open "hl2mp_player.cpp" and search for "CHL2MP_Player::PickupObject".
Now replace it with the following code:

void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize )
{
	// can't pick up what you're standing on
	if ( GetGroundEntity() == pObject )
		return;
	
	
	BaseClass::PickupObject(pObject, bLimitMassAndSize);
	
	// Can't be picked up if NPCs are on me
	if ( pObject->HasNPCsOnIt() )
		return;	
	
	HideViewModels();
	ClearActiveWeapon();
	
	Weapon_Switch( Weapon_OwnsThisType( "nameofyourweaponentity" ) );
	
	PlayerPickupObject( this, pObject );
}
Special thanks to SecobMod Team Updating the code