getEventHandlers | Multi Theft Auto: Wiki Skip to content

getEventHandlers

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function gets the attached functions from the event and attached element from current lua script.

Syntax

getEventHandlers ( )

Code Examples

server
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
end
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)