Verse Library verse

03 Fragment

Listens for eliminations, increments the killer's score, and broadcasts the update to all players.

verse-library/4-tracking-players-using-maps/03-fragment.verse

# This function runs when a player gets an elimination
OnElimination: func(killer: player, victim: player) void:
    # 1. Get the killer's current score
    current_score: int = PlayerScoreMap[killer]
    
    # 2. Add 1 to that score
    new_score: int = current_score + 1
    
    # 3. Save the new score back to the map
    PlayerScoreMap[killer] = new_score
    
    # Optional: Print to chat to verify it works
    PrintToAllPlayers($"{killer.Name} now has {new_score} eliminations!")

Comments

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