# How do I use SuccessEvent on a timer device?

**URL:** <https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [August 4, 2023, 6:26pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934 "2023-08-04T18:26:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 4, 2023, 6:26pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/1 "2023-08-04T18:26:39Z")

</div>

The title says it all, I want to use the data member “SuccessEvent” to execute a part of my code. I don’t exactly know how to do this because it uses “listenable” and I’m only familiar with “Subscribe” which isn’t the case here. Can anyone help?

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [August 4, 2023, 7:17pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/2 "2023-08-04T19:17:40Z")

</div>

TimerDevice.SuccessEvent.Subscribe(OnTimerFinish)

That’s it 🙂

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 4, 2023, 9:15pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/3 "2023-08-04T21:15:51Z")

</div>

Getting this error:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/f/b7fb65c9bb1cd7078069d7641007d045cef0e8bc.png)

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [August 4, 2023, 9:33pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/4 "2023-08-04T21:33:01Z")

</div>

you have to define that method “OnTimerFinish” because that is what is going to get called when the timer finishes

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 4, 2023, 9:45pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/5 "2023-08-04T21:45:26Z")

</div>

What do you mean define, could you give an example?

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [August 4, 2023, 9:53pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/6 "2023-08-04T21:53:34Z")

</div>

You said you were familiar with “Subscribe” so I assumed you had written verse code before. Anyways, something like this:

OnTimerFinish(Agent:agent):void=  
#whatever you want here

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 4, 2023, 10:39pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/7 "2023-08-04T22:39:55Z")

</div>

> [@GraemeBB](#):
>
> You said you were familiar with “Subscribe” so I assumed you had written verse code before.

I meant that I read a few things about that, just never implemented it (I’m still learning verse so I’m not the best in the world). Anyways, I did that and it came up with an error:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/0/490975325eceec5e838505e68a94c3997cd4cab2.png)

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [August 4, 2023, 10:47pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/8 "2023-08-04T22:47:39Z")

</div>

It’s time for you to learn about Verse then 🙂 Here is one of my tutorials to get you up and running:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/e/03e6dccf99c6d4f464e1362c7b709b1e74981159.jpeg "Easy Beginning With UEFN Verse Coding For Fortnite Creative") ](https://www.youtube.com/watch?v=O-RB653N_vg)

The quick answer though is that you have to tab in your line below the method

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 5, 2023, 9:38am UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/9 "2023-08-05T09:38:54Z")

</div>

I watched your tutorial and learned a few things 👍. However, as for the code, it still gives me an error and I don’t think it’s linked to the actual indentation of the function. Everything else becomes underlined in red too. Can you help on this?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/e/b2e895b9973670d00857344bfccea1653df96222.png)

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [August 5, 2023, 3:03pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/10 "2023-08-05T15:03:41Z")

</div>

You’re missing indentation under your if statement

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 5, 2023, 11:44pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/11 "2023-08-05T23:44:20Z")

</div>

Tried a bunch of stuff and it just keeps messing up. Can you help, I’m really confused.

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Random }

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
testing := class(creative_device):

    @editable
    OrderTimer : timer_device = timer_device{}

    @editable
    ButtonHouse1 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse2 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse3 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse4 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse5 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse6 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse7 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse8 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse9 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse10 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse11 : conditional_button_device = conditional_button_device{}
    @editable
    ButtonHouse12 : conditional_button_device = conditional_button_device{}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        # TODO: Replace this with your code

        var buttonActive1 : logic = false
        var buttonActive2 : logic = false
        var buttonActive3 : logic = false
        var buttonActive4 : logic = false
        var buttonActive5 : logic = false
        var buttonActive6 : logic = false
        var buttonActive7 : logic = false
        var buttonActive8 : logic = false
        var buttonActive9 : logic = false
        var buttonActive10 : logic = false
        var buttonActive11 : logic = false
        var buttonActive12 : logic = false

        var activeOrders : int = 0

        #on timer success, get a random int
        OrderTimer.SuccessEvent.Subscribe(OnTimerFinish)

    OnTimerFinish(Agent:agent):void=
        var randomHouseGen:int = GetRandomInt(1,12)

        Print("{randomHouseGen}")
        #if activeOrders = 5, wait until it goes back to 3 to continue

        if(randomHouseGen = 1, activeOrders < 5, buttonActive1 = false):
            randomOrder(ButtonHouse1, "House 1")
            set buttonActive1 = true
            set activeOrders = activeOrders + 1

    
    randomOrder(ButtonHouseNum:conditional_button_device, HouseName:string):void =

        var pizza : int = GetRandomInt(1,3)
        var slurp : int = GetRandomInt(0,3)
        var icecream : int = GetRandomInt(0,3)

        ButtonHouseNum.Enable()

        if (pizza = 1):
            ButtonHouseNum.SetItemCountRequired(0,1)
        else if (pizza = 2):
            ButtonHouseNum.SetItemCountRequired(0,2)
        else if (pizza = 3):
            ButtonHouseNum.SetItemCountRequired(0,3)

            

        if (slurp = 0):
            ButtonHouseNum.SetItemCountRequired(1,0)
        else if (slurp = 1):
            ButtonHouseNum.SetItemCountRequired(1,1)
        else if (slurp = 2):
            ButtonHouseNum.SetItemCountRequired(1,2)
        else if (slurp = 3):
            ButtonHouseNum.SetItemCountRequired(1,3)

        if (icecream = 0):
            ButtonHouseNum.SetItemCountRequired(2,0)
        else if (icecream = 1):
            ButtonHouseNum.SetItemCountRequired(2,1)
        else if (icecream = 2):
            ButtonHouseNum.SetItemCountRequired(2,2)
        else if (icecream = 3):
            ButtonHouseNum.SetItemCountRequired(2,3)

        Print ("Order from " + HouseName)

        Print("{pizza}" + " pizzas")

        if (slurp > 0):
            Print("{slurp}" + " milkshakes")

        if (icecream > 0):
            Print("{icecream}" + " ice creams")

```

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [August 5, 2023, 11:52pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/12 "2023-08-05T23:52:01Z")

</div>

Sorry, the agent is a possible fail so it’s like this:

OnTimerFinish(Agent:?agent):void=

Add in that question mark

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 5, 2023, 11:55pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/13 "2023-08-05T23:55:06Z")

</div>

Yup, that was it. Thanks a lot

---

<div class="post-metadata">

**Author:** ![Owen\_0182](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Owen\_0182](https://forums.unrealengine.com/u/Owen_0182)\
**Post date:** [August 16, 2023, 4:44pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/14 "2023-08-16T16:44:39Z")

</div>

Thanks for your responses. This also worked in my project. If you dont mind could you explain what (Agent:?agent) does? I’ve never seen this without an equals. Usually I use (Agent := agent). I was appending the ? but keep having an error until I removed the equals sign. From my understanding ‘:=’ is used to assign a value to a variable that might fail. But what does ‘:’ by itself do? Thanks again!

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 16, 2023, 10:37pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/15 "2023-08-16T22:37:13Z")

</div>

I’m not sure about the := because someone told me about this. All I know is that you put the ? because Agent is failable and that’s always the case with timers no matter what

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [September 15, 2023, 10:37pm UTC](https://forums.unrealengine.com/t/how-do-i-use-successevent-on-a-timer-device/1250934/16 "2023-09-15T22:37:46Z")

</div>

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