GetEventHandlers: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua">[Lua] | <syntaxhighlight lang="lua">[Lua] | ||
function | function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) | ||
if | if | ||
type( sEventName ) == 'string' and | type( sEventName ) == 'string' and | ||
Line 48: | Line 48: | ||
addCommandHandler( 'removeOnPlayerWastedEvent', | addCommandHandler( 'removeOnPlayerWastedEvent', | ||
function() | function() | ||
if | if isEventHandlerAdded( 'onPlayerWasted', root, onPlayerWasted ) then | ||
outputChatBox( 'onPlayerWasted succesfully removed!' ) | outputChatBox( 'onPlayerWasted succesfully removed!' ) | ||
removeEventHandler( 'onPlayerWasted', root, onPlayerWasted ) | removeEventHandler( 'onPlayerWasted', root, onPlayerWasted ) |
Revision as of 13:49, 17 February 2013
Syntax
table getEventHandlers ( string eventName, element attachedTo )
Required Arguments
- eventName: The name of the event. For example ( "onPlayerWasted" ).
- attachedTo: The element attached to.
Returns
Returns table with attached functions, false otherwise.
Example
Click to collapse [-]
Server[Lua] function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end return false end return false end return false end function onPlayerWasted() outputChatBox( getPlayerName( source ) .. ' died.' ) end addEventHandler( 'onPlayerWasted', root, onPlayerWasted ) addCommandHandler( 'removeOnPlayerWastedEvent', function() if isEventHandlerAdded( 'onPlayerWasted', root, onPlayerWasted ) then outputChatBox( 'onPlayerWasted succesfully removed!' ) removeEventHandler( 'onPlayerWasted', root, onPlayerWasted ) end end )
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled