Randomized Side Choosing

Reaction score
65
Okay, we've got players, up to 12. At the start I would like them to be separated to 2 teams randomly. The thing is that the teams should have an equal amount of players (or if an odd number, the other team having one more). I almost managed to do it by myself, but not quite :eek: So, to get the project to continue, I'd like to get this trigger done.
 
Reaction score
148
Perhaps try something like this?
Code:
teams
    Events
        Map initialization
    Conditions
    Actions
        Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Actions)
            Loop - Actions
                Player Group - Add (Picked player) to (All players)
                Set nPlayers = (nPlayers + 1)
        Set tempPlayer = (Random player from Players)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                tempInteger Less than or equal to (nPlayers / 2)
            Then - Actions
                Player Group - Add tempPlayer to Teams[1]
                Set tempInteger = (tempInteger + 1)
                Player Group - Remove tempPlayer from Players
            Else - Actions
                Player Group - Add tempPlayer to Teams[2]

"Players" is a Player Group variable
"Teams" is a Player Group variable Array
"tempInteger" is Integer variable
"nPlayers" is Integer variable
"tempPlayer" Is Player variable
 
M

Masterfrog

Guest
Event: Map Initialization

Conditions:

Events:
Pick Every Player in All Players and do Actions:
If Random integer between 1 and 2 equals to 1
Then
Make all Players in Playergroup1 ally picked player
Make Picked Player ally all players in playergroup1
If amount of players in Playergroup1 Is Equal to Or greater than 6
Then
Add Picked Player to Playergroup2
Else
Add Picked Player to Playergroup1
Else
Make all Players in Playergroup2 ally picked player
Make Picked Player ally all players in playergroup2
If amount of players in Playergroup2 Is Equal to Or greater than 6
Then
Add Picked Player to Playergroup1
Else
Add Picked Player to Playergroup2


Something like that will work. Oh, and Playergroup1 and playergroup2 are variables of player group type
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top