addEventHandler: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
No edit summary
 
(No difference)

Latest revision as of 19:55, 8 May 2020

Function Server and Client icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Server 1.0.0, Client 1.0.0

void addEventHandler(string eventName, function handler)

The addEventHandler function is used to add a handler to call when an event occurs.
If the event is not an event provided by GTAC, it must be registered first by calling addEvent.

Parameters

1) string eventName The name of the event, case-insensitive.
2) function handler The scripting function to call when the event occurs.

Return

void This function doesn't return a value.

Callbacks

function handler(Event event, [...])

1) Event event The event object.
2) ... vararg The arguments specific to the eventName.

Notes

Examples

Example 1 - JavaScript:

addEventHandler('onPedWasted', function(event, ped, attacker, weapon, piece) { if(ped.isType(ELEMENT_PLAYER)) { message(ped.name + ' has died.'); } else { message('A ped has died.'); } });

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png bindEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png removeEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerNetworkEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png unbindEventHandler


Client Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png addEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png bindEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png removeEventHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png triggerNetworkEvent
icon-iii.png icon-vc.png icon-sa.png icon-iv.png unbindEventHandler