Skip to main content

Usable Items & Hooks

RegisterUsableItem

Use a trusted server resource to attach behavior to an item:

exports.nord_inventory:RegisterUsableItem('repairkit', function(source, item, definition)
    -- validate your own resource state here
    -- return false to block the use
    return true
end)

The handler receives:

  • player source;
  • a copy of the item instance;
  • a copy of the item definition.

Returning false blocks completion of the use.

Hooks

Register a hook:

exports.nord_inventory:RegisterHook('beforeMoveItem', function(payload)
    if payload.to.type == 'evidence' and not IsAllowed(payload.source) then
        return false
    end
end)

Lowercase alias:

exports.nord_inventory:registerHook(...)

Hook names used by the core

beforeMoveItem

Payload includes:

{
    source = source,
    from = fromInventory,
    to = toInventory,
    item = item,
    amount = amount,
    fromSlot = fromSlot,
    toSlot = toSlot,
    txid = transactionId
}

Returning false blocks the move.

afterMoveItem

Receives the same move payload after a successful move.

beforeUseItem

{
    source = source,
    inventory = inventory,
    item = item,
    definition = definition
}

Returning false blocks use.

afterUseItem

Receives the use payload after successful item handling.