ox_doorlock
Overextended's door locks, with characters and groups read from cobalt_core.
| Export | Side | What it does |
|---|---|---|
useClosestDoor | Client | Toggles the closest door in range, as pressing E does. |
getClosestDoor | Client | The closest door in range, or nil. |
getClosestDoorId | Client | The id of the closest door in range, or nil. |
getDoorIdFromEntity | Client | The door id of a door entity, or nil when the entity is not a door. |
pickClosestDoor | Client | Picks the lock of the closest door in range with the lockpick animation. |
getDoor | Server | A door by id, or false when there is none. |
getAllDoors | Server | Every door. |
getDoorFromName | Server | The first door with this name, or nil. |
editDoor | Server | Changes a door's fields, saves it and sends it to every client. |
createDoor | Server | Saves a new door and returns its id. |
removeDoor | Server | Deletes a door; errors when there is none with this id. |
setDoorState | Server | Locks (1 or true) or unlocks (0 or false) a door. |
registerHook | Server | Runs callback on an event and returns the hook id. |
removeResourceHook | Server | Removes one of the calling resource's hooks, or all of them when id is nil. |
useClosestDoor
ClientToggles the closest door in range, as pressing E does.
exports.ox_doorlock:useClosestDoor()exports.ox_doorlock:useClosestDoor()getClosestDoor
ClientThe closest door in range, or nil.
exports.ox_doorlock:getClosestDoor()| Returns | Description |
|---|---|
OxDoorlockClientDoor? |
local doorlockClientDoor = exports.ox_doorlock:getClosestDoor()getClosestDoorId
ClientThe id of the closest door in range, or nil.
exports.ox_doorlock:getClosestDoorId()| Returns | Description |
|---|---|
integer? |
local value = exports.ox_doorlock:getClosestDoorId()getDoorIdFromEntity
ClientThe door id of a door entity, or nil when the entity is not a door.
exports.ox_doorlock:getDoorIdFromEntity(entityId)| Parameter | Type | Optional | Description |
|---|---|---|---|
entityId | integer | No |
| Returns | Description |
|---|---|
integer? |
local value = exports.ox_doorlock:getDoorIdFromEntity(door)pickClosestDoor
ClientPicks the lock of the closest door in range with the lockpick animation.
exports.ox_doorlock:pickClosestDoor()exports.ox_doorlock:pickClosestDoor()getDoor
ServerA door by id, or false when there is none.
exports.ox_doorlock:getDoor(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | integer | No |
| Returns | Description |
|---|---|
OxDoorlockDoor | false |
local doorlockDoor = exports.ox_doorlock:getDoor(1)getAllDoors
ServerEvery door.
exports.ox_doorlock:getAllDoors()| Returns | Description |
|---|---|
OxDoorlockDoor[] |
local doorlockDoors = exports.ox_doorlock:getAllDoors()getDoorFromName
ServerThe first door with this name, or nil.
exports.ox_doorlock:getDoorFromName(name)| Parameter | Type | Optional | Description |
|---|---|---|---|
name | string | No |
| Returns | Description |
|---|---|
OxDoorlockDoor? |
local doorlockDoor = exports.ox_doorlock:getDoorFromName('mrpd_front_doors')editDoor
ServerChanges a door's fields, saves it and sends it to every client. An empty string clears a field.
exports.ox_doorlock:editDoor(id, data)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | integer | No | |
data | table | No |
exports.ox_doorlock:editDoor(1, { state = 1, maxDistance = 2.0 })createDoor
ServerSaves a new door and returns its id. Needs coords, or doors for a double door.
exports.ox_doorlock:createDoor(data)| Parameter | Type | Optional | Description |
|---|---|---|---|
data | table | No |
| Returns | Description |
|---|---|
integer | id |
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
ServerDeletes a door; errors when there is none with this id.
exports.ox_doorlock:removeDoor(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | integer | No |
exports.ox_doorlock:removeDoor(1)setDoorState
ServerLocks (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)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | integer | No | |
state | 0 | 1 | boolean | No | |
lockpick | boolean | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.ox_doorlock:setDoorState(1, 1, true)registerHook
ServerRuns 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)| Parameter | Type | Optional | Description |
|---|---|---|---|
event | 'doorAuthorization' | No | |
callback | function | No | |
options | OxDoorlockHookOptions | Yes |
| Returns | Description |
|---|---|
integer | hookId |
local hookId = exports.ox_doorlock:registerHook(
'doorAuthorization',
function(payload) return true end,
{ nameFilter = '^mrpd' }
)removeResourceHook
ServerRemoves one of the calling resource's hooks, or all of them when id is nil.
exports.ox_doorlock:removeResourceHook(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | integer | Yes |
exports.ox_doorlock:removeResourceHook(1)