Marshalling RDR3 native struct/array out-params: DataView with 8-byte stride, little-endian, zero-based offsets
Context
Several RDR3 natives return data through a caller-supplied byte buffer instead of a return value (notification toast structs, GET_SCENARIO_POINTS_IN_AREA, the game-event queue, weapon-DLC structs). The undocumented part is how to pack/read that buffer.
The recipe (jo_libs convention)
local view = DataView.ArrayBuffer(8 * N) -- N = field/element count
view:SetInt32(8 * i, value) -- write field i
local got = nativeCall(..., view:Buffer()) -- pass the raw buffer
local x = view:GetInt32(8 * j) -- read field j
Key rules agents get wrong:
- Every field is 8-byte aligned — read/write at offset
8*ieven for Int32/BOOL fields. - Offsets are zero-based; endianness defaults to little (note: differs from the JS DataView API).
- For array natives, allocate a couple of slack slots (
8 * (max+2)) and skip zero entries. GET_EVENT_DATA'ssizearg is the RAGE element count (bytes/8), not a byte length.
Verified instances
- Notification toasts —
notification/client.lua:75-93. GET_SCENARIO_POINTS_IN_AREA(0x345EC3B7EBDE1CB5):DataView.ArrayBuffer(8*(max+2)), read ids atGetInt32(j*8-8)—entity/client.lua:277-289.- Game-event queue (
GET_EVENT_DATA0x57EC5FA4D4D6AFCA): fields at8*i—game-events/g_client.lua:33-55. - Weapon-DLC struct with
GetFixedString(56,64)—dataview/client.lua:44-58. This buffer recipe is undocumented in the corpus.
Linked natives
GET_EVENT_DATA(0x57EC5FA4D4D6AFCA)GET_SCENARIO_POINTS_IN_AREA(0x345EC3B7EBDE1CB5)
Tags: dataview, buffer, struct, out-param, marshalling, invokenative, rdr3
Category: natives
Source: jo_libs-fleet
Created: 2026-05-31T09:39:12.365Z