triggerEvent
Shared
Triggers an event on this side, on source. The element's own handlers and its ancestors' propagating ones are called right away, before the function returns.
bool triggerEvent(string eventName, element source, any ...)
Parameters
| Name | Type | Description |
|---|---|---|
| eventName | string | The name of a registered event. |
| source | element | The element the event happens on. It becomes the handlers' source global. |
| ... | any | Arguments passed to every handler. |
Returns
false if the event does not exist or a handler cancelled it with cancelEvent, else true.
To carry an event to the other side, use triggerServerEvent or triggerClientEvent. In the handlers, sourceResource is the resource that called triggerEvent.
Example
addEvent("onRaceFinish")
addEventHandler("onRaceFinish", root, function(position)
if position > 3 then
cancelEvent(true, "no podium")
end
end)
local podium = triggerEvent("onRaceFinish", resourceRoot, 2)