How to make team balance?
#1

Hi,
I have a question.
How can i balance 2 teams? So, when 1 join and in the team COPS are 5 players and in the team BALLAS are 4 players he can only go to team BALLAS?
I searched for it and found a topic but that was for 4 teams. I have only 2 teams.

PS: My old topic was deleted, i don't know why.
Reply
#2

im joining the question
Reply
#3

1. get the teammebers with a varibale
2. check if the one team (lol wrote time) have more players as the other
Reply
#4

@Seif doesnt SendClientMessage return 1 ? so the player can still spawn ?
Reply
#5

how would u do it with three teams
Reply
#6

Quote:
Originally Posted by whooper
how would u do it with three teams
Maybe that way?

Код:
new count1, count2, count3;
for(new p = 0; p < GetMaxPlayers(); p++)
{
  if (Class[p] == TEAM_COPS)
  {
    count1++;
  }
  else if (Class[p] == TEAM_BALLAS)
  {
    count2++;
  }
  else if (Class[p] == TEAM_THIRD)
  {
    count3++;
  }
}
if (((count1 > count2) || (count1 > count3)) && Class[playerid] == TEAM_COPS)
  return SendClientMessage(playerid, color_here, " This team is full!");
else if (((count2 > count1) || (count2 > count3)) && Class[playerid] == TEAM_BALLAS)
  return SendClientMessage(playerid, color_here, " This team is full!");
else if (((count3 > count1) || (count3 > count2)) && Class[playerid] == TEAM_THIRD)
  return SendClientMessage(playerid, color_here, " This team is full!");
Reply
#7

So how do i set the max number that can be on that team
Reply
#8

adminuser I dont thing the "or" is good because
if TEAM_COP have 8 people TEAM_BALLAS 9 and TEAM_THIRD 2 members
so if you are team cop you will get the is full message
because the members of team cop are 8 also bigger as the members of TEAM_THIRD (2)

with && it should work - TEAM_THIRD is now TEAM_GROVE
pawn Код:
new count[3];
for(new p = 0; p < GetMaxPlayers(); p++)
{
    if (Class[p] == TEAM_COPS) count[0]++;
    else if (Class[p] == TEAM_BALLAS) count[1]++;
    else if (Class[p] == TEAM_GROVE) count[2]++;
}
switch(Class[playerid])
{
    case TEAM_COPS: if(count[0] > count[1] && count[0] > count[2]) return SendClientMessage(playerid, color_here, "This team is full!");
    case TEAM_BALLAS: if(count[1] > count[0] && count[1] > count[2]) return SendClientMessage(playerid, color_here, "This team is full!");
    case TEAM_GROVE: if(count[2] > count[0] && count[2] > count[1]) return SendClientMessage(playerid, color_here, "This team is full!");
}
Reply
#9

Stop, in your script:

What is when there are 5 Cops, 8 Ballas and 2 Groves and you choose cop?

case TEAM_COPS: if(count[0] > count[1] && count[0] > count[2])

=> count[0] > count[1] - NO, BUT - count[0] > count[2] - YES

So you would have a problem too i think, dont you ?

Because in your script the team must be bigger than BOTH other teams not if there is one team smaller than this one


I would say my script is right because he can only choose the smallest team... the team with the fewest players....
Reply
#10

so hwo to set the max nub=mber thta can spawn on that team
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)