addEventHandler

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

        addEvent
        addEventHandler
        bindEventHandler
        removeEventHandler
        triggerEvent
        triggerNetworkEvent
        unbindEventHandler


Client Related

        addEvent
        addEventHandler
        bindEventHandler
        removeEventHandler
        triggerEvent
        triggerNetworkEvent
        unbindEventHandler