SA-MP Forums Archive
Little teambalancer problem - 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)
+--- Thread: Little teambalancer problem (/showthread.php?tid=369647)



Teambalancer is buggy - Dan. - 17.08.2012

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;
}



Re: Little teambalancer problem - Dan. - 17.08.2012

BUMP.


Re: Little teambalancer problem - Dan. - 18.08.2012

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