15.07.2010, 18:16
(
Последний раз редактировалось Kitten; 24.11.2013 в 04:43.
)
Solved
BalanceTeams(team1, team2)
{
new count[2], dif;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(playerid)) continue;
if(GetPlayerTeam(i) == team1) count[0]++;
else if(GetPlayerTeam(i) == team2) count[1]++;
}
dif = count[0] - count[1];
if(dif >= 2)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(playerid) || dif <= 1) continue;
if(GetPlayerTeam(i) == team2)
{
SetPlayerTeam(i, team1);
dif--;
}
}
return;
}
else if(dif <= -2)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(playerid) || dif >= -1) continue;
if(GetPlayerTeam(i) == team1)
{
SetPlayerTeam(i, team2);
dif++;
}
}
return;
}
return;
}