AddEvent: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function allows you to define an [[event]]. These function exactly like the built in events. See [[event system]] for more information on the event system.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool addEvent ( string name, string arguments )   
bool addEvent ( string eventName, string arguments )   
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''eventName:''' The name of the event you wish to create
 
*'''arguments:''' A string of comma seperated variable names indicating the arguments your event takes. These names are used for event handlers that are coded in the map structure. For example "message, playerName".
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns ''true'' if the event was added successfully, ''false'' otherwise.


==Example==  
==Example==  
This example does...
This example will define a new event called ''onSpecialEvent''. You could trigger this later using [[triggerEvent]].
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
-- Get the root map element
blabhalbalhb --abababa
rootElement = getRootElement ()
--This line does this...
 
mooo
-- Add a new event called onSpecialEvent that has one parameter 'text'
addEvent ( "onSpecialEvent", "text" )
 
-- Add an event handler
addEventHandler ( "onSpecialEvent", rootElement, "specialEventHandler" )
-- Define our handler function
function specialEventHandler ( text )
outputChatBox ( text )
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Event functions}}
{{Event functions}}

Revision as of 23:49, 20 May 2006

This function allows you to define an event. These function exactly like the built in events. See event system for more information on the event system.

Syntax

bool addEvent ( string eventName, string arguments )   

Required Arguments

  • eventName: The name of the event you wish to create
  • arguments: A string of comma seperated variable names indicating the arguments your event takes. These names are used for event handlers that are coded in the map structure. For example "message, playerName".

Returns

Returns true if the event was added successfully, false otherwise.

Example

This example will define a new event called onSpecialEvent. You could trigger this later using triggerEvent.

-- Get the root map element
rootElement = getRootElement ()

-- Add a new event called onSpecialEvent that has one parameter 'text'
addEvent ( "onSpecialEvent", "text" )

-- Add an event handler
addEventHandler ( "onSpecialEvent", rootElement, "specialEventHandler" )
-- Define our handler function
function specialEventHandler ( text )
	outputChatBox ( text )
end

See Also

Shared