Adding Random Players To Player Groups

Silentnight1

New Member
Reaction score
1
I am trying to figure out how to create a trigger to add 2 players at random to player groups, having 8 players total, making 4 groups of 2 each in them. Anyone have any thoughts?
 

Arkless

New Member
Reaction score
31
A simple way that is easy to accomplish would be the following:

Use an array with a size of 8. Fill it with the playernumbers of your players.

Use a random integer from 0 to 7, put that player in the first team. Now move the Integer value from position 7 to the position you just used.
example:
random integer = 4
team1, player 1 = MyArray[4]
MyArray[4] = MyArray[7]

Now repeat this (beginning with the random integer) till you got your teams filled.

pseudo code:
int[4][2] Teams;
int TeamCounter;
int TeamMember;
int[8] RandomizationArray;
int Random;
int Counter;
Counter = 0;
while (Counter <= 7) {
RandomizationArray[Counter] = Counter;
Counter += 1;
}
Counter = 7;
TeamCounter = 0;
TeymMember = 0;
while (Counter >=0){
Random = RandomInt(0,Counter);
Teams[TeamCounter][TeamMember] = RandomizationArray[Random];
if (TeamMember == 0) {
TeamMember = 1;
} else {
TeamMember = 0;
TeamCounter += 1;
}
RandomizationArray[Random] = RandomizationArray[Counter];
Counter -= 1;
}
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top