I am new to Verse, so forgive any obvious mistake. I want to make it so when a player spawns, he is assigned to a random team on round start. That team will have different settings using team settings and inventory devices for each team. How come when i playtest the player is always in team 1?
using { /Fortnite.com/Devices }
using { /Fortnite.com/Teams }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath}
using { /Fortnite.com/FortPlayerUtilities }
using { /Verse.org/Simulation/Tags }
# Tags on spawner devices in map
spawner := class(tag){}
# A Verse-authored creative device that can be placed in a level
game_manager := class(creative_device):
# The amount of team settings devices in the map
AmountOfTeamSettings : int = 3
var AllTeams : []team = array{}
OnBegin<override>()<suspends>:void=
var TeamStack:stack(team) = stack(team){}
TeamCollection:= Self.GetPlayspace().GetTeamCollection()
set AllTeams = TeamCollection.GetTeams()
AllPlayers := Self.GetPlayspace().GetPlayers()
# Randomize Teams
RandomTeams := Shuffle(AllTeams)
for (Index := 0..AmountOfTeamSettings-1):
if(TeamStack.Push(RandomTeams[Index])):
if(var RandomTeamTuple : tuple(stack(team), team) = TeamStack.Pop[]):
for (TeamPlayer : AllPlayers):
set TeamStack = RandomTeamTuple(0)
var RandomTeam : team = RandomTeamTuple(1)
if(TeamCollection.AddToTeam[TeamPlayer, RandomTeam]):
Print("Player Spawned")
stack<public>(t:type) := class<computes>:
Items<public>:[]t = array{}
Push<public>(Item:t)<computes>:stack(t)=
stack(t){ Items := Items + array{Item} }
Pop<public>()<decides><computes>:tuple(stack(t), t)=
Ret:t = Items[Items.Length - 1]
(stack(t){ Items := Items.RemoveElement[Items.Length - 1] }, Ret)