18.08.2007, 13:57
Quote:
Originally Posted by tomozj
This gets a randomly selected connected ID. If none is connected, then in theory, it'll keep trying until someone does.
pawn Код:
pawn Код:
|
pawn Код:
stock GetRandomID()
{
new bool:connected[MAX_PLAYERS] = false, amount = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i))
{
connected[i] = true;
amount++;
}
if(amount = 0) return -1;
new rand = random(amount), done = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
if(connected[i])
{
if(done == rand) return i;
done++;
}
return -1;
}