how to make auto 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 auto team balance? (
/showthread.php?tid=224853)
how to make auto team balance? -
Medal Of Honor team - 12.02.2011
How will i make auto team balance?
if(classid == 0)
{
gTeam[playerid] = TEAM_USA;
}
else if(classid == 1)
{
gTeam[playerid] = TEAM_GERMANY;
}
else if(classid == 2)
{
gTeam[playerid] = TEAM_MERC;
}
else if(classid == 3)
{
gTeam[playerid] = TEAM_RUSSIA;
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_JAPAN;
}
Re: how to make auto team balance? -
Mean - 12.02.2011
pawn Код:
new TeamPlayers[ <Amount of teams here> ];
public OnPlayerRequestSpawn(playerid)
{
for(new teams; teams < [Team Amount]; teams++)
{
if(teams == gTeam[playerid]) continue;
if(TeamPlayers[gTeam[playerid]] > TeamPlayers[teams] + 3)
{
SendClientMessage(playerid, COLOR_RED, "You can't join this team as it would unbalance the game!");
return 0;
}
}
}
//By Hiddos
So... Example usage:
pawn Код:
public OnPlayerRequestSpawn( playerid )
{
for( new teams; teams < 23; teams++ )
{
if( teams == gTeam[ playerid ] ) continue;
if( TeamPlayers[ gTeam[ playerid ] ] > TeamPlayers[ teams ] + 3)
{
SendClientMessage( playerid, COLOR_RED, "You can't join this team as it would unbalance the game!" );
return 0;
}
}
return 1;
}