AxelCapek
(AxelCapek)
August 26, 2023, 3:44pm
1
When using a custom event to check when a player “Gets back on a vehicle” the event GotBackOnVehicleEvent(Slot).Signal()
never wins in my race
event!
What am I doing wrong? Snippet:
GotBackOnVehicleEvent<public>(Slot:int) : event() = event(){}
ExitedVehicle(Agent:agent, Slot:int):void=
Print("Player exited Vehicle! Slot: {Slot}")
spawn { CheckRespawnVehicle(Agent, Slot) }
CheckRespawnVehicle(Agent:agent, Slot:int)<suspends>:void=
race:
block:
GotBackOnVehicleEvent(Slot).Await()
Print("Player got back on vehicle! Slot: {Slot}")
block:
Sleep(EmptyVehicleRespawnTime)
Print("Player didnt get back on vehicle in time!")
if. Vehicle := DirtBikes[Slot] then Vehicle.RespawnVehicle()
EnteredVehicle(Agent:agent, Slot:int):void=
Print("Player entered vehicle! Slot: {Slot}")
GotBackOnVehicleEvent(Slot).Signal()
All Print
events happen except for:
Print("Player got back on vehicle! Slot: {Slot}")
Ep8Script
(Ep8Script)
August 27, 2023, 5:22am
2
GotBackOnVehicleEvent
is a function and thus returns a new event()
object every time - you should use an array or map instead to ensure the same object is being used
1 Like
AxelCapek
(AxelCapek)
August 27, 2023, 10:17am
3
Hey @Ep8Script , thanks for the reply.
Can you explain this further? I’ve successfully used events before, for example if I used
GotBackOnVehicleEvent<public>() : event() = event(){}
and
GotBackOnVehicleEvent().Signal()
These would work fine - how exactly does adding Slot:int
change it’s purpose and in what scenario would I use this if not in my case?
Edit: I solved my particular case by using a class that handles events, however still questioning how changing the payload broke things.
Ep8Script
(Ep8Script)
August 28, 2023, 2:11pm
4
Each time you run GetBackOnVehicleEvent
here, a new event
object is created - therefore calling GetBackOnVehicleEvent().Signal()
will signal a different event to what GetBackOnVehicleEvent().Await()
is awaiting - to have them be the same event
object, you’d need to store the event
object somewhere as a constant or variable
Are you sure you had this working previously? It shouldn’t be possible
AxelCapek
(AxelCapek)
August 28, 2023, 2:13pm
5
Interesting, I’ve used it several times this way! Pretty sure there’s also official docs using it in this way.
Ep8Script
(Ep8Script)
August 28, 2023, 4:12pm
6
Can you double check? I’m very curious because it shouldn’t be possible lol, but happy to be wrong about it!
AxelCapek
(AxelCapek)
August 28, 2023, 4:20pm
7
Just checked another project and its set up like above. Looking for doc examples!
Ep8Script
(Ep8Script)
August 29, 2023, 12:57am
8
Are you able to definitely verify it works or share code that does? I’m confused