public OnPlayerRequestSpawn(playerid) { new Count1, Count2; for(new p = 0; p < GetMaxPlayers(); p++) { if (GetPlayerTeam(p) == TEAM_KOPASSUS) Count1++; else if(GetPlayerTeam(p) == TEAM_TERRORIST) Count2++; } if ((Count1 > Count2) && GetPlayerTeam(playerid) == TEAM_TERRORIST) { GameTextForPlayer(playerid, "~r~This team is full!", 600, 5); PlayerPlaySound(playerid,1055,0, 0, 0); return 0; } else if((Count2 < Count1) && GetPlayerTeam(playerid) == TEAM_KOPASSUS) { GameTextForPlayer(playerid, "~r~This team is full!", 600, 5); PlayerPlaySound(playerid,1055,0, 0, 0); return 0; } SetPlayerToTeamColour(playerid); return 1; } |
if((Count2 > Count1) && GetPlayerTeam(playerid) == TEAM_TERRORIST)
{
// code
}
else if((Count2 < Count1) && GetPlayerTeam(playerid) == TEAM_KOPASSUS)
{
//code
}
//Above main( )
new Count1, Count2;
//Under OnPlayerDisconnect
if( GetPlayerTeam( playerid ) == TEAM_KOPASSUS ) Count1--;
else if( GetPlayerTeam( playerid ) == TEAM_TERRORIST ) Count2--;
OnPlayerDisconnect(playerid) { if (GetPlayerTeam(p) == TEAM_KOPASSUS) Count1--;
else if(GetPlayerTeam(p) == TEAM_TERRORIST) Count2--; return 1 }
public OnPlayerRequestSpawn(playerid)
{
if ((Count1 > Count2) && GetPlayerTeam(playerid) == TEAM_TERRORIST)
{
GameTextForPlayer(playerid, "~r~This team is full!", 600, 5);
PlayerPlaySound(playerid,1055,0, 0, 0);
return 0;
}
else if((Count2 < Count1) && GetPlayerTeam(playerid) == TEAM_KOPASSUS)
{
GameTextForPlayer(playerid, "~r~This team is full!", 600, 5);
PlayerPlaySound(playerid,1055,0, 0, 0);
return 0;
}
SetPlayerToTeamColour(playerid);
return 1;
}
Yes, that should work, except you have the Count1 and Count2 mixed up in your statements.
pawn Код:
pawn Код:
|
The same way you have it alread, return 0.
The final code should look something like this: pawn Код:
|
new Count1, Count2; for(new p = 0; p < GetMaxPlayers(); p++) { if (GetPlayerTeam(p) == TEAM_KOPASSUS) Count1++; else if(GetPlayerTeam(p) == TEAM_TERRORIST) Count2++; }
public OnPlayerRequestSpawn(playerid)
{
if ((Count1 > Count2) && GetPlayerTeam(playerid) == TEAM_TERRORIST)
{
GameTextForPlayer(playerid, "~r~This team is full!", 600, 5);
PlayerPlaySound(playerid,1055,0, 0, 0);
return 0;
}
else if((Count2 < Count1) && GetPlayerTeam(playerid) == TEAM_KOPASSUS)
{
GameTextForPlayer(playerid, "~r~This team is full!", 600, 5);
PlayerPlaySound(playerid,1055,0, 0, 0);
return 0;
}
SetPlayerToTeamColour(playerid);
if( GetPlayerTeam( playerid ) == TEAM_KOPASSUS ) Count1++;
else if( GetPlayerTeam( playerid ) == TEAM_TERRORIST ) Count2++;
return 1;
}