Making a 2Teams (Variables) Balancer
#1

Hey i have 2 teams

Код:
new TEAM_COP[MAX_PLAYERIS];
new TEAM_PRIS[MAX_PLAYERS];
and i need to make a team balancer
soo theres not like 15 cops
and like 2 prisoners

Can anyone help?
Reply
#2

pawn Код:
//where you set teams
if ( team_count_A > team_count_B )
{
  //set to team B
}
else if ( team_count_B > team_count_A )
{
  //set to team A
}
else
{
  //set them to the one they picked
}
Reply
#3

Quote:
Originally Posted by Donny
pawn Код:
//where you set teams
if ( team_count_A > team_count_B )
{
  //set to team B
}
else if ( team_count_B > team_count_A )
{
  //set to team A
}
else
{
  //set them to the one they picked
}
I don't quite understand?
Reply
#4

**BUMP
Reply
#5

Quote:
Originally Posted by aspire5630
**BUMP
just check OnPlayerSpawn or where u want to check that
if team got more player or if team b got more
if yes set the player to the other team or whatever u want to do then
to check how much ppl are on the team ull need to make a loop
which goes through ur maxplayers n check everyone if they are on team a or team b
(u need 2 new variables in the loop one for team a and one for b) then if the player it just loops through is team a it sets variable a++;
and if he is team b it sets variable b++;
after that it should check what i explained above
Reply
#6

what do you mean like if there are 15 cops and 10 prisoners it auto makes you prisoner because too much cops
Reply
#7

yeh, what it will do

say..

4 prisoners...
it will make the next people who log on
Cops

Just to balance the teams
Reply
#8

Quote:
Originally Posted by aspire5630
yeh, what it will do

say..

4 prisoners...
it will make the next people who log on
Cops

Just to balance the teams
Quote:
Originally Posted by ┤ŞąiBЄЯҒПŋ├
Quote:
Originally Posted by aspire5630
**BUMP
just check OnPlayerSpawn or where u want to check that
if team got more player or if team b got more
if yes set the player to the other team or whatever u want to do then
to check how much ppl are on the team ull need to make a loop
which goes through ur maxplayers n check everyone if they are on team a or team b
(u need 2 new variables in the loop one for team a and one for b) then if the player it just loops through is team a it sets variable a++;
and if he is team b it sets variable b++;
after that it should check what i explained above
Reply
#9

Код:
//top
new team_count_A;
new team_count_B;

//OnPlayerRequestSpawn
if ( team_count_A > team_count_B )
{
  //deny team A and set to team B
}
else if ( team_count_B > team_count_A )
{
  //deny team B and set to team A
}
else
{
  //set them to the one they picked
}

//OnPlayerSpawn

If(gTeam=TEAM_COP)
{
//add the value "1" to the variable new team_count_A;
}
else if(gTeam=TEAM_PRIS)
{
//add the value "1" to the variable new team_count_B;
}

//OnPlayerDisconnect

If(gTeam=TEAM_COP)
{
//subtractthe value "1" to the variable new team_count_A;
}
else if(gTeam=TEAM_PRIS)
{
//subtract the value "1" to the variable new team_count_B;
}
Reply
#10

Quote:
Originally Posted by [KG
Nikere ]
Код:
//top
new team_count_A;
new team_count_B;

//OnPlayerRequestSpawn
if ( team_count_A > team_count_B )
{
  //deny team A and set to team B
}
else if ( team_count_B > team_count_A )
{
  //deny team B and set to team A
}
else
{
  //set them to the one they picked
}

//OnPlayerSpawn

If(gTeam=TEAM_COP)
{
//add the value "1" to the variable new team_count_A;
}
else if(gTeam=TEAM_PRIS)
{
//add the value "1" to the variable new team_count_B;
}

//OnPlayerDisconnect

If(gTeam=TEAM_COP)
{
//subtractthe value "1" to the variable new team_count_A;
}
else if(gTeam=TEAM_PRIS)
{
//subtract the value "1" to the variable new team_count_B;
}
u guys forget the loop



pawn Код:
//OntopOfScript
new team1count,team2count;


//OnPlayerREquestSpawn/Sumwhere in script
OnPlayerRequestSpawn(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(GetPlayerTeam(i) == GTEAM_ONE)
      {
      team1count++;
      }
      if(GetPlayerTeam(i) == GTEAM_TWO)
      {
      team2count++;
      }
    }
    if(team1count > team2count)
    {
      SetPlayerTeam(playerid,2);
    }
    if(team2count > team1count)
    {
      SetPlayerTeam(playerid,1);
    }
    if(team2count == team1count)
    {
     //Set the Selected Team(however u want to do it.
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)