21.03.2015, 17:25
(
Последний раз редактировалось ReD_HunTeR; 21.03.2015 в 18:14.
)
if you're using GetPlayerTeam
if you're using array, variables..
pawn Код:
#define TEAMA 1
#define TEAMB 2
public OnPlayerRequestSpawn(playerid)
{
new team1 = GetPlayersInTeamFromMaxPlayers(TEAMA);
new team2 = GetPlayersInTeamFromMaxPlayers(TEAMB);
if(team1 > team2 && gTeam[playerid] == TEAMB && team1 != team2)
{
GameTextForPlayer(playerid, "~r~Team B Full!~n~~w~Choose Another Team!", 3000, 5);
SendClientMessage(playerid, COLOR_RED, "Please Choose Another team because team B is full.");
return 0;
}
else if(team2 > team1 && gTeam[playerid] == TEAMA && team1 != team2)
{
GameTextForPlayer(playerid, "~r~Team A Full!~n~~w~Choose Another Team!", 3000, 5);
SendClientMessage(playerid, COLOR_RED, "Please Choose Another team because team A is full.");
return 0;
}
return 1;
}
stock GetPlayersInTeamFromMaxPlayers(teamid)
{
new playercount = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
if(GetPlayerTeam(i) != teamid) continue;
playercount++;
}
return playercount;
}
if you're using array, variables..
pawn Код:
#define TEAMA 1
#define TEAMB 2
new gTeam[MAX_PLAYERS];
public OnPlayerRequestSpawn(playerid)
{
new team1 = GetPlayersInTeamFromMaxPlayers(TEAMA);
new team2 = GetPlayersInTeamFromMaxPlayers(TEAMB);
if(team1 > team2 && GetPlayerTeam(playerid) == TEAMB && team1 != team2)
{
GameTextForPlayer(playerid, "~r~Team B Full!~n~~w~Choose Another Team!", 3000, 5);
SendClientMessage(playerid, COLOR_RED, "Please Choose Another team because team B is full.");
return 0;
}
else if(team2 > team1 && GetPlayerTeam(playerid) == TEAMA && team1 != team2)
{
GameTextForPlayer(playerid, "~r~Team A Full!~n~~w~Choose Another Team!", 3000, 5);
SendClientMessage(playerid, COLOR_RED, "Please Choose Another team because team A is full.");
return 0;
}
return 1;
}
stock GetPlayersInTeamFromMaxPlayers(teamid)
{
new playercount = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
if(gTeam[i] != teamid) continue;
playercount++;
}
return playercount;
}