Help me with Team Balancer
#2

Take off of this example:

playerid - the player
team_1 - the team that is being calculated by the ratio
team_2 - the other team
ratio - the ratio of which to balance team 1 from team 2
teamvar - the variable to hold the player's team

EXAMPLE:
pawn Код:
OnPlayerSpawn(playerid)
{
  TeamBalance(playerid, TEAM_GREEN, TEAM_BLUE, 1, Team); // Sets the balance of the teams equal
}
pawn Код:
TeamBalance(playerid, team_1, team_2, ratio, teamvar[]) {
  new result_var = (Players() / ratio);
  for(new x = 0; x < MAX_PLAYERS; x++) {
   if(teamvar[x] == team_1) {
     count++;
   }
  }
  if(count < result_var) {
   teamvar[playerid] = team_1;
  } else {
   teamvar[playerid] = team_2;
  }
}
Reply


Messages In This Thread
Help me with Team Balancer - by Awerop - 09.04.2010, 12:33
Re: Help me - by Grim_ - 09.04.2010, 12:40
Re: Help me with Team Balancer - by Awerop - 09.04.2010, 12:46

Forum Jump:


Users browsing this thread: 2 Guest(s)