Skip to content

Events ​

Subscribe with samp.events.on(name, callback, options). The returned subscription has unsubscribe().

For the exact fields, types, permissions, and mutability of every event, use the Event payload reference.

lua
local subscription = samp.events.on("player.spawned", function(event)
    samp.log.info(event.name)
end, {
    priority = 100,
    once = true
})

-- subscription:unsubscribe()

Higher priority runs first. Use once = true for a one-shot subscription.

Event envelope ​

Events include a stable envelope where applicable:

FieldMeaning
nameEvent name.
sequenceMonotonic dispatch sequence.
timestampMonotonic event time in milliseconds.
sessionIdCurrent game runtime session.
playerGenerationCurrent local-player generation.

Main event groups ​

  • Lifecycle: plugin.loaded, session.started, session.ended, game.ready, server.connected, server.disconnected.
  • Local player: player.spawned, player.died, player.health_changed, vehicle and interior changes.
  • Chat: received player messages, server messages, chat bubbles, and outgoing interception.
  • World: checkpoints and streamed entity lifecycle.
  • Interaction: dialogs, TextDraws, and plugin-menu controls.
  • Frames: game.frame and draw.hud.

Mutable events ​

Some events expose writable fields. Cancellation is sticky: after one plugin sets cancelled = true, a later plugin cannot restore the operation.

lua
samp.events.on("chat.message_received", function(event)
    samp.log.info(
        event.playerName .. ": " .. event.message
    )
end, {
    priority = 0
})

samp.events.on("chat.message_sending", function(event)
    if event.message == "!cancel" then
        event.cancelled = true
    end
end)

Mutable callbacks cannot yield. Keep them especially short because they delay the original interaction.