Team Balancer Question
#2

pawn Code:
public OnPlayerRequestSpawn(playerid)
{
    new balla = GetPlayersInTeamFromMaxPlayers(TEAM_BALLAS);
    new grove = GetPlayersInTeamFromMaxPlayers(TEAM_GROVE);
    if(balla > grove && gTeam[playerid] == TEAM_GROVE)
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    else if(grove > balla && gTeam[playerid] == TEAM_GROVE)
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    return 1;
}
pawn Code:
stock GetPlayersInTeamFromMaxPlayers(teamid)
{
    new playercount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(HasPlayerSpawned[i] == false) continue;
        if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
        if(gTeam[i] != teamid) continue;
        playercount++;
    }
    return playercount;
}
* The stock is added in my stocks include.
Edit it to your variables.
EDIT :
Add
new bool:HasPlayerSpawned[MAX_PLAYERS];
Ontop of script, sorry, I forgot to mention that.
Reply


Messages In This Thread
Team Balancer Question - by Tigerbeast11 - 10.09.2011, 14:03
Re: Team Balancer Question - by Darnell - 10.09.2011, 14:10
Re: Team Balancer Question - by Basicz - 10.09.2011, 14:11
Re: Team Balancer Question - by Tigerbeast11 - 10.09.2011, 14:28
Re: Team Balancer Question - by Tigerbeast11 - 10.09.2011, 14:51

Forum Jump:


Users browsing this thread: 2 Guest(s)