3 Random
#4

pawn Код:
stock GetRandomPlayer(bool: init = false) {
    static
        iCount,
        iPlayers[MAX_PLAYERS]
    ;
    if(init) {
        for((_: init) = iCount = 0; (_: init) != MAX_PLAYERS; ++init) {
            if(IsPlayerConnected(_: init)) {
                iPlayers[iCount++] = _: init;
            }
        }
    }
    if(iCount != 0) {
        new
            rand = random(iCount)
        ;
        (_: init) = iPlayers[rand];
        iPlayers[rand] = iPlayers[--iCount];
        return _: init;
    }
    return INVALID_PLAYER_ID;
}
pawn Код:
new
    rand1 = GetRandomPlayer(true),
    rand2 = GetRandomPlayer(),
    rand3 = GetRandomPlayer()
;
But If I am not mistaken that foreach already got an random function (if you use it)
Reply


Messages In This Thread
3 Random - by COD - 06.05.2012, 16:26
Re: 3 Random - by [MG]Dimi - 06.05.2012, 16:52
Re: 3 Random - by 2KY - 06.05.2012, 17:09
AW: 3 Random - by Nero_3D - 06.05.2012, 17:24
Re: 3 Random - by COD - 06.05.2012, 18:26
Re: 3 Random - by 2KY - 06.05.2012, 18:28

Forum Jump:


Users browsing this thread: 1 Guest(s)