Authorization Hooks

Authorization hooks allow another server resource to extend or override door access without modifying Nord Doorlock.

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

Authorization result calculated before this hook.

Return Values

Return:

true

to authorize.

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.

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)

Revision #1
Created 2026-09-08 13:05:56 UTC by Riguita
Updated 2026-09-08 13:05:56 UTC by Riguita