Team Balance - 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)
+--- Thread: Team Balance (
/showthread.php?tid=447328)
~fixed~ -
Blackazur - 29.06.2013
~fixed~
Re: Team Balance -
Anak - 29.06.2013
maybe this example help you.
pawn Code:
new team1 = 6; // exm team 1 has 6 players
new team2 = 10; // exm team 2 heas 10 players
new timer;
public OnFilterScriptInit()
{
timer = SetTimer("balanceteams", 1000, 1);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public balanceteams()
{
if (team1 > team2)
{
team2++;
team1--;
}
if (team1 < team2)
{
team2--;
team1++;
}
if(team1 == team2)
{
KillTimer(timer);
}
return 1;
}
Re: Team Balance -
Pottus - 29.06.2013
Quote:
Originally Posted by Anak
maybe this example help you.
pawn Code:
new team1 = 6; // exm team 1 has 6 players new team2 = 10; // exm team 2 heas 10 players new timer;
public OnFilterScriptInit() { timer = SetTimer("balanceteams", 1000, 1); return 1; }
public OnFilterScriptExit() { return 1; }
public balanceteams() { if (team1 > team2) { team2++; team1--; } if (team1 < team2) { team2--; team1++; } if(team1 == team2) { KillTimer(timer); } return 1; }
|
What are you thinking? That isn't a solution at all.
Start up
---------------------------------
1) Get a list of all active players
2) Randomize list
3) Divide active player count by 2
4) Join players on both teams
--------------------------------
Removing / Joining players
--------------------------------
Player joins game
1) Find which team has lowest player count
2) Join player to team with lowest count if equal choose a random team
Please leaves game (disconnects, /exitround etc...) (This will be your update timer)
1) Update player team count (Textdraws)
2) If player team count is different than the last update do steps 3, and 4
3) Find which team has lowest player count
4) If the count is greater than 1 swap a player from higher team
AW: Team Balance -
Nero_3D - 29.06.2013
Try that
pawn Code:
stock Balance() {
new
count,
player[MAX_PLAYERS]
;
foreach(Player, i) {
player[count++] = i;
}
for(new rand, half = count / 2; halft--; count--) {
rand = random(count);
HumanSetup(player[rand]);
player[rand] = player[count];
}
while(count) {
ZombieSetup(player[--count]);
}
}