Track item mechanic

Hey! I want to create a mechanic for my map that checks if a player has a specific item in their inventory. If they do, they get 1 gold coin every second. If not, nothing happens. Is there a way to do this in Verse?

1 Like

You need to create a loop that has a Sleep(1.0) inside of it.
Then, add an @editable const of type conditional_button_device and another one of type item_granter_device, call them like CondButton and GoldGrant.

Inside the loop you need to add the control. Use an if statement to check if the player has the item, by using the HasAllItems function of the conditional button and then grant gold to the player.

This is a basic code for this, that checks every player in the map. You’ll obviously need to set the conditional button and the item granter correctly.

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

Test := class(creative_device):
    
    @editable CondButton : conditional_button_device = conditional_button_device{}
    @editable GoldGrant : item_granter_device = item_granter_device{}

    OnBegin<override>()<suspends>:void=
        loop:
            Sleep(1.0)
            for(Player : GetPlayspace().GetPlayers()):
                if(CondButton.HasAllItems[Player]):
                    GoldGrant.GrantItem(Player)

Thank you, it worked!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.