Skip to content

tw.gameEvents

Side: Client

Listen to native RedM game events such as deaths, shots, interactions, and more.

Functions

tw.gameEvents.listen(event_name, callback)

Registers a listener for a specific game event (or all events).

ParameterTypeDescription
event_namestringName of the game event to listen for (e.g. "EVENT_BUCKED_OFF") or "all" to receive every event
callbackfunctionCalled with a data table containing event_name plus named fields from the event definition

The data table passed to the callback always contains:

  • event_name — the name of the triggered event
  • Additional named fields depending on the specific event
lua
tw.gameEvents.listen("EVENT_ENTITY_DAMAGED", function(data)
    print("Event:", data.event_name)
    -- data contains event-specific fields
end)

Examples

Listen to a specific event

lua
tw.gameEvents.listen("EVENT_BUCKED_OFF", function(data)
    print("Player was bucked off a horse!")
end)

Listen to entity damage

lua
tw.gameEvents.listen("EVENT_ENTITY_DAMAGED", function(data)
    print("Entity damaged:", data.event_name)
end)

Listen to all game events (debug)

lua
tw.gameEvents.listen("all", function(data)
    print("Game event fired:", data.event_name)
end)

Notes

  • Use "all" as the event name to receive every game event. This is useful for debugging but should not be used in production due to the high volume of events.
  • The data table fields vary depending on the event type. Each event has its own set of named fields based on the native event definition.
  • Common events include: EVENT_ENTITY_DAMAGED, EVENT_ENTITY_DESTROYED, EVENT_BUCKED_OFF, EVENT_SHOT_FIRED, and many others.

Premium RedM Scripts — Multi-Framework