SA-MP Forums Archive
teambalancer doesn't work 60% of the time :S - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: teambalancer doesn't work 60% of the time :S (/showthread.php?tid=125909)



teambalancer doesn't work 60% of the time :S - ~Dangun! - 06.02.2010

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;
}