ES/addEvent

From Multi Theft Auto: Wiki
Revision as of 21:50, 16 July 2013 by Kevin Gross (talk | contribs) (Created page with "__NOTOC__ {{Server client function}} ==Syntaxis== <syntaxhighlight lang="lua"> bool addEvent ( string nombreEvento [, bool permitirtrigerremoto = false ] ) </syntaxhighlight> ===Argumentos Requer...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Syntaxis

bool addEvent ( string nombreEvento [, bool permitirtrigerremoto = false ] )   

Argumentos Requeridos

  • nombreEvento: El nombre del evento que deseas crear

Optional Arguments

  • permitirtrigerremoto: Un boolean determinando si puedes trigear el evento remotamente.

Returns

Devuelve true si el evento fue agregado exitosamente, false si el evento ya esta agregado.

Example

This example will define a new event called onSpecialEvent.

-- Add a new event called onSpecialEvent
addEvent ( "onSpecialEvent", true )

-- Define our handler function, that takes a "text" parameter and outputs it to the chatbox
function specialEventHandler ( text )
	outputChatBox ( text )
end

-- Add it as a handler for our event
addEventHandler ( "onSpecialEvent", getRootElement(), specialEventHandler )

You can then trigger this event later on using:

	triggerEvent ( "onSpecialEvent", getRootElement(), "test" )

This will cause the handler to be triggered, so "test" will be output to the chatbox.

See Also