Events

Register a handler with mp.events.add(name, handler) on the server or in a client script. A handler that throws is reported in the log and the other handlers still run. SixL events cannot be cancelled (RAGE MP's this.cancel does nothing here).

mp.events.add('playerReady', (player) => player.outputChatBox('Welcome!'));

Several events have the same name on the server and on the client but different arguments. Each table below says where the event is raised.

Server events

Raised on the server; the handler runs in a server package.

EventWhen it firesArguments, in order
packagesLoadedEvery server package finished loading.none
incomingConnectionA connection arrived and is being set up. The handler cannot refuse it.ip (text): the client's address; serial (text): the hardware serial (64 hex characters) or an empty text; login (text): the lobby account name the player proved, or an empty text for a guest
playerJoinA player connected, before the client is ready.player
playerReadyThe player's client is ready (after the welcome and the load-in scene). player.position is where the player really is (the server waits a moment for the first position from the player's game, so placing something near the player works). A teleport or player.spawn() is safe here. playerSpawn follows at once.player
playerSpawnRight after playerReady for the first spawn, and again after every player.spawn().player
playerQuitA player left. The player is already removed from mp.players but still readable. Raised before entityDestroyed.player; exitType (text): 'disconnect', 'timeout' or 'kicked'; reason (text): the text shown when kicked or banned, otherwise empty
playerChatA player sent a chat line.player; text (text)
playerCommandA player sent a command (/name ...) that no mp.events.addCommand handler is registered for.player; command (text): the whole line without the slash, arguments included
playerDamageA player lost health or armour (once per loss; healing raises nothing).player; healthLoss (number); armorLoss (number)
playerDeathA player died (once until their health is above 0 again).player; reason (number): the weapon hash of the last hit report younger than 5 seconds, or 0; killer (player): who made that hit, or undefined
playerWeaponChangeThe weapon in the player's hand changed.player; oldWeapon (number); newWeapon (number): GTA VI weapon hashes
playerWeaponHitA player's shot hit another player. A request: the script must check it and apply the damage itself.attacker (player); target (player); hit (object): damage, weapon, bodyPart, bone, point ({ x, y, z })
pedWeaponHitA player's shot hit a server ped. The script applies the damage itself.attacker (player); ped; hit (object): damage, weapon, and, with the current protocol, bone, bodyPart, point
playerStartEnterVehicleA player started getting into a vehicle (walking to the door, opening it). The seat is kept for them from now on.player; vehicle (or null); seat (number, 0 = driver)
playerEnterVehicleA player sat in a vehicle. Not raised for an entry the player gave up.player; vehicle (or null); seat (number, 0 = driver)
playerStartExitVehicleA player started getting out of a vehicle. They still have the seat.player
playerExitVehicleA player left a vehicle.player; vehicle (or null); seat (number): the seat they had
playerStreamInA player came into another player's range.player: who came into range; forPlayer: who now sees them
playerStreamOutA player left another player's range.player; forPlayer
playerEnterColshapeA player entered a colshape (checked about every 100 ms, same dimension).player; colshape
playerExitColshapeA player left a colshape (not raised for a player who left the server).player; colshape
playerEnterCheckpointA player entered a checkpoint (3D distance, same dimension, checkpoint shown to them, checked about every 100 ms).player; checkpoint
playerExitCheckpointA player left a checkpoint.player; checkpoint
playerReachWaypointA player reached the waypoint set on the map: the player's client saw it go away with the player within 50 m of it (asked once a second) and told the server. Raised while the player's client is connected and its runtime runs: the client asks about the waypoint once a second, whether or not a client script listens.player
vehicleDamageA vehicle lost health (once per loss, from the driver's reported state).vehicle; bodyHealthLoss (number); engineHealthLoss (number)
vehicleDeathA vehicle was destroyed (once per death).vehicle
vehicleSirenToggleThe siren of a vehicle was turned on or off (from the driver's reported state; partial, not yet confirmed in the game).vehicle; state (true when on)
trailerAttachedA trailer was hitched to a vehicle, or let go (from the driver's reported state; partial, not yet confirmed in the game).vehicle; trailer (the trailer vehicle, null when let go)
entityCreatedAn entity was created: a player joined, or a vehicle, ped, object, blip, marker, label, checkpoint or colshape was made.entity
entityDestroyedAn entity was destroyed or left.entity
entityModelChangeA script changed an entity's model (not for the first value).entity; oldModel (text or number)
dummyEntityCreatedA dummy entity was created.dummy
dummyEntityDestroyedA dummy entity was destroyed.dummy
serverShutdownThe server is shutting down. Handlers have about 0.2 seconds.none

Chat commands

mp.events.addCommand('name', (player, fullText, ...words) => {}) registers a command. The name is matched without regard to case and a leading slash is optional. fullText is everything after the command name; words are the same text split by spaces. When a handler exists for the command, only that handler runs and playerCommand is not raised.

The game client has a built-in chat (mp.gui.chat): the player presses T, types a line and presses Enter. A line that starts with / is a command: playerCommand, or the handler registered with addCommand. Any other line raises playerChat. At most 5 lines in 3 seconds are sent from the game client, and a line is cut to 256 characters. The server enforces its own limit for each player as well (by default 10 lines in 3 seconds, chat and commands together, and 256 characters; see chat in the server settings): lines over it never reach playerChat or playerCommand, so a modified client cannot flood your handlers. The server's player.outputChatBox lines appear in the built-in chat. A game mode that wants its own chat page marks a browser with markAsChat, and the chat goes to it.

Damage and death

Which events exist today, and who decides what.

What happenedWhat your server script gets
A player shot another playerplayerWeaponHit(attacker, target, hit): a request. Nothing is subtracted for you.
A player shot a server pedpedWeaponHit(attacker, ped, hit): a request. The ped keeps its health until your script acts. pedDamage follows with the attacker (see below).
A server ped was hurt by anything: a shot, a vehicle, a fall, an explosion, another pedpedDamage(ped, attacker, weapon, damage, bone, cause): one client's statement, a request like pedWeaponHit. attacker is a player, a ped or a vehicle that client could see, and undefined for the world or anything it could not see.
A player was hurtplayerHurt(player, attacker, weapon, damage, bone, cause) from the player's own client: who it says did it. The game has applied the damage already, but who did it is the client's word.
A player lost health or armour, from any cause (a shot, a fall, a vehicle, an explosion, your own health change)playerDamage(player, healthLoss, armorLoss), once per loss. It comes from the player's reported state: it has the amounts, playerHurt has the source.
A player's health reached 0playerDeath(player, reason, killer), once until the health is above 0 again. reason is the weapon of the last hit on the player and killer the player who made it (the driver, for a vehicle), when such a hit was reported in the last 5 seconds (playerWeaponHit or playerHurt); otherwise 0 and undefined.
A vehicle lost health or was destroyedvehicleDamage and vehicleDeath, from the driver's reported state.

cause is 1 for a shot, 2 for a vehicle and 0 for everything else; for a fall, an explosion or fire the weapon hash names the source. Melee blows are not told apart from other damage yet (cause is never 5 today), and explosions and falls are not told apart from each other by cause.

Who reports a hit, and how repeats are handled:

Server peds can be damaged by default, as mp.peds in RAGE MP: make one invincible when you create it, or later with setInvincible. The game reports every hit on a server ped (pedDamage, pedWeaponHit) and does not apply the damage itself: your script decides what the hit does - apply it, ignore it, or kill the ped. A server ped has no health property; keep the ped's health in your own data (for example a Map keyed by ped.id), subtract the damage in your handler and call ped.destroy() when it reaches 0. Players are the other way round: the game applies the damage to them as it normally does, and playerHurt only tells you who did it.

Applying damage from a script:

const health = new Map(); // ped.id -> health, your own bookkeeping
    
    mp.events.add('pedWeaponHit', (attacker, ped, hit) => {
      const left = (health.get(ped.id) ?? 100) - hit.damage;
      health.set(ped.id, left);
      if (left <= 0) ped.destroy();
    });
    
    mp.events.add('playerWeaponHit', (attacker, target, hit) => {
      // validate first: range, weapon, rate of fire, team rules ...
      target.health -= hit.damage; // setting health sends it to the player; at 0 playerDeath follows
    });
    
    // A car, a fall or an explosion hurt a ped: a statement of one client, so validate it first
    mp.events.add('pedDamage', (ped, attacker, weapon, damage) => {
      const sane = damage > 0 && damage <= 100;
      // an attacker must be near the ped; the world (undefined) is limited to one hit a second per ped
      const near = !attacker || !attacker.position || distance(attacker.position, ped.position) < 100;
      if (!sane || !near || tooFast(ped)) return;
      const left = (health.get(ped.id) ?? 100) - damage;
      health.set(ped.id, left);
      if (left <= 0) ped.destroy();
    });
    // distance() and tooFast() are yours: a vector length and a per-ped rate check

For a player, set player.health and player.armour on the server. The new value goes to the player's client, and playerDamage and playerDeath follow from the reported state.

Events sent by clients and by your scripts

Any other event name is yours:

Names that start with sixl: are used by the platform; do not use them.

Client events

Raised on the player's computer; the handler runs in a client script.

EventWhen it firesArguments, in order
playerReadyThe local player is ready: the server welcomed the client and the load-in scene has finished. Once per session. Scripts are already loaded, so handlers added at load time are in place. A teleport is safe here.none
playerJoinA player became known to this client: the first time they come into range, once until they quit. Not raised for the local player.player
playerQuitA player the client had in range left the server. Raised before entityStreamOut.player
playerSpawnThe local player is alive again after a death. Not raised for the first spawn of the session.player: the local player
playerDeathThe local player died (once per death).player: the local player; reason: the weapon of the last hit on the player in the 5 seconds before (see incomingDamage), else 0; killer: the player who made that hit, else undefined (a hit by a ped, a vehicle or the world names no killer)
playerEnterVehicleThe local player sat in a vehicle of the server (again after playerLeaveVehicle when moving to another seat).vehicle; seat (number, 0 = driver)
playerLeaveVehicleThe local player left a seat of a vehicle of the server (also when moving to another seat).vehicle; seat (number)
entityStreamInAn entity came into the client's range: a player, ped, vehicle, object, blip, marker, label or checkpoint.entity
entityStreamOutAn entity is leaving the range; it is still readable in the handler.entity
playerWeaponShotThe local player fired a weapon (one event per shot).targetPosition ({ x, y, z } in metres); targetEntity: always undefined
outgoingDamageThe local player's shot hit a player or ped of the server and the hit went to the server. Returning true does not cancel it.sourceEntity; targetEntity; targetPlayer (undefined for a ped); weapon (number); boneIndex (number: a hash of the bone's name, 0 if unknown); damage (number)
incomingDamageThe local player was hurt: by a shot, a vehicle, a fall, an explosion or anything else. The damage has already landed in the game: returning true does not cancel it.sourceEntity (the player, ped or vehicle that did it; undefined for the world or an entity this client does not hold); sourcePlayer (undefined unless a player did it); targetEntity (the local player); weapon (number; for a fall, an explosion or fire it names that source); boneIndex (number: a hash of the bone's name, 0 if unknown); damage (number)
renderEvery frame of the game. Keep the work small.none
playerEnterColshapeThe local player came into a colshape this client made (mp.colshapes), in its dimension. Checked every frame; once per crossing.shape
playerExitColshapeThe local player left a colshape this client made. A destroyed colshape raises none.shape
playerEnterCheckpointThe local player came within a checkpoint's radius (the server's checkpoints and the client's own), in its dimension. Checked every frame.checkpoint
playerExitCheckpointThe local player left a checkpoint's radius. A destroyed checkpoint raises none.checkpoint
playerCreateWaypointThe player set a waypoint on the map. Up to a second late: the game is asked once a second.position (Vector3)
playerReachWaypointThe waypoint went away with the player within 50 m of it.player: the local player
dummyEntityCreatedA dummy entity of the server's scripts is known to this client (made by the server, or there when the client joined; again after the client's scripts restart). Its variables are readable in the handler.dummyType (number); dummy
dummyEntityDestroyedA dummy entity of the server's scripts was destroyed, or the client left the server.dummyType (number); dummy
browserCreatedA browser was created with mp.browsers.new.browser
browserDomReadyA browser's page finished loading its document.browser
browserLoadingFailedA browser's page failed to load.browser; url (text); reason (text)
uncaughtExceptionA script threw an error that nothing caught. The error is logged and the runtime keeps running.error
unhandledRejectionA promise was rejected and nothing handled it. The reason is logged and the runtime keeps running.promise; error (the rejection reason)

Differences from RAGE MP