Verse Library verse

01 Device

Subscribes to per-player elimination events to track stats or trigger rewards across the session.

verse-library/tracking-player-health-shields-and-elimination-events/01-device.verse

# This is a Verse script for Fortnite Creative
# It tracks eliminations and gives rewards

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Playspaces }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our device. It connects our code to the game.
# Place this device on your island in UEFN.
health_reward_system := class(creative_device):

    # This is a "Function". It is a set of instructions.
    # We will run this when the game starts.
    OnBegin<override>()<suspends>:void=
        # We get a reference to the current game session.
        # This lets us listen for eliminations across all players.
        GameSession := GetPlayspace()

        # We listen for the "PlayerRemovedEvent" and loop over
        # each player joining so we can subscribe per-player.
        # The standard pattern is to subscribe to each
        # fort_character's EliminatedEvent as players spawn.
        for (Player : GameSession.GetPlayers()):
            spawn { WatchPlayer(Player) }

    # This function watches a single player for elimination events.
    # <suspends> means it can wait for async events.

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