[HELP]Round check bug
#1

Well ladies and Gentlemen since J.Bull ( Jack Bull ) destroyed his project, Infected SA-MP, I told him I would take it over and thats what I did but the problem at moment is the "Round CHECK" who checks how many players each time has and if the civilians and army got 0 members each it will tell the zombies auto win but the problem is that when there's 3+ players on it auto says zombie wins! Even if there's 2 civilians or 2 army guys on and 1 zombie.

ROUND CHECK CODE:
http://pastebin.com/7KD6uSvJ
Reply
#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
#3

Thanks mate :P I'll test it soon ^^
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)