Posted by: bigguy
Date posted: Sep 21 2003 User Rating: 5 out of 5.0 | Number of views: 1766 Number of comments: 0 | Description: Function to remove named items from a player's inventory. |
Originally posted on Half-Life Programming Planet.
Add this new prototype to player.h:
| | | virtual void Spawn( void ); void Pain( void );
BOOL RemoveNamedPlayerItem ( const char *pszItemName );
|
Put this somewhere in player.cpp:
| | |
BOOL CBasePlayer::RemoveNamedPlayerItem( const char *pszItemName ) { CBasePlayerItem *pItem; int i;
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) { pItem = m_rgpPlayerItems[ i ];
while (pItem) { if ( !strcmp(pszItemName, STRING(pItem->pev->classname ) ) ) { RemovePlayerItem ( pItem ); return TRUE; } pItem = pItem->m_pNext; } } return FALSE; } |
Then just call it something like this:
| | | pPlayer->RemoveNamedPlayerItem( "weapon_minigun" );
| |
|
User Comments
No User Comments
You must register to post a comment. If you have already registered, you must login.
|