Verse Library verse

01 Standalone

Manages a player line array to add members to the back and remove them from the front for serving.

verse-library/fortnite-generic-queue-implementation/01-standalone.verse

# We need to access the player system to get player handles
using { /Fortnite.com/Players }
# We need the teleporter device to move people
using { /UnrealEngine.com/Temporary/SpatialMath }

# This is our "Brain" script. It holds the line.
RedCarpetQueue := class:
    # The Line: An array that holds players. 
    # []Player means "a list of zero or more players."
    # internal means only this script can see/change it directly.
    PlayerLine:<internal>[]Player = array{}

    # The "Join Line" function. Called when a player hits the join button.
    JoinLine(Player:Player):void=
        # Add the player to the END of the array.
        # Think of this as the person standing at the back of the line.
        PlayerLine := array{PlayerLine, Player}
        
        # Tell the player they're in line (optional, but nice)
        PrintToPlayer(Player, "You are now in line. Position: ", to_string(len(PlayerLine)))

    # The "Serve Next" function. Called by the Red Carpet device.
    ServeNext():void=
        # Check if the line is empty.
        # len() gives us the number of items in the array.
        if(len(PlayerLine) > 0):
            # Take the FIRST player (index 0) from the line.
            # We use "slice" to get the first element.
            NextPlayer := PlayerLine[0]

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