Verse Library verse

04 Granting Weapons When Players Spawn

Configures team collections, tracks player counts, and handles initial team balancing and teleportation.

extracted-snippets/documentation/en-us/fortnite/triad-infiltration-04-granting-weapons-on-player-spawn-in-verse/04-granting-weapons-when-players-spawn.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/triad-infiltration-04-granting-weapons-on-player-spawn-in-verse
# Local doc:  epic-docs/documentation/en-us/fortnite/triad-infiltration-04-granting-weapons-on-player-spawn-in-verse.md
# Section:    Granting Weapons When Players Spawn
OnBegin<override>()<suspends>:void =
# Get all the Teams
set Teams = GetPlayspace().GetTeamCollection().GetTeams()
# Save the teams to later reference them
set InfiltratorsOpt = option{Teams[0]}
set AttackersOpt = option{Teams[1]}
set DefendersOpt = option{Teams[2]}
if:
Infiltrators := InfiltratorsOpt?
Attackers := AttackersOpt?
Defenders :=  DefendersOpt?
Logger.Print("Found all three teams")
set TeamsAndTotals[Infiltrators] = MaximumInfiltrators
set TeamsAndTotals[Attackers] = MaximumAttackers
set TeamsAndTotals[Defenders] = MaximumDefenders
Logger.Print("Set all three teams in TeamsAndTotals")
then:
#Subscribe to PlayerAddedEvent to allow team rebalancing when a new player joins the game
for(PlayerSpawner:PlayersSpawners):
PlayerSpawner.SpawnedEvent.Subscribe(OnPlayerSpawn)
BalanceTeams()
TeleportPlayersToStartLocations()
else:
Logger.Print("Couldn't find all teams, make sure to assign the correct teams in your island settings.")

Comments

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