Finding Players At Runtime In Verse
This section shows how to find players and teams at runtime that you set up earlier.
Defining Class Members
-
Open Verse Explorer and double-click triad_infiltration_game.verse to open the script in Visual Studio Code.
-
At the top of the file, add
using { /Verse.org/Random }to access theShuffle()function. You'll use this to randomly shuffle teams of players before balancing. Also addusing { /Fortnite.com/FortPlayerUtilities }to access theRespawn()function for players, which you'll use later to teleport players to their spawn areas at the start of the game.using { /Fortnite.com/Devices } using { /Fortnite.com/FortPlayerUtilities } using { /Verse.org/Simulation } using { /Verse.org/Random } using { /UnrealEngine.com/Temporary/Diagnostics } -
In the
triad_infiltration_gameclass definition, add the following fields:- Three editable integers named
MaximumInfiltrators,MaximumAttackers, andMaximumDefenders. InitializeMaximumInfiltratorsto 2 andMaximumAttackersandMaximumDefendersto 4. These track the maximum number of players on each team, you'll use them to balance teams dynamically. You can change these numbers for testing purposes, and to create interesting variations in the game. `triad_infiltration := class(creative_device):To avoid players not being able to join a team, you should set the maximum number
of players in the island settings to the sum of all of the Maximum(Team) variables.
Maximum number of players on the Infiltrators Team.
@editable MaximumInfiltrators:int = 2Maxmimum number of players on the Attackers Team.
@editable MaximumAttackers:int = 4Maximum number of players on the Defenders Team.
@editable MaximumDefenders:int = 4` - A variable map named
TeamsAndTotals. This will map teams of players to the maximum number of players on that team. `# Maximum number of players on the Infiltrators Team. @editable MaximumInfiltrators:int = 2Maxmimum number of players on the Attackers Team.
@editable MaximumAttackers:int = 4Maximum number of players on the Defenders Team.
@editable MaximumDefenders:int = 4Map of teams to their maximum number of players.
var TeamsAndTotals:[team]int = map{}` - An editable array of teleporters named
Teleporters. This holds a reference to the teleporters which you'll use to teleport players to their spawns after team balancing. `# Map of teams to their maximum number of players. var TeamsAndTotals:[team]int = map{}Array of Teleporters that teleport players to their team's spawn once the game starts.
@editable Teleporters:[]teleporter_device = array{}` - An editable
item_granter_devicearray namedWeaponGranters. This stores the item granters needed to grant players a weapon based on their team when they spawn. `# Array of Teleporters that teleport players to their team's spawn once the game starts. @editable Teleporters:[]teleporter_device = array{}Array of weapon granters for each team.
@editable var WeaponGranters:[]item_granter_device = array{}` - Three optional
teamvariables namedMaybeInfiltrators,MaybeAttackers, andMaybeDefenders. These store a reference to each team to allow you to check that teams are set up correctly. `# Array of weapon granters for each team. @editable var WeaponGranters:[]item_granter_device = array{}Reference to the infiltrators team.
var MaybeInfiltrators:?team = falseReference to the attackers team.
var MaybeAttackers:?team = falseRerfernece to the defenders team.
var MaybeDefenders:?team = false` - A variable array of teams named
Teams. This holds a reference to all teams in the game, and you'll use this to set the optional team variables above as well as find teams to assign players to when balancing. `# Reference to the infiltrators team. var MaybeInfiltrators:?team = falseReference to the attackers team.
var MaybeAttackers:?team = falseRerfernece to the defenders team.
var MaybeDefenders:?team = falseArray of all teams in the game.
var Teams:[]team = array{}`
- Three editable integers named
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.