Public feed #533137

SteveUK

public cpp v1 · immutable
Raw Edit
·published 2007-06-03 11:01 UTC
rendered paste body
inline CBasePlayer *AI_GetSinglePlayer(){	if ( gpGlobals->maxClients > 1 ) // SteveUK: Gotta add some kind of selection, random player? NEED BETTER CODE.	{		int iRandomPlayerID = random->RandomInt( 1, gpGlobals->maxClients ); // this maybe unreliable so we gotta check it!		for( int i = iRandomPlayerID; i != 0; i-- ) // this is to check if our player works, then it loops and finds a valid player ID below it.		{			CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); // try go for this player			if( pPlayer ) // valid player			{				return pPlayer;			}		}		return NULL;	}		return UTIL_GetLocalPlayer();}