Try this function:
Code:
get_random_players(players[], total, flags[]="a", team[]="")
{
new temp_players[32], pnum;
get_players(temp_players, pnum, flags, team);
new retrieve = min(pnum, total);
new i, rand, j;
for(i = 0; i < retrieve; i++ )
{
rand = random(pnum);
players[i] = temp_players[rand];
for( j = rand; j < pnum; j++ )
{
if( (j + 1) == pnum )
{
temp_players[j] = 0;
}
else
{
temp_players[j] = temp_players[j + 1];
}
}
pnum--;
}
return i;
}
Usage:
To get 5 alive players:
Code:
new players[32];
new pnum = get_random_players(players, 5, "a");
To get 5 CT players:
Code:
new players[32];
new pnum = get_random_players(players, 5, "e", "CT");
Notice how the flags and team work just like the get_players() function.
__________________