Public feed #533168

SteveUK

public cpp v1 · immutable
Raw Edit
·published 2007-06-03 11:13 UTC
rendered paste body
inline CBasePlayer *AI_GetSinglePlayer( Vector vPos = Vector( 0, 0, 0 ) ){	if ( gpGlobals->maxClients > 1 ) // SteveUK: Gotta add some kind of selection, random player? NEED BETTER CODE.	{		float fBestDist = 0;		CBasePlayer *pIdealPlayer = NULL;		for( int i = 1; i <= gpGlobals->maxClients; i++ ) // loop through all these players;		{			CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); // get the player by the index the loops at			if( pPlayer ) // valid player pointer!			{				float t_len = ( pPlayer->GetAbsOrigin() - vPos ).Length(); // get the length from our origin.				if( t_len < fBestDist ) // if we're closer to those bitches				{					pIdealPlayer = pPlayer; // set the ideal player					fBestDist = t_len; // set the best distance for further comparisons				}			}		}		return pIdealPlayer; // return the ideal player	}		return UTIL_GetLocalPlayer();}