[HELP]Round check bug
#2

You check the team counts in the middle of the loop which is counting them, do the stuff AFTER the loop and it'll work fine:

pawn Код:
public RoundCheck()
{
    Civilian = 0;
    Army = 0;
    Zombie = 0;
   
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid) && gPlayerLogged[playerid])
        {
            switch(gTeam[playerid])
            {
                case 0: Civilian++;
                case 1: Zombie++;
                case 2: Army++;
            }
        }
    }
   
    if(Zombie >= 2) // if there are more than 1 zombie...
    {
        if(Civilian <= 0 && Army <= 0) // ...and no civilians/soldiers
        {
            GameTextForAll("~w~Round has Ended", 3000, 3);
            SetTimer("ZombieWin", 2000, 0);
        }
    }
    else if(Zombie <= 0) // else if there are no zombies...
    {
        if(Civilian >= 2) // ...and more than 1 civilian
        {
            new zombie = INVALID_PLAYER_ID;
            while(!IsPlayerConnected(zombie)) // This will be fucked up due to PAWN's retarded random()-function, sometimes this loop might take ages until it ends cuz of random() returning the same IDs again and again.
            {
                  zombie = random(MAX_PLAYERS);
            }

            gTeam[zombie] = 1;
            Infected[zombie] = 1;
            OnPlayerSpawn(zombie);
            SendClientMessage(zombie, COLOR_RED, "Server has picked you to be Zombie");
            ResetPlayerWeapons(zombie);
        }
    }
   
    return 1;
}
Reply


Messages In This Thread
[HELP]Round check bug - by Julian2574 - 15.07.2010, 12:00
Re: [HELP]Round check bug - by Finn - 15.07.2010, 13:02
Re: [HELP]Round check bug - by Julian2574 - 15.07.2010, 13:08

Forum Jump:


Users browsing this thread: 1 Guest(s)