teambalancer doesn't work 60% of the time :S
#1

Sometimes my teambalancer just doesn't work. 1 time it works fine. the other time it's not.


I have no clue why.. This is the code:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    new TeamA, TeamB;
    for(new i, m = GetMaxPlayers(); i < m; i++)
    {
        if (IsPlayerConnected(i))
        {
            if (gTeam[i] == TEAM_ATTACK) TeamA++;
            else if (gTeam[i] == TEAM_DEFEND) TeamB++;
        }
    }
    if (gTeam[playerid] == TEAM_ATTACK)
    {
      TeamA--;
        if (TeamA > 0 && TeamB > 0) TeamA = ((TeamA*100)/(TeamA+TeamB));
        else return 1;
        if (TeamA >= 52) // if TeamA is 52% or higher
        {
            TextDrawShowForPlayer(playerid, text16);
            SetTimer ("Destroy16", 1000, false);
            return 0;
        }
    }
    else if (gTeam[playerid] == TEAM_DEFEND)
    {
      TeamB--;
        if (TeamA > 0 && TeamB > 0) TeamB = ((TeamB*100)/(TeamB+TeamA));
        else return 1;
        if (TeamB >= 52) // if TeamB is 52% or higher
        {
            TextDrawShowForPlayer (playerid, text16);
            SetTimer ("Destroy16", 1000, false);
            return 0;
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)