Authorization Hooks
Supported hook event:
doorAuthorization
Basic Example
local hookId = exports.nord_doorlock:RegisterHook(
'doorAuthorization',
function(payload)
if payload.door.name == 'VIP Entrance' then
return exports.my_vip:IsVip(payload.source)
end
end
)
Hook Payload
The callback receives:
{
source = 12,
door = {
-- copied door definition
},
lockpick = false,
authorised = true
}
source
Player server ID.
door
A copy of the current door definition.
lockpick
Boolean indicating the authorization context supplied by Nord Doorlock.
authorised
Return Values
Return:
true
Return:
false
to deny.
Return nothing / nil to leave the current result unchanged.
Multiple hooks can run. A boolean returned by a later matching hook becomes the current result for subsequent hooks.
Name Filter
Hook options may contain a Lua pattern:
local hookId = exports.nord_doorlock:RegisterHook(
'doorAuthorization',
function(payload)
return exports.my_access:CanUseDoor(
payload.source,
payload.door.id
)
end,
{
nameFilter = '^Police'
}
)
Only matching door names are evaluated by that hook.
nameFilter is used with Lua's string.match, so treat it as a Lua pattern rather than a plain substring.
Remove One Hook
exports.nord_doorlock:RemoveHooks(hookId)
Remove All Hooks Owned by Your Resource
exports.nord_doorlock:RemoveHooks()
A resource can only remove hooks registered under its own invoking resource identity.
Recommended Resource Cleanup
local hookId
CreateThread(function()
hookId = exports.nord_doorlock:RegisterHook(
'doorAuthorization',
function(payload)
-- custom access
end
)
end)
AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then return end
if hookId then
exports.nord_doorlock:RemoveHooks(hookId)
end
end)