Events
Last updated on
Network and local events of the doorlock module.
The server re-checks every client payload: a client names a door id and the state it wants, nothing more. Staff events are gated on their own command.opx.doorlock.* entry and floored per player; a refusal answers not_permitted or too_fast on staffDone.
Player
opx:net:doorlock:ask
Client → server. Asks for the doors of the player's bucket. At most one per second is answered.
TriggerServerEvent('opx:net:doorlock:ask')opx:net:doorlock:setState
Client → server. ox's setState: turn a door. Without state it flips. For a coded door the first request answers passcode_required and the client sends it again with code.
TriggerServerEvent('opx:net:doorlock:setState', { id = 12, state = 0, code = '1234' })- id:
integer - state?:
0 | 1 - code?:
string
opx:net:doorlock:pick
Client → server. Starts a lockpick.
TriggerServerEvent('opx:net:doorlock:pick', { id = 12 })opx:net:doorlock:pickGo
Server → client. The pick may start: run one progress bar per step. The server's clock starts now.
RegisterNetEvent('opx:net:doorlock:pickGo', function(payload) end)- payload:
{ id, name, steps }—steps:number[], each bar's milliseconds
opx:net:doorlock:picked
Client → server. The bars ran. A finished that arrives before the steps could have run is refused and audited (doorlock.pickEarly); the server makes every roll.
TriggerServerEvent('opx:net:doorlock:picked', { id = 12, finished = true })opx:net:doorlock:answer
Server → client. The verdict on a request.
RegisterNetEvent('opx:net:doorlock:answer', function(payload) end)- payload:
{ ok, code, id?, name?, state?, how?, broke? }code: a success (locked,unlocked,picked,already_locked,already_unlocked) or a refusal
opx:net:doorlock:sync
Server → client. The doors of the player's bucket, in chunks of 12. Sent on join, on a bucket change, after every staff write.
RegisterNetEvent('opx:net:doorlock:sync', function(payload) end)- payload:
{ bucket, mode, offset, done, doors, staff? }doors:{ { id, name, ids, x, y, z, state, reach, hideUi?, holdOpen?, lockpick?, passcode?, lockSound?, unlockSound? } }—passcodeis onlytruewhen the door has onestaff: the player's staff flags, nil for a player
opx:net:doorlock:state
Server → client, to everyone in the door's bucket. A door changed state.
RegisterNetEvent('opx:net:doorlock:state', function(payload) end)- payload:
{ id, state }— noby: who turned a door is not sent to the bucket (the journal keeps it for staff)
Staff
opx:net:doorlock:staffOpen
Server → client. /opx.doorlock ran: open the panel.
RegisterNetEvent('opx:net:doorlock:staffOpen', function(payload) end)- payload:
{ access, mode, closest }—access:{ save, remove, lock, key, bypass, teleport }
opx:net:doorlock:staffAsk
Client → server. The list, or one door's detail. Gated on command.opx.doorlock.
TriggerServerEvent('opx:net:doorlock:staffAsk', { id = 12 }) -- {} for the listopx:net:doorlock:staffList
Server → client. The list in chunks of 20, or one door.
RegisterNetEvent('opx:net:doorlock:staffList', function(payload) end)- list:
{ rows, offset, total, done, mode }— each row{ id, name, state, bucket, x, y, z, double?, seeded? } - detail:
{ detail, id }— the door in ox's shape plusliveandseeded;detail = falsewhen unknown. The code is in it only for staff withcommand.opx.doorlock.save; others gethasPasscode.
opx:net:doorlock:staffSave
Client → server. Create (no id) or edit. Gated on command.opx.doorlock.save. A save naming no passcode keeps the door's code; '' clears it.
TriggerServerEvent('opx:net:doorlock:staffSave', { id = 12, door = { name = 'Back room', state = 1 } })opx:net:doorlock:staffRemove
Client → server. Deletes a door. Gated on command.opx.doorlock.remove.
TriggerServerEvent('opx:net:doorlock:staffRemove', { id = 12 })opx:net:doorlock:staffState
Client → server. Lock or unlock from anywhere; flips without state. Gated on command.opx.doorlock.lock.
TriggerServerEvent('opx:net:doorlock:staffState', { id = 12, state = 1 })opx:net:doorlock:staffKey
Client → server. Cuts a key for the caller. Gated on command.opx.doorlock.key.
TriggerServerEvent('opx:net:doorlock:staffKey', { id = 12 })opx:net:doorlock:staffDone
Server → client. The result of a staff write.
RegisterNetEvent('opx:net:doorlock:staffDone', function(payload) end)- payload:
{ verb, ok, code, id?, name?, created?, detail? }verb:'save' | 'remove' | 'state' | 'key'detail: what a save refusal names (the unknown group, the door holding a leaf)
opx:on:doorlock:changed
Server, local. ox's stateChanged: a door turned, by anyone. Published with OPX.Publish, so other server resources can listen too.
AddEventHandler('opx:on:doorlock:changed', function(source, data) end)- source:
number?— the player, nil for autolock, the console or an export - data:
{ id, door, name, state, locked, by, item? }door: same asidby:string— a player id,'autolock','staff:<id>','lockpick:<id>','ext:<resource>'or the contract'sbyitem:string?— the item that opened it
AddEventHandler('opx:on:doorlock:changed', function(source, data)
if data.name == 'Vault' and not data.locked then print('vault opened by ' .. data.by) end
end)