12.07.2017, 17:43
Quote:
|
Select Random Player
PHP Code:
|
PHP Code:
SelectRandomPlayer()
{
new players[MAX_PLAYERS], count;
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
{
IsPlayerConnected(i) && (players[count ++] = i);
}
return ((!count) ? (-1) : (players[random(count)]));
}
Alternatively (for a tad better performance):
or
Have a global array store connected players and remove the ones that leave, filling the slots in a continuous order.


