PDA

View Full Version : Question royalhack ToBasePlayer



peterslone
10-03-2009, 04:07 PM
C_BasePlayer *pBasePlayer = NULL;

.....


IClientEntity* ClientEntity = HalFLife2.m_pEntList->GetClientEntity( index );

if ( ClientEntity == NULL
|| ClientEntity->IsDormant() )
continue;

CBaseEntity* pBaseEntity = ClientEntity->GetBaseEntity();

if ( pBaseEntity == NULL
|| pBaseEntity->IsDormant() )
continue;

pBasePlayer = ToBasePlayer(pBaseEntity);

if(pBasePlayer == NULL)
continue;



why is this allways pBasePlayer null/0 ?

Xeno123
10-03-2009, 04:09 PM
Hard to tell when A. you just told us "your code" is not yours, B. your using a base that is years old, and C. we don't know what the hell that function does. Post the code of it.

peterslone
10-03-2009, 04:30 PM
the TITLE says royalhack you are jumping again xeno :) .

this function is in the sdk


inline C_BasePlayer *ToBasePlayer( C_BaseEntity *pEntity )
{
if ( !pEntity || !pEntity->IsPlayer() )
return NULL;

#if _DEBUG
Assert( dynamic_cast<C_BasePlayer *>( pEntity ) != NULL );
#endif

return static_cast<C_BasePlayer *>( pEntity );
}

Xeno123
10-03-2009, 04:34 PM
FAAAAIL. Ok you're right. Hm, and you're sure the entity is valid. Interesting. (Sorry for jumping at you, I tend to do that :|).

badster19
10-04-2009, 06:55 AM
It's simple, the IsPlayer() always returns an odd value since the SDK is outdated. Why don't you just recreate the function and use static_cast to cast a BaseEntity to a BasePlayer?

peterslone
10-04-2009, 10:57 AM
i will try that now badster

Xeno123
10-04-2009, 10:58 AM
C_BasePlayer* ToBasePlayer ( C_BaseEntity* pBaseEnt )
{
return static_cast<C_BasePlayer*>(pBaseEnt);
}

peterslone
10-04-2009, 12:33 PM
the IsPlayer() always returns an odd value






C_BasePlayer* pBasePlayer = ((CBasePlayer*)pBaseEntity);



thanks