using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
# This is a map type.
# It links a player to an integer (a whole number).
# Think of it as a list of Player -> Score.
PlayerScoreMap := [player]int
MyGame := class(creative_device):
# This is our scoreboard!
# It starts empty.
Scoreboard : PlayerScoreMap = {}
# This function runs when a player eliminates someone.
OnElimination := func(player: player):
# Check if the player is already on the scoreboard.
# If not, give them a score of 0.
if (Scoreboard[player] == 0):
Scoreboard[player] = 0
# Add 1 to their score.
# This updates the value for this player key.
Scoreboard[player] = Scoreboard[player] + 1
# Print the new score to the debug console.
print("Player scored! New total: ", Scoreboard[player])
# This runs when the game starts.
OnBegin<override>(sourced root: root):
Verse Library
verse
01 Device
Tracks and increments individual player scores using a map data structure during eliminations.
verse-library/team-elimination-4-tracking-players-using-maps-in-verse/01-device.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.