Events::add

From RAGE Multiplayer Wiki

This function registers event handlers.

Returning true will destroy automatically the event handler.


Shared
Function

 C#  JavaScript



C# Syntax

RAGE.Events.Add(string eventName, RAGE.Events.CallDelegate handler);


JavaScript Syntax

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