Verse Library verse

25 Player Stats Manager Verse

Manages and updates persistent player statistics like scores, wins, and losses for each connected agent.

extracted-snippets/documentation/en-us/uefn/persistent-player-statistics-in-unreal-editor-for-fortnite/25-player-stats-manager-verse.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/persistent-player-statistics-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/uefn/persistent-player-statistics-in-unreal-editor-for-fortnite.md
# Section:    player\_stats\_manager.verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# Manages and updates player_stat_tables for each player.
player_stats_manager := class():
# Return the player_stats_table for the provided Agent.
GetPlayerStats(Agent:agent)<decides><transacts>:player_stats_table=
var PlayerStats:player_stats_table = player_stats_table{}
if:
Player := player[Agent]
PlayerStatsTable := PlayerStatsMap[Player]
set PlayerStats = MakePlayerStatsTable(PlayerStatsTable)
PlayerStats
# Initialize stats for all current players.
InitializeAllPlayers(Players:[]player):void =
for (Player : Players):
InitializePlayer(Player)
# Initialize stats for the given player.
InitializePlayer(Player:player):void=
if:
not PlayerStatsMap[Player]
set PlayerStatsMap[Player] = player_stats_table{}
else:
Print("Unable to initialize player stats")
# Adds to the given Agent's score and updates both their stats table
# in PlayerStatsManager and the billboard in the level.
AddScore<public>(Agent:agent, NewScore:int):void=

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.

Sign in with Discord

Comments

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