Creating simple pickup: Difference between revisions
Jump to navigation
Jump to search
Note:This was made for Orange Box version
Special thanks to SecobMod Team: Updating the code
(Created page with 'What: I will explain how you can add a simple pickup like you have in the singleplayer Version: Orange Box SDK. ------- First open "hl2mp_player.cpp" and search for "CHL2MP_Pla…') |
(fixed basically everything) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Note|This was made for Orange Box version}} | |||
------- | ------- | ||
First open "hl2mp_player.cpp" and search for "CHL2MP_Player::PickupObject".<br> | |||
First open "hl2mp_player.cpp" and search for "CHL2MP_Player::PickupObject". | Now replace it with the following code: | ||
< | |||
with: | |||
<source lang=cpp> | <source lang=cpp> | ||
void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize ) | void CHL2MP_Player::PickupObject( CBaseEntity *pObject, bool bLimitMassAndSize ) | ||
Line 23: | Line 10: | ||
return; | return; | ||
BaseClass::PickupObject(pObject, bLimitMassAndSize); | |||
// Can't be picked up if NPCs are on me | // Can't be picked up if NPCs are on me | ||
if ( pObject->HasNPCsOnIt() ) | if ( pObject->HasNPCsOnIt() ) | ||
return; | return; | ||
HideViewModels(); | |||
ClearActiveWeapon(); | |||
Weapon_Switch( Weapon_OwnsThisType( "nameofyourweaponentity" ) ); | |||
PlayerPickupObject( this, pObject ); | PlayerPickupObject( this, pObject ); | ||
} | } | ||
</source> | </source> | ||
{{Special thanks|SecobMod Team|Updating the code}} | |||
[[Category:Programming]] |
Latest revision as of 06:05, 11 September 2022

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 );
}
