Events in Verse

In my code, i have an event:

QuestProgressed : event() = event(){}

I was wondering if anyone knew when I signal that event, if it signals to all player’s awaiting for this event, or just an agent?

If it is for all players, what is a work around so that it signals to just the agent?

Thank you!

Not sure but you could test by using test players and doing something like respawning them from the event to see who is effected. What I would do for a situation like this is have a QuestProgressed Trigger that you trigger with the agent who did it, then run a OnQuestProgressed(maybeA : ?agent) function that does whatever you want with just the activating agent.

1 Like

tried that out and when you signal an event, it is not to all players in the game! thanks for helping me out!

1 Like

Players don’t await for an event, it’s the server that does. So it would depend on your code

I have this code here for example:

UpdateStrengthUI(Agent : agent, Canvas : canvas)<suspends>:void=
        if(CP := PlayerMap[Agent]):
            if(Player := player[Agent], PlayerUI := GetPlayerUI[Player]):
                race:
                    block:
                        loop:
                            ExitStrength.Await()
                            PlayerUI.RemoveWidget(Canvas)
                            return

If I have two players waiting for the “ExitStrength” Signal, would both of their UI’s be exited?

I believe you’re asking whether calling ExitStrength.Signal() resumes ALL tasks that were previously suspended by calling ExitStrength.Await() or just some of them.

The answer is that all tasks are resumed.

So, yes, if two players are waiting for the ExitStrength signal (i.e. you called UpdateStrengthUI twice) and the signal is emitted afterwards, then both of their UI’s will be exited. (Given that both calls are referencing the signal from the same class instance)

1 Like

Thank you so much! I ended up testing it with some of my friends and that ended up being the result as well.

What I did as a work around, is that since I already have a Custom Player class for persistence, I added the events into there, and that seemed to have done the job perfectly!