Random player
#2

pawn Code:
stock ChooseRandomPlayer() // Function by Admantis
{
    new TMP, TOTAL; // Creates TMP and TOTAL
    for(new I = 0; I < MAX_PLAYERS; I++) // Player loop
    {
        if (IsPlayerConnected(I)) { TMP += 1; } // If player is connected, count is increased
    }
    TOTAL = random(TMP); // TOTAL is equal of the random of online players
    return TOTAL; // Returning a value (TOTAL)
}
Example:
pawn Code:
gTeam[ChooseRandomPlayer()] = 1;
SetPlayerTeam(ChooseRandomPlayer(), 1);
Reply


Messages In This Thread
Random player - by Amine_Mejrhirrou - 18.04.2011, 22:31
Re: Random player - by admantis - 18.04.2011, 22:40
Re : Random player - by Amine_Mejrhirrou - 18.04.2011, 22:47
Re: Random player - by admantis - 18.04.2011, 22:55
Re : Random player - by Amine_Mejrhirrou - 18.04.2011, 23:07

Forum Jump:


Users browsing this thread: 1 Guest(s)