Verse Library verse

01 Fragment

Manages a player queue and automatically processes VIP members at fixed intervals using a simulation timer.

verse-library/fortnite-fixed-sized-generic-queue-implementation-w-circular-option/01-fragment.verse

# VIP Line System - A Fixed-Size Queue Implementation

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# We create a custom Actor (a smart object) that holds our queue logic.
# Think of this as a "Smart Ticket Machine" sitting in your level.
class VipQueueActor is Actor()
    # This is our "Line". It's a list that can hold Player references.
    # Fixed size: Max 20 players.
    Queue: FixedQueue<Player> = FixedQueue<Player>(20)
    
    # A timer to process the line.
    ProcessTimer: Timer = CreateTimer()
    
    # The time between serving each player (in seconds).
    ServiceInterval: float = 5.0

    # When the game starts, set up the timer.
    OnBegin<override>()<suspends>: void = super.OnBegin()
        # Start the timer to check the queue every 5 seconds.
        ProcessTimer.SetInterval(ServiceInterval)
        ProcessTimer.Loop()

    # This event fires every time the timer ticks.
    OnTimer<override>(timer: Timer)<suspends>: void = 
        # Only process if there are people in line.
        if (Queue.IsNotEmpty())
            # Get the next player in line (First In, First Out).
            # We remove them from the queue so they don't get served twice.

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