Teambalancer?
#1

Solved
Reply
#2

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;
}
Reply
#3

Solved
Reply
#4

where do i add this?
Reply
#5

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

Solved
Reply
#7

I didn't get errors when I compiled
Reply
#8

Solved
Reply
#9

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


Forum Jump:


Users browsing this thread: 2 Guest(s)