triggerEvent | Multi Theft Auto: Wiki Skip to content

triggerEvent

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function will trigger a named event on a specific element in the element tree. See event system for more information on how the event system works.

Note

You should avoid triggering events on the root element unless you really need to. Doing this triggers the event on every element in the element tree, which is potentially very CPU intensive. Use as specific (i.e. low down the tree) element as you can.

Note

See Event Source Element for a descriptive visualization of the event system handling an event trigger.

Syntax

triggerEvent ( )

Code Examples

server

If you define a new custom event as follows:

function onCustomEvent(chatMessage)
outputChatBox(chatMessage)
end
addEvent("onCustomEvent", false) -- set to false, so this event won't be called from counter side - important security measure
addEventHandler("onCustomEvent", root, onCustomEvent)