Whats wrong with this Auto Balance
#1

Код:
new Count1, 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;
}

public OnPlayerDisconnect
{
 if( GetPlayerTeam( playerid ) == TEAM_KOPASSUS ) Count1--;
 else if( GetPlayerTeam( playerid ) == TEAM_TERRORIST ) Count2--;
return 1;
}
my server still could spawn 2 player with the same team,,,
Reply
#2

Ah, it seems I mixed up the variables!
pawn Код:
new Count1, Count2;

public OnPlayerRequestSpawn(playerid)
{
   if ((Count1 > Count2) && GetPlayerTeam(playerid) == TEAM_KOPASSUS)
   {
      GameTextForPlayer(playerid, "~r~This team is full!", 600, 5);
      PlayerPlaySound(playerid,1055,0, 0, 0);
      return 0;
   }
   else if((Count2 > Count1) && GetPlayerTeam(playerid) == TEAM_TERRORIST)
   {
      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;
}

public OnPlayerDisconnect
{
 if( GetPlayerTeam( playerid ) == TEAM_KOPASSUS ) Count1--;
 else if( GetPlayerTeam( playerid ) == TEAM_TERRORIST ) Count2--;
return 1;
}
Reply
#3

whats the different,,

that auto balance doesnt work
Reply
#4

Do you set the player's teams during OnPlayerRequestClass? If not, that would be your problem, as their team would still be equal to NO_TEAM.

Under OnPlayerRequestClass, compare their classid with the skin they are one, and set their team there. Then your script will work.
Reply
#5

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Do you set the player's teams during OnPlayerRequestClass? If not, that would be your problem, as their team would still be equal to NO_TEAM.

Under OnPlayerRequestClass, compare their classid with the skin they are one, and set their team there. Then your script will work.
i made this
is that right
Код:
public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1380.6447,-1753.0427,13.5469);
    SetPlayerFacingAngle(playerid, 269.6420);
    SetPlayerCameraPos(playerid, 1387.2906,-1752.8887,13.3828);
    SetPlayerCameraLookAt(playerid, 1380.6447,-1753.0427,13.5469);

    if(classid == 0)
	{
		GameTextForPlayer(playerid,"~r~Terorist",6000,6);
		gTeam[playerid] = TEAM_RED;
		SetPlayerTeam(playerid, 0);
	}
 	if(classid == 1)
	 {
		GameTextForPlayer(playerid,"~b~Counter Terorist",6000,6);
		gTeam[playerid] = TEAM_BLUE;
		SetPlayerTeam(playerid, 1);
	}
	return 1;
}
Reply
#6

It depends on your definitions. Is Counter terrorist the same as kopassus?

If so, your defines should look like this:
pawn Код:
#define TEAM_KOPASSUS 1
#define TEAM_TERRORIST 0
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)