SA-MP Forums Archive
[UNSOLVED] Team Balance With 3 Teams - 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: [UNSOLVED] Team Balance With 3 Teams (/showthread.php?tid=114052)



[UNSOLVED] Team Balance With 3 Teams - Nameless303 - 17.12.2009

Hi,

I'm searching for a Team Balance script for 3 teams... I know, there are a lot of topics about Team Balancing but I couldn't find a script...

Thanks...

EDIT: I tried myself, but it doesn't works...


Re: [UNSOLVED] Team Balance With 3 Teams - DeathOnaStick - 17.12.2009

This maybe works for Team one and two (in one way) so far. You need to add the other stuff by yourself anyway, but you can use the same concept.

Have Fun.

pawn Код:
public Ballance()
{
new TeamPlayers[*Amount of Teams*];
for(new i=0; i<MAX_PLAYERS; i++)if(IsPlayerConnected(i))TeamPlayers[GetPlayerTeam(i)]++;

if(TeamPlayers[TEAM_TWO]<TeamPlayers[TEAM_ONE]) //Start: Ballance Team One
{
new RandPla=random(TeamPlayers[TEAM_ONE]);
if(GetPlayerTeam(RandPla)!=TEAM_ONE)
{
for(RandPla; RandPla<=MAX_PLAYERS && GetPlayerTeam(RandPla)!=TEAM_ONE, RandPla++) ForcePlayerClassSelection(RandPla);
}
if(RandPla==MAX_PLAYERS)Ballance();
else ForcePlayerClassSelection(RandPla);
} //End: Ballance Team One

return 1;
}



Re: [UNSOLVED] Team Balance With 3 Teams - Nameless303 - 17.12.2009

Quote:
Originally Posted by DeathOnaStick
This maybe works for Team one and two (in one way) so far. You need to add the other stuff by yourself anyway, but you can use the same concept.

Have Fun.

pawn Код:
public Ballance()
{
new TeamPlayers[*Amount of Teams*];
for(new i=0; i<MAX_PLAYERS; i++)if(IsPlayerConnected(i))TeamPlayers[GetPlayerTeam(i)]++;

if(TeamPlayers[TEAM_TWO]<TeamPlayers[TEAM_ONE]) //Start: Ballance Team One
{
new RandPla=random(TeamPlayers[TEAM_ONE]);
if(GetPlayerTeam(RandPla)!=TEAM_ONE)
{
for(RandPla; RandPla<=MAX_PLAYERS && GetPlayerTeam(RandPla)!=TEAM_ONE, RandPla++) ForcePlayerClassSelection(RandPla);
}
if(RandPla==MAX_PLAYERS)Ballance();
else ForcePlayerClassSelection(RandPla);
} //End: Ballance Team One

return 1;
}
The thing is, I also have a balance script for 2 teams but I don't know how to change it to 3...
TnQ Anyway (:


Re: [UNSOLVED] Team Balance With 3 Teams - Backwardsman97 - 18.12.2009

You could do something as simple as...

pawn Код:
new Teams;

public OnPlayerConnect(playerid)
{
   gTeam[playerid]= Teams;//Or whatever your team system is

   if(Teams < 2)
      Teams++;
   else
      Teams=0;

   return 1;
}



Re: [UNSOLVED] Team Balance With 3 Teams - Nameless303 - 18.12.2009

Quote:
Originally Posted by Backwardsman97
You could do something as simple as...

pawn Код:
new Teams;

public OnPlayerConnect(playerid)
{
  gTeam[playerid]= Teams;//Or whatever your team system is

  if(Teams < 2)
     Teams++;
  else
     Teams=0;

  return 1;
}
Doesn't works..



Re: [UNSOLVED] Team Balance With 3 Teams - xDENNNIISSSS - 21.12.2009

Well,

We are still searching..
Someone have it?

Tnx already




Re: [UNSOLVED] Team Balance With 3 Teams - Nameless303 - 22.12.2009

* BUMP *


Re: [UNSOLVED] Team Balance With 3 Teams - LarzI - 22.12.2009

Show us the balance code you already got?


Re: [UNSOLVED] Team Balance With 3 Teams - Nameless303 - 22.12.2009

Quote:
Originally Posted by lrZ^ aka LarzI
Show us the balance code you already got?
Код:
public OnPlayerRequestSpawn(playerid)
{
	if (CountA > CountB && GetPlayerTeam(playerid) == TEAM_A)
	{
		SendMsg(playerid, 5000, "~b~NOTICE: ~w~This team is full!");
		return 0;
	}
	else if (CountB > CountA && GetPlayerTeam(playerid) == TEAM_B)
	{
		SendMsg(playerid, 5000, "~b~NOTICE: ~w~This team is full!");
		return 0;
	}
	else return 1;
}

OnPlayerDeath and OnplayerDisconnect;
			if (GetPlayerTeam(playerid) == TEAM_A)
		 	{
		 		CountA--;
		  }
		  	else if (GetPlayerTeam(playerid) == TEAM_B)
		  	{
		  		CountB--;
		  	}

OnPlayerSpawn;
			if (GetPlayerTeam(playerid) == TEAM_A)
		 	{
		 		CountA++;
		  }
		  	else if (GetPlayerTeam(playerid) == TEAM_B)
		  	{
		  		CountB++;
		  	}



Re: [UNSOLVED] Team Balance With 3 Teams - wafffllesss - 22.12.2009

Try this (not tested, i'm at work.. cannot test right now)

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if ( CountA > CountB && CountA > CountC && GetPlayerTeam(playerid) == TEAM_A)
    {
        SendMsg(playerid, 5000, "~b~NOTICE: ~w~This team is full!");
        return 0;
    }
    else if ( CountB > CountA && CountB > CountC && GetPlayerTeam(playerid) == TEAM_B)
    {
        SendMsg(playerid, 5000, "~b~NOTICE: ~w~This team is full!");
        return 0;
    }
    else if ( CountC > CountA && CountC > CountB && GetPlayerTeam(playerid) == TEAM_C)
    {
        SendMsg(playerid, 5000, "~b~NOTICE: ~w~This team is full!");
        return 0;
    }
    else return 1;
}

OnPlayerDeath and OnplayerDisconnect;
if (GetPlayerTeam(playerid) == TEAM_A)
{
    CountA--;
}
else if (GetPlayerTeam(playerid) == TEAM_B)
{
    CountB--;
}
else if (GetPlayerTeam(playerid) == TEAM_C)
{
    CountC--;
}

OnPlayerSpawn;
if (GetPlayerTeam(playerid) == TEAM_A)
{
    CountA++;
}
else if (GetPlayerTeam(playerid) == TEAM_B)
{
    CountB++;
}
else if (GetPlayerTeam(playerid) == TEAM_C)
{
    CountC++;
}