User:Sybellex: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "==Syntax== <syntaxhighlight lang="lua"> bool addEvent ( string eventName [, bool allowRemoteTrigger = false ] ) </syntaxhighlight> ===Required Arguments=== *'''eventName:''' The name of the event you wish to create. ===Optional Arguments=== *'''allowRemoteTrigger:''' A boolean specifying whether this event can be called remotely using triggerClientEvent / triggerServerEvent or not. ===Returns=== Returns ''true'' if the event was added successfully, ''fal...")
 
(Replaced content with "<inputbox> type=create width=100 break=no buttonlabel=Create new article placeholder=Article title </inputbox>")
Tag: Replaced
 
Line 1: Line 1:
==Syntax==
<inputbox>
<syntaxhighlight lang="lua">
type=create
bool addEvent ( string eventName [, bool allowRemoteTrigger = false ] ) 
width=100
</syntaxhighlight>
break=no
 
buttonlabel=Create new article
===Required Arguments===
placeholder=Article title
*'''eventName:''' The name of the event you wish to create.
</inputbox>
 
===Optional Arguments===
*'''allowRemoteTrigger:''' A boolean specifying whether this event can be called remotely using [[triggerClientEvent]] / [[triggerServerEvent]] or not.
 
===Returns===
Returns ''true'' if the event was added successfully, ''false'' if the event was already added.
 
==Example==
This example will define a new event called ''onSpecialEvent''.
<syntaxhighlight lang="lua">
-- 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", root, specialEventHandler )
</syntaxhighlight>
 
You can then trigger this event later on using:
<syntaxhighlight lang="lua">
triggerEvent ( "onSpecialEvent", root, "test" )
</syntaxhighlight>
 
This will cause the handler to be triggered, so "test" will be output to the chatbox.

Latest revision as of 23:35, 21 October 2024

<inputbox> type=create width=100 break=no buttonlabel=Create new article placeholder=Article title </inputbox>