05.05.2010, 17:38
How can you make like, if one of the team is full, 1/2 automaticly go to the other one, so it are both even teams? (If you choose class and just in-game)
public OnPlayerRequestSpawn(playerid)
{
new count1,count2;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(pi[playerid][army] == 1) count1 ++; // Change "pi[playerid][army] == 1) " to like if(gTeam == TEAM)
else if (pi[playerid][Terr] == 1) count2 ++; // Same for here, just the other team
}
if(count1 > count2)
{
GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
ForceClassSelection(playerid);
}
else if(count2 > count1)
{
GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
ForceClassSelection(playerid);
}
return 1;
}
|
Originally Posted by Naxix
Try this
Код:
public OnPlayerRequestSpawn(playerid)
{
new count1,count2;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(pi[playerid][army] == 1) count1 ++; // Change "pi[playerid][army] == 1) " to like if(gTeam == TEAM)
else if (pi[playerid][Terr] == 1) count2 ++; // Same for here, just the other team
}
if(count1 > count2)
{
GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
ForceClassSelection(playerid);
}
else if(count2 > count1)
{
GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
ForceClassSelection(playerid);
}
return 1;
}
-Naxix |
|
Originally Posted by Naxix
Do you use gTeam or how you made your teams?
|
|
C:\Users\Robin\humanvszombies\zm.pwn(279) : error 076: syntax error in the expression, or invalid function call C:\Users\Robin\humanvszombies\zm.pwn(280) : error 076: syntax error in the expression, or invalid function call |
|
if(PlayerTeam == ZombieTeam == 1) count1 ++; // Change "pi[playerid][army] == 1) " to like if(gTeam == TEAM) else if (PlayerTeam == HumanTeam == 1) count2 ++; // Same for here, just the other team |
if(PlayerTeam == ZombieTeam) count1 ++;
else if (PlayerTeam == HumanTeam) count2 ++;
|
Originally Posted by Naxix
Use:
Код:
if(PlayerTeam == ZombieTeam) count1 ++;
else if (PlayerTeam == HumanTeam) count2 ++;
|
if(PlayerTeam(playerid) == ZombieTeam) count1 ++;
else if (PlayerTeam(playerid) == HumanTeam) count2 ++;
|
Originally Posted by Naxix
Try
Код:
if(PlayerTeam(playerid) == ZombieTeam) count1 ++;
else if (PlayerTeam(playerid) == HumanTeam) count2 ++;
|
|
C:\Users\Robin\humanvszombies\zm.pwn(277) : error 012: invalid function call, not a valid address C:\Users\Robin\humanvszombies\zm.pwn(277) : warning 215: expression has no effect C:\Users\Robin\humanvszombies\zm.pwn(277) : error 001: expected token: ";", but found ")" C:\Users\Robin\humanvszombies\zm.pwn(277) : error 029: invalid expression, assumed zero C:\Users\Robin\humanvszombies\zm.pwn(277) : fatal error 107: too many error messages on one line |
if(PlayerTeam[playerid] == ZombieTeam) count1 ++;
else if (PlayerTeam[playerid] == HumanTeam) count2 ++;
|
Originally Posted by Naxix
Код:
if(PlayerTeam[playerid] == ZombieTeam) count1 ++;
else if (PlayerTeam[playerid] == HumanTeam) count2 ++;
|
|
C:\Users\Robin\humanvszombies\zm.pwn(277) : error 076: syntax error in the expression, or invalid function call C:\Users\Robin\humanvszombies\zm.pwn(27 : error 076: syntax error in the expression, or invalid function call |
.
public OnPlayerRequestSpawn(playerid)
{
new count1,count2;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(PlayerTeam[i] == ZombieTeam)
{
count1 ++;
}
else if (PlayerTeam[i] == HumanTeam)
{
count2 ++; // Same for here, just the other team
}
if(count1 > count2)
{
GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
ForceClassSelection(playerid);
}
else if(count2 > count1)
{
GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
ForceClassSelection(playerid);
}
}
}
return 1;
}
new Count1, Count2;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(PlayerTeam[playerid] == ZombieTeam) Count1++;
else if (PlayerTeam[playerid] == HumanTeam) Count2++;
}
if ((Count1 > Count2) && PlayerTeam[playerid] == HumanTeam)
{
SendClientMessage(playerid,COLOUR_RED, "Balancing teams. Choose Another Team");
return 0;
}
else if ((Count2 > Count1) && PlayerTeam[playerid] == ZombieTeam)
{
SendClientMessage(playerid,COLOUR_RED, "[BALANCER] Balancing teams. Choose Another Team");
return 0;
}
return 1;
}
|
Originally Posted by Naxix
Try this then..
Код:
new Count1, Count2;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(PlayerTeam[playerid] == ZombieTeam) Count1++;
else if (PlayerTeam[playerid] == HumanTeam) Count2++;
}
if ((Count1 > Count2) && PlayerTeam[playerid] == HumanTeam)
{
SendClientMessage(playerid,COLOUR_RED, "Balancing teams. Choose Another Team");
return 0;
}
else if ((Count2 > Count1) && PlayerTeam[playerid] == ZombieTeam)
{
SendClientMessage(playerid,COLOUR_RED, "[BALANCER] Balancing teams. Choose Another Team");
return 0;
}
return 1;
}
|
|
Originally Posted by Naxix
It should prevent players from spawning.
|

|
public OnPlayerRequestClass(playerid,classid) { new Count1, Count2; for(new i = 0; i < GetMaxPlayers(); i++) { if(PlayerTeam[playerid] == 0) Count1++; else if (PlayerTeam[playerid] == 1) Count2++; } if ((Count1 > Count2) && PlayerTeam[playerid] == 1) { SendClientMessage(playerid,COLOR_RED, "Balancing teams. Choose Another Team"); return 0; } else if ((Count2 > Count1) && PlayerTeam[playerid] == 0) { SendClientMessage(playerid,COLOR_RED, "[BALANCER] Balancing teams. Choose Another Team"); return 0; } SetPlayerPos(playerid,299.9177,2741.7598,42.9127); SetPlayerFacingAngle(playerid,198.9686); SetPlayerCameraPos(playerid,306.3498,2727.6697,37. 0493); SetPlayerCameraLookAt(playerid,299.9177,2741.7598, 42.9127); if(classid == 0) { PlayerTeam[playerid] = 0; SetPlayerTeam(playerid,0); } else if(classid == 1) { PlayerTeam[playerid] = 1; SetPlayerTeam(playerid,1); } return 1; } |
|
if(classid == 0) { PlayerTeam[playerid] = 0; SetPlayerTeam(playerid,0); } else if(classid == 1) { PlayerTeam[playerid] = 1; SetPlayerTeam(playerid,1); } |