Verse Library verse

08 Balancing Teams At Start Of Game

Iterates players at start, calculates sizes, and redistributes them to maintain balanced team counts.

extracted-snippets/documentation/en-us/fortnite/team-multiplayer-balancing-in-verse/08-balancing-teams-at-start-of-game.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/team-multiplayer-balancing-in-verse
# Local doc:  epic-docs/documentation/en-us/fortnite/team-multiplayer-balancing-in-verse.md
# Section:    Balancing Teams at Start of Game
OnBegin<override>()<suspends> : void =
Print("Verse Device Started!")
set Teams = Self.GetPlayspace().GetTeamCollection().GetTeams()
Print("Beginning to Assign Players")
Playspace := GetPlayspace()
AllPlayers := Playspace.GetPlayers()
for (TeamPlayer : AllPlayers, CurrentTeam := Playspace.GetTeamCollection().GetTeam[TeamPlayer]):
var TeamSize : int = 0
if(set TeamSize = Playspace.GetTeamCollection().GetAgents[CurrentTeam].Length):
Print("Size of this player's starting team is {TeamSize}")
SmallestTeam : ?team = FindSmallestTeam(TeamSize)
if (TeamToAssign := SmallestTeam?, Playspace.GetTeamCollection().AddToTeam[TeamPlayer, TeamToAssign]):
Print("Attempting to assign player to a new team")

Comments

    Sign in to vote, comment, or suggest an edit. Sign in