Auto-team balance..
#1

So, how can I make if there are 5 people on one team, will not let you join until there are ~3 people on the other team?

Thanks
Reply
#2

You can like

pawn Code:
#define MAX_TEAM_MEMBERS 20                     //Change to yours...

//OnFilterScriptInIt
SetTimerEx("AutoBalance",600000,true,"d",playerid); //600000 = 10minutes.

forward AutoBalance(playerid);
public AutoBalance(playerid)
{
      //Use 'if' statement to see how many people on team, something like this
      if(gTeam[playerid] > MAX_TEAM_MEMBERS)
      {
              SetPlayerTeam(playerid,2); // Something like this should work.
      }
      return 1;
}
Reply
#3

Thanks
Reply
#4

A better idea:

pawn Code:
new TeamPlayers[ <Amount of teams here> ];

public OnPlayerRequestSpawn(playerid)
{
  for(new teams; teams < [Team Amount]; teams++)
  {
    if(teams == GetPlayerTeam(playerid)) continue; //Or gTeam[playerid], or w/e you use.
    if(TeamPlayers[Player Team Variable] > TeamPlayers[teams] + 3)
    {
      SendClientMessage(playerid, COLOR_RED, "You can't join this team as it would unbalance the game!");
      return 0;
    }
  }
}
Just a small sketch of a situation, unsure if I made some mistakes in my code though.
Reply
#5

I am looking for this too but sometimes there are like 6 players online and sometimes all are humans and sometimes everyone is a zombie because everyone is infected but then the teambalancer with the timer wont work because it wont reach the max teams and the one OnPlayerRequestSpawn wont work because when the Human gets infected he just changes skin, teams and weapons.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)