20.02.2012, 18:29
Hello i got problems with Team Balance.Its not working -.-
Here is the code maybe someone know
Anyone can help
Here is the code maybe someone know
pawn Код:
new team1 = GetPlayersInTeamFromMaxPlayers(1);//team1 = how many players are in TEAM_ONE..
new team2 = GetPlayersInTeamFromMaxPlayers(2);//team2 = how many players are in TEAM_TWO..
if(team1 > team2 && GetPlayerTeam(playerid) == 1)//if team1 has more players than team2 and the player is trying to spawn as TEAM_ONE..
{
GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);//Tell them its full, choose another team..
return 0;//And stop them from spawning..
}
else if(team2 > team1 && GetPlayerTeam(playerid) == 2)//if team2 has more players than team1 and the player is trying to spawn as TEAM_TWO..
{
GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);//Tell them its full, choose another team..
return 0;//And stop them from spawning..
}
stock GetPlayersInTeamFromMaxPlayers(teamid)//Stock developed by Weponz (Weponz Inc. © 2010 - 2011)
{
new playercount = 0;//Set our count to 0 as we have not counted any players yet..
for(new i = 0; i < MAX_PLAYERS; i++)//Loop through MAX_PLAYERS(I suggest you redefine MAX_PLAYERS to ensure max efficency)..
{
if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;//If a player is in class selection continue..
if(gTeam[i] != teamid) continue;//If a player is NOT in the specified teamid continue..
playercount++;//else (there in the teamid) so count the player in the team..
}
return playercount;//Return the total players counted in the specified team..
}
