10.09.2011, 14:51
So, I've got this:
Would this work? Or do I need something else?
pawn Code:
public OnPlayerRequestSpawn(playerid)
{
new team1 = GetPlayersInTeamFromMaxPlayers(TEAM_RED);
new team2 = GetPlayersInTeamFromMaxPlayers(TEAM_GREEN);
if(team1 > team2 && Team[playerid] == TEAM_RED && !IsPlayerVIP(playerid))
{
TextDrawShowForPlayer(playerid,balancer);
SetTimer("HideBalancer",4000,0);
return 0;
}
else if(team2 > team1 && Team[playerid] == TEAM_GREEN && !IsPlayerVIP(playerid))
{
TextDrawShowForPlayer(playerid,balancer);
SetTimer("HideBalancer",4000,0);
return 0;
}
return 1;
}
forward HideBalancer(playerid);
public HideBalancer(playerid)
{
TextDrawHideForPlayer(playerid,balancer);
}
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(Team[i] != teamid) continue;
playercount++;
}
return playercount;
}