how to make auto team balance?
#1

How will i make auto team balance?

if(classid == 0)
{
gTeam[playerid] = TEAM_USA;
}
else if(classid == 1)
{
gTeam[playerid] = TEAM_GERMANY;
}
else if(classid == 2)
{
gTeam[playerid] = TEAM_MERC;
}
else if(classid == 3)
{
gTeam[playerid] = TEAM_RUSSIA;
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_JAPAN;
}
Reply
#2

pawn Код:
new TeamPlayers[ <Amount of teams here> ];

public OnPlayerRequestSpawn(playerid)
{
    for(new teams; teams < [Team Amount]; teams++)
    {
        if(teams == gTeam[playerid]) continue;
        if(TeamPlayers[gTeam[playerid]] > TeamPlayers[teams] + 3)
        {
            SendClientMessage(playerid, COLOR_RED, "You can't join this team as it would unbalance the game!");
            return 0;
        }
    }  
}
//By Hiddos
So... Example usage:
pawn Код:
public OnPlayerRequestSpawn( playerid )
{
    for( new teams; teams < 23; teams++ )
    {
        if( teams == gTeam[ playerid ] ) continue;
        if( TeamPlayers[ gTeam[ playerid ] ] > TeamPlayers[ teams ] + 3)
        {
            SendClientMessage( playerid, COLOR_RED, "You can't join this team as it would unbalance the game!" );
            return 0;
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)