M MY Multiplayer: Wiki
Side
Kind

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

NameTypeDescription
eventNamestringThe name of a registered event.
sourceelementThe element the event happens on. It becomes the handlers' source global.
...anyArguments 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)

See also