Skip to main content

Getting Started with Events

<div style="max-width:1200px; margin:0 auto; font-family:system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; line-height:1.65;">

<div style="background:linear-gradient(135deg, #0f172a 0%, #1e293b 100%); border:1px solid #334155; border-radius:18px; padding:28px 30px; margin:16px 0 24px 0; color:#f8fafc;">

<div style="font-size:13px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; color:#93c5fd; margin-bottom:10px;">

RAGE:MP Documentation

</div>

<div style="font-size:34px; font-weight:800; line-height:1.15; margin-bottom:12px;">

Events System

</div>

<div style="font-size:16px; color:#cbd5e1; max-width:850px;">

Events are the backbone of scripting in RAGE:MP. This page explains what they are, how to register them, how communication works between server, client, and CEF, and how to manage them cleanly.

</div>

</div>

<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:14px; margin:0 0 24px 0;">

<div style="background:#f8fafc; border:1px solid #e2e8f0; border-radius:16px; padding:18px;">

<div style="font-size:12px; font-weight:700; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Core Idea

</div>

<div style="font-size:18px; font-weight:800; color:#0f172a; margin-bottom:6px;">

Events react to things

</div>

<div style="color:#475569; font-size:14px;">

Built-in events react automatically. Custom events react when you trigger them.

</div>

</div>

<div style="background:#f8fafc; border:1px solid #e2e8f0; border-radius:16px; padding:18px;">

<div style="font-size:12px; font-weight:700; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Communication

</div>

<div style="font-size:18px; font-weight:800; color:#0f172a; margin-bottom:6px;">

Know your direction

</div>

<div style="color:#475569; font-size:14px;">

Server, client, and CEF do not all communicate the same way.

</div>

</div>

<div style="background:#f8fafc; border:1px solid #e2e8f0; border-radius:16px; padding:18px;">

<div style="font-size:12px; font-weight:700; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Rule

</div>

<div style="font-size:18px; font-weight:800; color:#0f172a; margin-bottom:6px;">

Register first

</div>

<div style="color:#475569; font-size:14px;">

An event must be registered before you can use or trigger it.

</div>

</div>

</div>

Introduction

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:16px; padding:22px; margin:0 0 20px 0;">

Events are the <b>core scripting system</b> for RAGE:MP.

They are registered by you and triggered when a specific action or situation happens.

For example, [PlayerEnterCheckpoint](/playerentercheckpoint) is triggered when a player enters a checkpoint. That event gives you:

  • the <b>Player</b> that entered it
  • the <b>Checkpoint</b> that was entered

</div>

Event Types

<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr)); gap:16px; margin:0 0 22px 0;">

<div style="background:linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); border:1px solid #bfdbfe; border-radius:18px; padding:22px;">

<div style="font-size:13px; font-weight:800; text-transform:uppercase; color:#1d4ed8; margin-bottom:8px;">

Type 1

</div>

<div style="font-size:24px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Built-in Events

</div>

<div style="color:#334155; margin-bottom:12px;">

These are provided by <b>RAGE:MP</b> and are triggered automatically in certain situations.

</div>

<div style="color:#475569; font-size:14px; margin-bottom:10px;">

Examples:

</div>

  • player entering a checkpoint
  • player quitting
  • player spawning

<div style="font-size:14px;">

<b>Lists:</b>

  • [Server-side events](/server-side-events)

<!-- -->

  • [Client-side events](/client-side-events)

</div>

</div>

<div style="background:linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%); border:1px solid #bbf7d0; border-radius:18px; padding:22px;">

<div style="font-size:13px; font-weight:800; text-transform:uppercase; color:#15803d; margin-bottom:8px;">

Type 2

</div>

<div style="font-size:24px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Custom Events

</div>

<div style="color:#334155; margin-bottom:12px;">

These are created by <b>you</b> and can be triggered whenever you want.

</div>

<div style="color:#475569; font-size:14px; margin-bottom:10px;">

Use them to:

</div>

  • connect systems together
  • trigger your own gameplay logic
  • send data between layers
  • create reusable scripting flows

</div>

</div>

Registering Events

<div style="background:#fff7ed; border:1px solid #fdba74; border-radius:16px; padding:16px 18px; margin:0 0 18px 0; color:#9a3412;">

<b>Important:</b> You must register an event before using it anywhere.

</div>

Server-side Event

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:16px; padding:18px; margin:0 0 18px 0;">

A normal server-side event can be registered like this:

</div>

Client → Server Event

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:16px; padding:18px; margin:0 0 18px 0;">

If the event is <b>triggered from client-side</b> but <b>registered on server-side</b>, the first argument must be <b>player</b>.

This happens because the client sends the local player together with the event data, allowing the server to know who triggered it.

</div>

CEF Notes

<div style="background:#f8fafc; border:1px solid #cbd5e1; border-radius:16px; padding:18px; margin:0 0 22px 0;">

<div style="font-size:18px; font-weight:800; color:#0f172a; margin-bottom:10px;">

CEF behaves differently

</div>

  • CEF cannot communicate directly with server-side
  • CEF mainly communicates with client-side
  • Older documentation often describes CEF more restrictively, but newer support exists in later versions

<div style="font-size:14px; font-weight:700; color:#334155; margin-bottom:8px;">

In version 1.1:

</div>

<div style="background:#0f172a; color:#e2e8f0; border-radius:14px; padding:16px; overflow:auto;">

``` Added: CEF: mp.events.add(string eventName, function handler) Added: CEF: mp.events.reset() Added: CEF: mp.events.remove(string eventName) Added: CEF: mp.events.call(string eventName) (alias to mp.trigger) Added: Client-side: Browser.call(eventName, arguments...) ```

</div>

</div>

Calling Events

<div style="background:#eef2ff; border:1px solid #c7d2fe; border-radius:16px; padding:18px; margin:0 0 20px 0; color:#3730a3;">

<b>Tip:</b> Most event confusion comes from not knowing which side is calling which side.

</div>

<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(360px,1fr)); gap:16px; margin:0 0 24px 0;">

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:20px;">

<div style="font-size:12px; font-weight:800; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Local

</div>

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Same Side

</div>

<div style="color:#475569; margin-bottom:12px;">

Use this when you call an event on the same side it exists on.

</div>

<div style="font-weight:700; margin-bottom:8px;">

Syntax

</div>

</div>

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:20px;">

<div style="font-size:12px; font-weight:800; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Remote

</div>

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Server → Client

</div>

<div style="color:#475569; margin-bottom:12px;">

The server tells one player or multiple players to execute a client-side event.

</div>

<div style="font-weight:700; margin-bottom:8px;">

Single player

</div>

<div style="font-weight:700; margin:14px 0 8px 0;">

All players

</div>

<div style="font-weight:700; margin:14px 0 8px 0;">

Filtered players

</div>

</div>

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:20px;">

<div style="font-size:12px; font-weight:800; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Remote

</div>

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Client → Server

</div>

<div style="color:#475569; margin-bottom:12px;">

Use this when the client wants to trigger a server-side event.

</div>

<div style="font-weight:700; margin-bottom:8px;">

Syntax

</div>

</div>

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:20px;">

<div style="font-size:12px; font-weight:800; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Bridge

</div>

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Client ↔ CEF

</div>

<div style="color:#475569; margin-bottom:12px;">

CEF does not directly talk to server-side. It goes through the client.

</div>

<div style="font-weight:700; margin-bottom:8px;">

Client → CEF

</div>

<div style="font-weight:700; margin:14px 0 8px 0;">

CEF → Client

</div>

</div>

</div>

Example Flow

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:22px; margin:0 0 24px 0;">

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Server command triggering a client effect

</div>

<div style="color:#475569; margin-bottom:18px;">

In this example, a player uses a server command, and the server tells that player's client to start a screen effect.

</div>

<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(360px,1fr)); gap:16px;">

<div>

<div style="font-size:16px; font-weight:800; color:#0f172a; margin-bottom:8px;">

Server-side

</div>

</div>

<div>

<div style="font-size:16px; font-weight:800; color:#0f172a; margin-bottom:8px;">

Client-side

</div>

</div>

</div>

</div>

Cancelling and Managing Events

<div style="display:grid; grid-template-columns:repeat(auto-fit,minmax(360px,1fr)); gap:16px; margin:0 0 24px 0;">

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:20px;">

<div style="font-size:12px; font-weight:800; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Method 1

</div>

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Pause / Destroy

</div>

<div style="color:#475569; margin-bottom:12px;">

To control an event instance directly, you can use <b>mp.Event</b>.

</div>

</div>

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:18px; padding:20px;">

<div style="font-size:12px; font-weight:800; text-transform:uppercase; color:#64748b; margin-bottom:8px;">

Method 2

</div>

<div style="font-size:22px; font-weight:800; color:#0f172a; margin-bottom:10px;">

Remove from Tree

</div>

<div style="color:#475569; margin-bottom:12px;">

You can remove a specific handler, remove all handlers for an event, remove multiple events, or reset the whole tree.

</div>

</div>

</div>

Quick Reference

<div style="background:#0f172a; border:1px solid #334155; border-radius:18px; padding:22px; margin:0 0 24px 0; color:#e2e8f0;">

<div style="font-size:22px; font-weight:800; margin-bottom:14px;">

Cheat Sheet

</div>

ActionMethod
Register local event`mp.events.add(...)`
Call local event`mp.events.call(...)`
Client to server`mp.events.callRemote(...)`
Server to one client`player.call(...)`
Server to all clients`mp.players.call(...)`
CEF to client`mp.trigger(...)`
Client to CEF`browser.execute(...)`
Remove event`mp.events.remove(...)`
Reset all events`mp.events.reset()`

</div>

Summary

<div style="background:linear-gradient(180deg, #f8fafc 0%, #ffffff 100%); border:1px solid #e2e8f0; border-radius:18px; padding:22px; margin:0 0 24px 0;">

  • Events are the foundation of scripting in RAGE:MP
  • Built-in events are automatic, custom events are created by you
  • Always register events before using them
  • Server, client, and CEF each have different communication rules
  • You can disable, destroy, remove, or reset events when needed

</div>

See also

<div style="background:#ffffff; border:1px solid #e2e8f0; border-radius:16px; padding:18px; margin:0 0 20px 0;">

</div>

</div>