addEvent | Multi Theft Auto: Wiki Skip to content

addEvent

Client-side
Server-side
Shared

This function allows you to register a custom event. Custom events function exactly like the built-in events. See event system for more information on the event system.

Syntax

bool addEvent ( ​string eventName, [ ​bool allowRemoteTrigger = false ] )
Required Arguments
  • eventName: The name of the event you wish to create.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

Returns

  • bool: result

Returns true if the event was added successfully, otherwise false if the event already exists built-in game events or if it fails for any other reason.

Code Examples

shared

This example will define a new event.

addEvent("onSpecialEvent", true)
function specialEventHandler(text)
outputChatBox(text)
end
addEventHandler("onSpecialEvent", root, specialEventHandler)