SA-MP Forums Archive
2 Team Balancer ... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 2 Team Balancer ... (/showthread.php?tid=259593)



2 Team Balancer ... - serman - 05.06.2011

Hello i tried to making Team Balancer it's not working

Please Help me

Here is My Code:
Код:
public OnPlayerRequestSpawn(playerid)
{
   new Count1,Count2;

    for(new i = 0; i < GetMaxPlayers(); i++)
	  {
	    if (gTeam[playerid] == TEAM_RED) Count1++;
	    else if (gTeam[playerid] == TEAM_GREEN) Count2++;
	  }
	  if ((Count1 > Count2) && gTeam[playerid] == TEAM_GREEN)
	  {
	    SendClientMessage(playerid,COLOR_RED, "[BALANCER] Balancing teams. Choose Another Team");
	    return 0;
	  }
	  else if ((Count2 > Count1) && gTeam[playerid] == TEAM_RED)
	  {
	    SendClientMessage(playerid,COLOR_RED, "[BALANCER] Balancing teams. Choose Another Team");
	    return 0;
	  }
	return 1;
}
Whats Wrong in my code ..Please help


Re: 2 Team Balancer ... - AK47317 - 05.06.2011

pawn Код:
new Count1,Count2;

public OnPlayerSpawn ( playerid ) {
    for(new i = 0; i < GetMaxPlayers(); i++)
      {
        if (gTeam[playerid] == TEAM_RED) Count1++;
        else if (gTeam[playerid] == TEAM_GREEN) Count2++;
      }
}

public OnPlayerRequestSpawn(playerid)
{

      if ((Count1 > Count2) && gTeam[playerid] == TEAM_GREEN)
      {
        SendClientMessage(playerid,COLOR_RED, "[BALANCER] Balancing teams. Choose Another Team");
        return 0;
      }
      else if ((Count2 > Count1) && gTeam[playerid] == TEAM_RED)
      {
        SendClientMessage(playerid,COLOR_RED, "[BALANCER] Balancing teams. Choose Another Team");
        return 0;
      }
    return 1;
}