addEventHandler

From GTA Connected
Jump to: navigation, search

Function Server and Client All Games Online and Offline

Server 1.0.0, Client 1.0.0

void addEventHandler(string eventName, function handler)

Description

The addEventHandler function is used to add a handler to call when an event occurs.

Parameters

Type Name Presence Default Value Description
string eventName required n/a The name of the event, case-insensitive.
function handler required n/a The scripting function to call when the event occurs.

Returns

Success Returns

Type Description
void This function doesn't return any values on success.

Failure Returns

Type Value
void n/a

Callbacks

function(Event event, [...])

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
unbindEventHandler

event.isDefaultPrevented
event.preventDefault


Client Related

addEvent
addEventHandler
bindEventHandler
removeEventHandler
triggerEvent
unbindEventHandler

event.isDefaultPrevented
event.preventDefault