Events::add

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

Shared
Function

Js.png JavaScript


This function registers event handlers.

Returning true will destroy automatically the event handler.

JavaScript Syntax
Jslogo.png

Syntax

events.add(name, ...arguments);
events.add( associativeArray );

Example

Shared
function onPlayerDeath(player, reason, killer)
{
    console.log(player.name + " died.");
}

mp.events.add(
{
    "playerJoin" : player =>
    {
         console.log("New player: " + player.name);
    },

    "playerQuit" : (player, reason) =>
    {
         console.log(player.name + " quit");
    },

    "playerDeath" : onPlayerDeath
});


See Also