SA-MP Forums Archive
Teambalancer? - 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? (/showthread.php?tid=160115)



Teambalancer? - Kitten - 15.07.2010

Solved


Re: Teambalancer? - bigcomfycouch - 15.07.2010

untested
pawn Код:
BalanceTeams(team1, team2)
{
    new count[2], dif;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(playerid)) continue;
        if(GetPlayerTeam(i) == team1) count[0]++;
        else if(GetPlayerTeam(i) == team2) count[1]++;
    }
    dif = count[0] - count[1];
    if(dif >= 2)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(playerid) || dif <= 1) continue;
            if(GetPlayerTeam(i) == team2)
            {
                SetPlayerTeam(i, team1);
                dif--;
            }
        }
        return;
    }
    else if(dif <= -2)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(playerid) || dif >= -1) continue;
            if(GetPlayerTeam(i) == team1)
            {
                SetPlayerTeam(i, team2);
                dif++;
            }
        }
        return;
    }
    return;
}



Re: Teambalancer? - Kitten - 15.07.2010

Solved


Re: Teambalancer? - Kitten - 15.07.2010

where do i add this?


Re: Teambalancer? - bigcomfycouch - 15.07.2010

Anywhere in your script ( as long as it's not inside a function ). Call it just as you would call any other function.


Re: Teambalancer? - Kitten - 15.07.2010

Solved


Re: Teambalancer? - bigcomfycouch - 15.07.2010

I didn't get errors when I compiled


Re: Teambalancer? - Kitten - 15.07.2010

Solved


Re: Teambalancer? - bigcomfycouch - 15.07.2010

all you have to do is change the GetPlayerTeam and SetPlayerTeam incase you use a variable like gTeam, the parameters are fine