How to make team balance? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make team balance? (
/showthread.php?tid=41693)
How to make team balance? -
kevin433 - 29.06.2008
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.
Re: How to make team balance? -
whooper - 20.08.2008
im joining the question
Re: How to make team balance? -
Nero_3D - 20.08.2008
1. get the teammebers with a varibale
2. check if the one team (lol wrote time) have more players as the other
Re: How to make team balance? -
Nero_3D - 20.08.2008
@Seif doesnt SendClientMessage return 1 ? so the player can still spawn ?
Re: How to make team balance? -
whooper - 20.08.2008
how would u do it with three teams
Re: How to make team balance? -
adminuser - 20.08.2008
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!");
Re: How to make team balance? -
whooper - 20.08.2008
So how do i set the max number that can be on that team
Re: How to make team balance? -
Nero_3D - 20.08.2008
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!");
}
Re: How to make team balance? -
adminuser - 20.08.2008
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....
Re: How to make team balance? -
whooper - 20.08.2008
so hwo to set the max nub=mber thta can spawn on that team