Events
Last updated on
Local, network and host-wide events of the inventory module, and its page channels.
The server also listens to opx:in:character:loaded, :unloaded and :deleted (private).
opx:on:inventory:changed
Client, local. The server pushed this player's bag. Raised after the mirror is updated.
AddEventHandler('opx:on:inventory:changed', function(change) end)- change:
table—{ inventory, changes = { { name, delta } } }
Server, host-wide: also raised when a container is written, for every server resource. See public server events.
AddEventHandler('opx:on:inventory:changed', function(playerId, info) end)- playerId?:
number - info:
table—{ kind, owner, container, citizenId }
opx:on:inventory:used
Client, local. A use went through.
AddEventHandler('opx:on:inventory:used', function(use) end)- use:
table—{ name, slot, label, close, status?, animation? }
Server, host-wide: also raised when an item is used, for every server resource.
AddEventHandler('opx:on:inventory:used', function(playerId, info) end)- playerId:
number - info:
table—{ citizenId, name, slot, consumed, metadata }
opx:on:inventory:armed
Client, local. A bag weapon was drawn or put away.
AddEventHandler('opx:on:inventory:armed', function(weapon) end)- weapon:
table?—{ name, serial, slot }, or nil when put away
opx:on:inventory:opened
Client, local. The screen opened.
AddEventHandler('opx:on:inventory:opened', function() end)opx:on:inventory:closed
Client, local. The screen closed.
AddEventHandler('opx:on:inventory:closed', function() end)opx:on:character:loaded
Client, local; raised by character, listened to here. Sends hello to reload the bag.
opx:on:character:unloaded
Client, local; raised by character, listened to here. Closes the screen and clears the mirror.
opx:on:inventory:items
Server, host-wide. What a player's bag gained and lost, by item name: (playerId, { citizenId, changes = { { name, delta, count } } }). Computed against the bag's tally of its last change, so a drag inside the bag raises nothing. See Public server events.
opx:net:inventory:catalog
Server → client. Items registered at runtime, four at a time: { { name, owner, definition } }. Sent to every client on a registration and to one client on its hello. The client validates each one with the same Catalog.Register and rewrites the page's catalogue; a part longer than 4 is refused whole.
opx:net:inventory:request
Client → server. One screen request. Rate limited (RATE_LIMIT).
TriggerServerEvent('opx:net:inventory:request', requestId, action, payload)- requestId:
number - action:
string—open,close,closeSecondary,move,split,sort,use,drop,give,takeDrop,openStash,openTrunk,openGlovebox,nearby - payload:
table
opx:net:inventory:hello
Client → server. Client is ready: send piles, bag and held weapon. At most once per 2 s.
TriggerServerEvent('opx:net:inventory:hello')opx:net:inventory:answer
Server → client. Answer to one request.
RegisterNetEvent('opx:net:inventory:answer', function(requestId, ok, code, data) end)- requestId:
number - ok:
boolean - code?:
string - data?:
any
opx:net:inventory:own
Server → client. The player's bag changed.
RegisterNetEvent('opx:net:inventory:own', function(bag) end)- bag:
table
opx:net:inventory:container
Server → client. A container the player is viewing changed.
RegisterNetEvent('opx:net:inventory:container', function(container) end)- container:
table
opx:net:inventory:secondary
Server → client. A second container was opened, or closed.
RegisterNetEvent('opx:net:inventory:secondary', function(container) end)- container:
table|false
opx:net:inventory:nearby
Server → client. Players in reach, nearest first, for "give to". Never a name: the server does not read or send one. The page shows To your left · 1.2 m with #12 beside it.
RegisterNetEvent('opx:net:inventory:nearby', function(players) end)- players:
{ id, distance, side? }[]- distance:
number— metres, one decimal - side?:
'ahead' | 'behind' | 'left' | 'right'— from the giver's facing; absent on a host that cannot read it
- distance:
opx:net:inventory:giveOffer
Server → client (the receiver). Somebody in reach is handing this player something and asks first. The client shows an Accept / Refuse menu card. No name and no server id.
RegisterNetEvent('opx:net:inventory:giveOffer', function(token, offer) end)- token:
integer— names the offer in the answer - offer:
table—{ item, count, side?, distance, expiresInMs }- item:
string— the item's label, or the amount as money for notes - side?:
'ahead' | 'behind' | 'left' | 'right'— where the giver stands, from the receiver's facing - distance:
number— metres, one decimal - expiresInMs:
integer—15000
- item:
opx:net:inventory:giveAnswer
Client → server. The receiver's answer. Counts against the request window (RATE_LIMIT). Only the receiver the offer was made to can answer it; an unknown, expired or replayed token moves nothing. A yes is checked again from scratch (both can act, reach, same stack, room).
TriggerServerEvent('opx:net:inventory:giveAnswer', token, accepted)- token:
integer - accepted:
boolean— anything buttrueis a refusal
opx:net:inventory:giveWithdrawn
Server → client (the receiver). The offer was withdrawn: it expired after 15 s, or the giver left. The card is taken down.
RegisterNetEvent('opx:net:inventory:giveWithdrawn', function(token) end)- token:
integer
opx:net:inventory:open
Server → client. Raise the screen (after OpenStash or a staff search).
RegisterNetEvent('opx:net:inventory:open', function() end)opx:net:inventory:reset
Server → client. Close the screen and clear the mirror.
RegisterNetEvent('opx:net:inventory:reset', function() end)opx:net:inventory:used
Server → client. A use went through: play it.
RegisterNetEvent('opx:net:inventory:used', function(use) end)- use:
table—{ name, slot, label, close, status?, animation? }
opx:net:inventory:armed
Server → client. Held weapon changed.
RegisterNetEvent('opx:net:inventory:armed', function(weapon) end)- weapon:
table|false—{ name, serial, slot }
opx:net:inventory:drops
Server → client. Every pile, in parts.
RegisterNetEvent('opx:net:inventory:drops', function(part) end)- part:
table—{ first, done, drops = { { id, x, y, z, bucket } }, bucket? }bucket: on the first part only, the player's routing bucket. The client draws only that bucket's piles.
opx:net:inventory:bucket
Server → client. The player's routing bucket, sent when the host reports a bucket change. The client has no read of its own bucket, so the server reads it from its own position and says it.
RegisterNetEvent('opx:net:inventory:bucket', function(bucket) end)- bucket:
integer
opx:net:inventory:drop
Server → all clients. A pile appeared or went.
RegisterNetEvent('opx:net:inventory:drop', function(op, value) end)- op:
string—'add'or'remove' - value:
table|number— the pile onadd, its id onremove