Verse Library verse

01 Fragment

Tracks players entering a trigger zone and submits their data to a connected analytics device for logging.

verse-library/submits-an-event-for-agent-to-generate-analytics/01-fragment.verse

# Import the necessary Fortnite devices
using { /Fortnite.com/Devices }

# This is our Verse Device. It will live inside the Trigger Volume.
ZoneTrackerDevice : verse_device = {
    # We need a reference to the Analytics device.
    # Think of this as the 'wires' connecting our script to the device.
    AnalyticsRef : AnalyticsDevice
    
    # This function runs when the game starts or the device is initialized.
    OnCreated():void= {
        # Optional: Print to console to know it loaded
        print("ZoneTracker is online and watching!")
    }
    
    # This is the magic part. 
    # This function is called automatically by the Trigger Volume 
    # when a player enters.
    OnAgentEntered(Agent:agent):void= {
        # We take the 'Agent' (the player) and tell the Analytics device to record it.
        # It's like handing the bouncer the player's ID card.
        AnalyticsRef.Submit(Agent)
    }
}

Comments

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