Verse Library verse

01 Device

Manages timed player voting sessions using trigger devices and waits for results.

verse-library/using-voting-group-and-voting-options-devices-in-fortnite/01-device.verse

using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our custom device class. Think of it as the "Brain" of the voting system.
TraitorVoteManager := class(creative_device):
    
    # These are the devices we placed in the level. 
    # We connect them in UEFN, but we reference them here.
    @editable VoteGroup : voting_group_device = voting_group_device{}
    @editable OptionA : voting_option_device = voting_option_device{}
    @editable OptionB : voting_option_device = voting_option_device{}
    @editable OptionC : voting_option_device = voting_option_device{}
    
    # This function runs when the game starts
    OnBegin<override>()<suspends>:void=
        # We can check if the vote has started
        if VoteGroup.Is_Voting():
            Print("The Traitor Vote Has Begun! Choose Wisely.")
        else:
            Print("Wait for the button press to start the vote.")

    # This function runs when a player interacts with our trigger (e.g., a button)
    StartVote<override>()<suspends>:void=
        # Start the voting group
        VoteGroup.Start_Voting()
        
        # Wait for the duration (e.g., 10 seconds)
        Wait(10.0)
        
        # Check the results

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