Random team assigning, team members limit:
#2

like this maybe
pawn Код:
#include <foreach>

#define TeamA 1
#define TeamB 2
 
new team[MAX_PLAYERS];
new Iterator:hold<MAX_PLAYERS>;//holds the player which have been assigned to a team already


//on command to assign the the teams to all player connected
new i;
new count = Iter_Count(Player);//returns number of connected players

new ran, b = 0;//for using inside loop

for(i = 1; i <= count; i++)
{
ran = Iter_Random(Player);
while(b == 0)
      {
      If(Iter_Contains(hold, ran))ran = Iter_Random(Player);//means if player is already assigned a team
      else b = 1;//to end the loop
      }

b = 0;//for next loop
if(i % 2 == 0)team[ran] = TeamA;//this for balancing team
else team[ran] = TeamB;
Iter_Add(hold, ran);
}
/*=====================================*/

//on restart of event or event end this --
Iter_Clear(hold);
Reply


Messages In This Thread
Random team assigning, team members limit: - by Twizted - 20.07.2014, 11:26
Re: Random team assigning, team members limit: - by BroZeus - 20.07.2014, 12:29
Re: Random team assigning, team members limit: - by TakeiT - 20.07.2014, 13:05

Forum Jump:


Users browsing this thread: 1 Guest(s)