10.09.2011, 14:10
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;
}
Edit it to your variables.
EDIT :
Add
new bool:HasPlayerSpawned[MAX_PLAYERS];
Ontop of script, sorry, I forgot to mention that.