How do I pick a random admin?
#2

pawn Код:
new
    AdminsOnline = 0, //variable to save the number of admins online
    i = 0,
    m = GetMaxPlayers(); //getting the max number of players
for (; i < m, i++) if (IsPlayerAdmin) AdminsOnline++; //getting the number of admins online

new rand = random(AdminsOnline); //getting a random number

for (; i < m, i++)
{
    if(IsPlayerAdmin(playerid))
    {
        if (AdminsOnline <= 0)
        {
            //random admin code
            break;
        }
        AdminsOnline--;
    }
}

//if the random number is 3, the third admin you meet in the loop will be the random admin
Reply


Messages In This Thread
How do I pick a random admin? - by biltong - 05.04.2010, 11:14
Re: How do I pick a random admin? - by dice7 - 05.04.2010, 11:26
Re: How do I pick a random admin? - by biltong - 05.04.2010, 11:57
Re: How do I pick a random admin? - by biltong - 06.04.2010, 10:06
Re: How do I pick a random admin? - by campkz - 06.04.2010, 10:55

Forum Jump:


Users browsing this thread: 1 Guest(s)