help/pick a random player
#5

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

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)];
}
Reply


Messages In This Thread
help/pick a random player - by RowdyrideR - 08.07.2011, 16:39
Re: help/pick a random player - by RowdyrideR - 08.07.2011, 17:34
Re: help/pick a random player - by =WoR=Varth - 09.07.2011, 01:39
Re: help/pick a random player - by RowdyrideR - 09.07.2011, 14:02
AW: help/pick a random player - by Nero_3D - 09.07.2011, 14:30

Forum Jump:


Users browsing this thread: 1 Guest(s)