Getting Started with Events

From RAGE Multiplayer Wiki


Events are the core scripting system for RAGE:MP. They are registered upon your request and triggered in a certain situation, For example, PlayerEnterCheckpoint triggers when a player enters a checkpoint, so the event is automatically triggered and returns for you the Player that entered the checkpoint and the Checkpoint that he entered.

Events system

In-order to use the events you need to register the event into the events tree using addEvent.
There are 2 types of Events:

  • Built in events
  • Custom events

Built in events

They are events provided by RAGE:MP to be auto-triggered in a certain situation as we mentioned in the beginning (a Player entering a Checkpoint).

These are listed on the following pages:

Custom events

They are events build for you to control/call them anytime you want and in any situation you create for the Player.

Using events

Registering an event

You always have to register an event to the events tree before using it anywhere.

Registering it is pretty simple, but you have to keep in mind in which area it'll be called.

if your event will be for server-side use only then you can register it the way you want.

Server-Side'eventName', (arg1, arg2, etc.) => {
// code

if your event will be called from client-side and you registered it in server-side. You have to add player argument as a main first argument because client-side delivers the localPlayer with your data, so you can know which player is it.

Server-Side'eventName', (player, arg1, arg2, etc.) => {
// code

In CEF you're not allowed to register any events. You can only call the functions that are registered in your CEF.

In 1.1 version:

Added: CEF: eventName, function handler)

Added: CEF:

Added: CEF: eventName)

Added: CEF: eventName) (псевдоним к mp.trigger)

Added: Client-side:, arguments...)

Calling methods

It is pretty important to know how to call your events on each side, or you'll be totally lost in your development. We made it easier for you with the following calling methods, so you can know how the events calling system is working.

JavaScript Syntax

Calling server-side or client-side local events

Syntax'eventName', args);

Calling client-side events from server-side (the server-side calls client-side)

Notice: arguments must be inside an array.

Make a player call their client-side

Syntax'eventName', [arg1, arg2]);
Example 1

With this example we'll add a server-side command that calls a client-side event that starts a screen effect on the player who types the command. As show below, once a player types /effect [effect] (for example, /effect ChopVision) it will send whatever the player typed on the first argument to the event created on the client-side ('startEffectEvent').

Server-Side'effect', (player, fullText, effect) => {'startEffectEvent', [effect]);

On the client-side, it will received whatever the player typed on the first argument and replace it on the effect.

Client-Side'startEffectEvent', (effect) => {, 10000, false);

Make all players in the server call their client-side

Syntax'eventName', [arg1, arg2]);

Make server-side call a filtered player's client-side

The example below filters a player with the name WeirdNewbie to call his client-side.

Syntax => == 'WeirdNewbie'), 'eventName', [args]);

Calling server-side events from client-side (the client-side calls server-side)

Syntax'eventName', args);

Calling a function registered in CEF from client-side (the client-side calls CEF)



Calling a client-side event from CEF (the CEF calls client-side)

Notice: You can't communicate between CEF and server-side


mp.trigger('eventName', args);

Cancelling events

There are 2 ways to cancel a event:

  • Pausing it for future use.
  • Removing it from events tree.


In-order to pause a event you are required to use a special function to add that event (mp.Event).
A small example of how to use it:

let ev = new mp.Event("playerDeath", (player, reason, killer) =>
    mp.players.broadcast('First blood!');
    ev.destroy(); // this event handler will be not called anymore since it's destroyed
// ev.enable(); due to this line the event will be re-enabled.
// ev.destroy(); due to this line the event is never going to be executed if we call this before it


Here are all the methods to remove events:

// Remove specified handler of specified event
function playerJoinHandler(player)

}"playerJoin", playerJoinHandler);"playerJoin", playerJoinHandler);

// Remove handler(s) specified event(s)"playerJoin");["playerJoin", "playerQuit"]);

// Reset whole event tree.;

// Get all handlers of specified event"playerJoin").forEach(_ev => _ev(null));

See also