09.07.2011, 14:30
foreach is an include which provides faster loops, it also includes a function to get a random player
Just read the foreach topic and if you like it you could use the code varthshenon provided
If not use that
Just read the foreach topic and if you like it you could use the code varthshenon provided
If not use that
pawn Код:
stock GetRandomPlayer() {
new
i = 0,
count = 0,
player[MAX_PLAYERS];
for( ; i != MAX_PLAYERS; ++i) {
if(IsPlayerConnected(i)) {
player[count++] = i;
}
}
if(count == 0) {
return INVALID_PLAYER_ID;
}
return player[random(count)];
}