21.03.2015, 18:34
try this fixed
if u're using GetPlayerTeam
and if you're using variables...
if u're using GetPlayerTeam
pawn Код:
#include <a_samp>
#define TEAMA 1
#define TEAMB 2
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, 0xFF0000AA, "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, 0xFF0000AA, "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;
}
and if you're using variables...
pawn Код:
#include <a_samp>
#define TEAMA 1
#define TEAMB 2
new gTeam[MAX_PLAYERS];
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, 0xFF0000AA, "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, 0xFF0000AA, "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;
}