Let me rephrase the question then ... is there a function that can will return a random player
stock War3_GetRandomPlayer( const String:type[] = "#a", bool:check_alive = false, bool:check_immunity = false )
{
new targettable[MaxClients];
new target = 0;
new bool:all;
new x = 0;
new team;
if( StrEqual( type, "#t" ) )
{
team = TEAM_T;
all = false;
}
else if( StrEqual( type, "#ct" ) )
{
team = TEAM_CT;
all = false;
}
else if( StrEqual( type, "#a" ) )
{
team = 0;
all = true;
}
for( new i = 1; i <= MaxClients; i++ )
{
if( i > 0 && i <= MaxClients && IsClientConnected( i ) && IsClientInGame( i ) )
{
if( check_alive && !IsPlayerAlive( i ) )
continue;
if( check_immunity && W3HasImmunity( i, Immunity_Ultimates ) )
continue;
if( !all && GetClientTeam( i ) != team )
continue;
targettable[x] = i;
x++;
}
}
for( new y = 0; y <= x; y++ )
{
if( target == 0 )
{
target = targettable[GetRandomInt( 0, x - 1 )];
}
else if( target != 0 && target > 0 )
{
return target;
}
}
return 0;
}
That's the code that it used to use... I'm happy to just reuse that, however if there is already a function in the interface that will do this, I'd prefer to not have to include another dependency.