Team Balancer Problem
#1

When im lonely on the server and i die,then try to respawn with any of the classes,it wont let me saying that the team is full.


pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    new team1 = GetPlayersInTeamFromMaxPlayers(TEAM_TERRO);
    new team2 = GetPlayersInTeamFromMaxPlayers(TEAM_ARMY);
    if(team1 > team2 && gTeam[playerid] == TEAM_TERRO)
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    else if(team2 > team1 && gTeam[playerid] == TEAM_ARMY)
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    return 1;
}
Reply
#2

anyone can fix this?
Reply
#3

pawn Код:
&& gTeam[playerid] == TEAM_TERRO
Removing this from both should solve it.
Reply
#4

pawn Код:
#define TEAM_ARMY 0
#define TEAM_TERRO 1
pawn Код:
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..
}
also we got that here,, i tried remove what you said , and now when i spawned as a team, then when i want choose again, it says this team is full, on any team ...
Reply
#5

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    new team1 = GetPlayersInTeamFromMaxPlayers(TEAM_TERRO);
    new team2 = GetPlayersInTeamFromMaxPlayers(TEAM_ARMY);
    if((team1 > team2 && gTeam[playerid] == TEAM_TERRO) || (team2 > team1 && gTeam[playerid] == TEAM_ARMY))
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    else if((gTeam[playerid] == TEAM_ARMY && (team1 == 0 || team1 == team2)) || (gTeam[playerid] == TEAM_TERRO && (team2 == 0 || team1 == team2)))
    {
        return 1;
    }
    return 1;
}
Try this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)