Skip to content

Event callback parameters

Subscribe with samp.events.on. Every callback receives one event table.

Common envelope

Every event contains:

FieldTypeMeaning
namestringExact event name.
sequenceintegerMonotonic dispatch sequence within the runtime. All subscribers to one dispatch see the same value.
timestampintegerMonotonic event timestamp in milliseconds; not wall-clock time.
sessionIdintegerSession associated with the event.
playerGenerationintegerLocal-player generation associated with the event.

Payload tables are valid for the callback only. Copy primitive values if a task needs them later. Unless marked mutable, changing a field has no host effect.

Lifecycle, frame, and UI events

EventAdditional fieldsNotes
plugin.loadednoneDispatched after the entry file loads; subscribe during entry evaluation to receive it.
session.startednoneA new runtime session began.
session.endednoneCurrent session ended.
game.readynoneGame services became ready.
server.connectednoneMultiplayer connection completed.
server.disconnectednoneConnection ended.
player.spawnednoneAcquire new player/resources here.
player.diednonePrevious player-generation resources must be considered stale.
game.framedeltaSeconds: numberPer-frame managed callback. Keep work bounded.
draw.huddeltaSeconds, screenWidth, screenHeight: numberOnly phase in which samp.draw is available.
ui.menu_openednoneThis plugin's menu became visible; requires ui.menu.
ui.menu_closednoneThis plugin's menu was closed; requires ui.menu.
ui.control_changedpluginId, pageId, controlId: string; value: boolean/number/stringSwitch: boolean; slider: number; choice/text input: string; button: "click". Filter by page and control ID.

Local-player events

EventPermissionPayload
player.health_changedgame.player.readpreviousHealth: number, health: number.
player.vehicle_enteredgame.vehicle.readvehicleId: integer, passenger: boolean.
player.vehicle_leftgame.vehicle.readvehicleId: integer, passenger: boolean.
player.interior_changedgame.state.readpreviousInterior: integer, interior: integer.

player.damage_before

Requires game.player.write. Additional fields:

FieldTypeMutability
damagenumberWritable, finite 0..100000; set 0 to suppress damage.
weaponTypeintegerRead-only input.
bodyPartintegerRead-only input.
sourceType"player", "actor", or "entity"Read-only input.
sourcePlayerIdintegerPresent only for a known player source.
sourceActorIdintegerPresent only for a known actor source.

Handlers run by priority and each sees the accepted result of earlier handlers. Invalid replacements are ignored. The callback cannot yield.

Chat events

EventPermissionPayload
chat.message_receivedchat.readplayerId: integer, playerName: string, message: string, localPlayer: boolean.
chat.server_message_receivedchat.readmessage: string, color: integer (ARGB).
chat.bubble_receivedchat.readplayerId: integer, message: string, color: integer, drawDistance: number, durationMs: integer.

chat.message_sending

Requires chat.intercept. message: string and cancelled: boolean are writable. The replacement must be valid UTF-8, non-empty, at most 4,096 bytes, contain no NUL/CR/LF, and must not begin with /.

command.executing

Requires command.intercept. command: string and cancelled: boolean are writable. The replacement has the same 4,096-byte and line restrictions, must start with /, and must contain at least one character after it.

Cancellation is sticky for both events: once true, later handlers cannot set it back to false. Mutable interception callbacks cannot yield.

Checkpoint events

checkpoint.entered and checkpoint.left require game.state.read.

FieldTypeMeaning
kind"normal" or "race"Checkpoint kind.
positionVector3Checkpoint position.
sizeVector3Present for box-shaped checkpoints.
radiusnumberPresent for radius-shaped checkpoints.
raceTypeintegerPresent together with radius.

Server entity events

entity.streamed_in and entity.streamed_out require game.entity.read. Both contain:

FieldType
entityTypeplayer, vehicle, object, actor, pickup, or text_label
entityIdinteger
streamGenerationpositive integer

On streamed_in, pass all three fields to samp.entity.get. On streamed_out, an existing Handle for that identity is stale.

Dialog events

dialog.shown

Requires dialog.read.

FieldTypeMeaning
dialogIdinteger0..32767.
styleIdintegerNumeric style 0..5.
stylestringmessage, input, list, password, tablist, or tablist_headers.
titlestringDialog title.
messagestringDialog body/list data.
primaryButtonstringPrimary button label.
secondaryButtonstringSecondary button label; may be empty.

All strings are UTF-8. title and each button are at most 1,024 bytes; message is at most 16 KiB.

dialog.responding

Requires dialog.intercept. Fields accepted: boolean, listItem: integer (-1..65534), input: string (valid UTF-8, maximum 4,096 bytes, no NUL/CR/LF), and cancelled: boolean are writable. dialogId is read-only. Cancellation is sticky, invalid replacements are ignored, and the callback cannot yield.

TextDraw events

All TextDraw identities combine textdrawId (0..3071) and textdrawGeneration (positive integer).

EventPermissionAdditional payload
textdraw.showntextdraw.readidentity, styleId: integer, text: string, selectable: boolean, x: number, y: number.
textdraw.hiddentextdraw.readidentity.
textdraw.text_changedtextdraw.readidentity, text: string.
textdraw.clickingtextdraw.interceptidentity, writable cancelled: boolean.

Text may contain at most 4,096 bytes in an event. Click cancellation is sticky; the interception callback cannot yield.