Skip to Content
Cobalt

ox_doorlock

Overextended's door locks, with characters and groups read from cobalt_core.

ExportSideWhat it does
useClosestDoorClientToggles the closest door in range, as pressing E does.
getClosestDoorClientThe closest door in range, or nil.
getClosestDoorIdClientThe id of the closest door in range, or nil.
getDoorIdFromEntityClientThe door id of a door entity, or nil when the entity is not a door.
pickClosestDoorClientPicks the lock of the closest door in range with the lockpick animation.
getDoorServerA door by id, or false when there is none.
getAllDoorsServerEvery door.
getDoorFromNameServerThe first door with this name, or nil.
editDoorServerChanges a door's fields, saves it and sends it to every client.
createDoorServerSaves a new door and returns its id.
removeDoorServerDeletes a door; errors when there is none with this id.
setDoorStateServerLocks (1 or true) or unlocks (0 or false) a door.
registerHookServerRuns callback on an event and returns the hook id.
removeResourceHookServerRemoves one of the calling resource's hooks, or all of them when id is nil.

useClosestDoor

Client

Toggles the closest door in range, as pressing E does.

exports.ox_doorlock:useClosestDoor()
Example
exports.ox_doorlock:useClosestDoor()

getClosestDoor

Client

The closest door in range, or nil.

exports.ox_doorlock:getClosestDoor()
ReturnsDescription
OxDoorlockClientDoor?
Example
local doorlockClientDoor = exports.ox_doorlock:getClosestDoor()

getClosestDoorId

Client

The id of the closest door in range, or nil.

exports.ox_doorlock:getClosestDoorId()
ReturnsDescription
integer?
Example
local value = exports.ox_doorlock:getClosestDoorId()

getDoorIdFromEntity

Client

The door id of a door entity, or nil when the entity is not a door.

exports.ox_doorlock:getDoorIdFromEntity(entityId)
ParameterTypeOptionalDescription
entityIdintegerNo
ReturnsDescription
integer?
Example
local value = exports.ox_doorlock:getDoorIdFromEntity(door)

pickClosestDoor

Client

Picks the lock of the closest door in range with the lockpick animation.

exports.ox_doorlock:pickClosestDoor()
Example
exports.ox_doorlock:pickClosestDoor()

getDoor

Server

A door by id, or false when there is none.

exports.ox_doorlock:getDoor(id)
ParameterTypeOptionalDescription
idintegerNo
ReturnsDescription
OxDoorlockDoor | false
Example
local doorlockDoor = exports.ox_doorlock:getDoor(1)

getAllDoors

Server

Every door.

exports.ox_doorlock:getAllDoors()
ReturnsDescription
OxDoorlockDoor[]
Example
local doorlockDoors = exports.ox_doorlock:getAllDoors()

getDoorFromName

Server

The first door with this name, or nil.

exports.ox_doorlock:getDoorFromName(name)
ParameterTypeOptionalDescription
namestringNo
ReturnsDescription
OxDoorlockDoor?
Example
local doorlockDoor = exports.ox_doorlock:getDoorFromName('mrpd_front_doors')

editDoor

Server

Changes a door's fields, saves it and sends it to every client. An empty string clears a field.

exports.ox_doorlock:editDoor(id, data)
ParameterTypeOptionalDescription
idintegerNo
datatableNo
Example
exports.ox_doorlock:editDoor(1, { state = 1, maxDistance = 2.0 })

createDoor

Server

Saves a new door and returns its id. Needs coords, or doors for a double door.

exports.ox_doorlock:createDoor(data)
ParameterTypeOptionalDescription
datatableNo
ReturnsDescription
integerid
Example
local id = exports.ox_doorlock:createDoor(
    { name = 'mrpd_front_doors', model = `v_ilev_ph_door01`, coords = vector3(434.7, -980.6, 30.8), heading = 270, state = 1, groups = { police = 0 } }
)

removeDoor

Server

Deletes a door; errors when there is none with this id.

exports.ox_doorlock:removeDoor(id)
ParameterTypeOptionalDescription
idintegerNo
Example
exports.ox_doorlock:removeDoor(1)

setDoorState

Server

Locks (1 or true) or unlocks (0 or false) a door. Called from a server script it skips the access check.

exports.ox_doorlock:setDoorState(id, state, lockpick)
ParameterTypeOptionalDescription
idintegerNo
state0 | 1 | booleanNo
lockpickbooleanYes
ReturnsDescription
boolean
Example
local ok = exports.ox_doorlock:setDoorState(1, 1, true)

registerHook

Server

Runs callback on an event and returns the hook id. On doorAuthorization, returning true lets in a player the access check refused.

exports.ox_doorlock:registerHook(event, callback, options)
ParameterTypeOptionalDescription
event'doorAuthorization'No
callbackfunctionNo
optionsOxDoorlockHookOptionsYes
ReturnsDescription
integerhookId
Example
local hookId = exports.ox_doorlock:registerHook(
    'doorAuthorization',
    function(payload) return true end,
    { nameFilter = '^mrpd' }
)

removeResourceHook

Server

Removes one of the calling resource's hooks, or all of them when id is nil.

exports.ox_doorlock:removeResourceHook(id)
ParameterTypeOptionalDescription
idintegerYes
Example
exports.ox_doorlock:removeResourceHook(1)

On this page