[UnSolved] Team balancing?
#5

pawn Код:
stock FindSmallestCell(array[],len=sizeof(array))
{
  new _smallest,_value=0x7FFFFFFE; //_value = Largest Possible Value
  for(new cell;cell<len;cell++)
  {
    if(array[cell]<_value)
    {
      _smallest=cell;
      _value=array[cell];
    }
  }
  return _smallest;
}
You would use this with a variable like
pawn Код:
new TeamAmounts[AMOUNT_OF_TEAMS];
Which you would add to everytime a player joins a particular team so if you wanted to find the team for a player you'd try this
pawn Код:
pTeam[playerid]=FindSmallestCell(TeamAmounts,AMOUNT_OF_TEAMS); //Find the team for the player and set that player to that team
TeamAmounts[pTeam[playerid]]++; //Add to that teams 'TeamAmount'


This could also be used to re-balance the teams

pawn Код:
RebalanceTeams()
{
  for(new team;team<AMOUNT_OF_TEAMS;team++)TeamAmounts[team]=0;
  for(new playerid;playerid<MAX_PLAYERS;playerid++)
  {
    if(!IsPlayerConnected(playerid))continue;
    pTeam[playerid]=FindSmallestCell(TeamAmounts,AMOUNT_OF_TEAMS);
    TeamAmounts[pTeam[playerid]]++;
  }
}
Reply


Messages In This Thread
[UnSolved] Team balancing? - by bajskorv123 - 09.02.2010, 18:40
Re: [UnSolved] Team balancing? - by Torran - 09.02.2010, 18:41
Re: [UnSolved] Team balancing? - by [XAC]Klinsen - 09.02.2010, 19:03
Re: [UnSolved] Team balancing? - by Ironboy500 - 09.02.2010, 19:53
Re: [UnSolved] Team balancing? - by Joe Staff - 09.02.2010, 20:02

Forum Jump:


Users browsing this thread: 1 Guest(s)