Little teambalancer problem
#1

I go into the game, just started up the server. I choose a team, team England, or whatever team I want. Then my friend comes into the game, he can't choose team I chose because it's full, he will choose team Mexico.

But when I do /resetteam and /kill to change my team, I cant choose any of the teams, I cant choose the team I chose, can't choose the team my friend chose, cant choose any of the teams!

This is the OnPlayerRequestSpawn function:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(IsTeamFull(gTeam[playerid]))
    {
        SendClientMessage(playerid, C_GREY, "The team is full, please choose another one!");
        return 0;
    }
    else
    {
        return 1;
    }
}
The IsTeamFull stock:
pawn Код:
stock IsTeamFull(teamid)
{
    if(teamid == T_ENGLAND)
    {
        if(TeamMembers(teamid) > TeamMembers(T_RUSSIA) || TeamMembers(teamid) > TeamMembers(T_MEXICO) || TeamMembers(teamid) > TeamMembers(T_IRAQ))
        {
            return 1;
        }
        else return 0;
    }
    if(teamid == T_RUSSIA)
    {
        if(TeamMembers(teamid) > TeamMembers(T_ENGLAND) || TeamMembers(teamid) > TeamMembers(T_MEXICO) || TeamMembers(teamid) > TeamMembers(T_IRAQ))
        {
            return 1;
        }
        else return 0;
    }
    if(teamid == T_MEXICO)
    {
        if(TeamMembers(teamid) > TeamMembers(T_RUSSIA) || TeamMembers(teamid) > TeamMembers(T_ENGLAND) || TeamMembers(teamid) > TeamMembers(T_IRAQ))
        {
            return 1;
        }
        else return 0;
    }
    if(teamid == T_IRAQ)
    {
        if(TeamMembers(teamid) > TeamMembers(T_RUSSIA) || TeamMembers(teamid) > TeamMembers(T_MEXICO) || TeamMembers(teamid) > TeamMembers(T_ENGLAND))
        {
            return 1;
        }
        else return 0;
    }
    return 0;
}
And the stock "teammembers" what is used in the previous stock, this gets how many players are in the team:
pawn Код:
stock TeamMembers(teamid)
{
    new players = 0;
    foreach(Player, i)
    {
        if(gTeam[i] == teamid)
        {
            if(GetPlayerState(i) != PLAYER_STATE_NONE) // If the player isn't choosing a class.
            {
                players ++;
            }
        }
    }
    return players;
}
Reply
#2

BUMP.
Reply
#3

EDIT:// Figured it out. Close the thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)