Docs/API

Hooks

Every rtv-mp scenario hook, its arguments and when it fires: player_join, player_spawn, player_death, player_leave, area_loaded, npc_killed and event hooks.

API version 1Lua 5.1Updated 2026-11-07

player_join#

Arguments: player

The first time a connection reaches the world (finished loading). Fires once per connection, before that player's first player_spawn.

player_spawn#

Arguments: player, reason

Every time a player enters the world alive. reason is "join" (first entry this connection), "respawn" (first entry after a death) or "travel" (after changing area).

player_spawn_point#

Arguments: player, reason

Runs when a new character joins or a dead one respawns (a dead character that reconnects counts as a respawn), before the player is placed. It runs on the simulation goroutine and cannot wait or yield. A returning player who is alive resumes where they logged out and does not trigger it.

  • reason is "new_character" or "respawn".
  • Return the name of an enabled public map to load the player straight into it instead of their hideout. The position is an optional second value.
  • With no position, the map's arrival.travel spawn groups choose the point. A position that is blocked moves to the nearest free spot.
  • Returning nothing, or a hideout or disabled map, keeps the normal spawn.
  • The player is not in the world yet, so only id, name and identity are readable.
-- Everyone loads straight into Apartments; the map's arrival rules pick the point.
on("player_spawn_point", function(player, reason)
  return "Apartments"
end)

-- Or choose the exact spot.
on("player_spawn_point", function(player, reason)
  return "Apartments", { x = 12, y = 4, z = -30 }
end)

player_loadout#

Arguments: player, reason, hideout

Synchronously selects a configured loadout while a new life is built. Return a loadout name from players.json; unknown names are ignored. This hook cannot wait or yield.

It runs on the simulation goroutine during life inventory creation. Its reason is new_character or respawn; hideout is the hideout name for respawns and an empty string otherwise. The selected name is used for both inventory receipts and the character layout.

player_death#

Arguments: player, info

Fires when the character dies. player.area and player.position still describe where. Deaths already saved when the player connects are not reported. The second argument, info, is a table:

FieldTypeDescription
causestring"bullet", "explosion", "npc", "environment" or "other".
killerplayer or NPC handleWho dealt the killing blow. Absent for the environment.
weaponstringThe weapon's item name. Bullet kills only.
weapon_itemstringThe weapon's resource path. Bullet kills only.
distancenumberMetres from shooter to victim. Bullet kills only.
headshotbooleanWhether the killing shot hit the head. Bullet kills only.
hitboxstringThe body part the killing shot hit: head, torso, hips, or left_arm, right_arm, left_hand, right_hand, left_leg, right_leg, left_foot, right_foot. Bullet kills only.

player_leave#

Arguments: player

A player who had joined disconnected. The handle is offline: id, name and identity still work.

area_loaded#

Arguments: area

An area instance finished loading: a public map at startup, or a private hideout when its owner arrives.

area_unloaded#

Arguments: area

An area instance was unloaded (idle hideouts). The handle's loaded is false.

npc_killed#

Arguments: npc, killer

An NPC died, by any cause: players, other AI, explosions and npc:kill(). killer is the NPC's last attacker: a player handle, an NPC handle, or nil. To tell them apart, check for killer.identity, which only players have. Corpses already saved when an area loads are not reported.

event_started#

Arguments: area, name, scripted

An event started in an area. For native dynamic events, name is the /spawnevent key (airdrop, btr_patrol, ...), or the game's event name when it has no key, and scripted is false. For scenario events, scripted is true.

event_ended#

Arguments: area, name, reason, scripted

An event ended. For native events reason is "ended"; they are not reported when their area unloads, because the event is saved with the area. For scenario events, see how they end.

Found a mistake or missing detail? Tell us in the Discord.