# Outer map: Team Name -> Inner Map (Player -> Score)
var TeamScoreMap: map[string, map[player, int]] = map{}
# Function to add a player to a team
OnPlayerTeamJoin: func(player: player, team_name: string) void:
# Check if the team exists in our master map
if (not TeamScoreMap.Contains(team_name)):
# Create a new empty map for this team
TeamScoreMap[team_name] = map{}
# Now get the inner map for this team
team_player_map: map[player, int] = TeamScoreMap[team_name]
# Add the player to the team's inner map with 0 score
team_player_map[player] = 0
Verse Library
verse
04 Fragment
Manages nested maps to track individual player scores per team on join.
verse-library/4-tracking-players-using-maps/04-fragment.verse