Origen Network Store
  • 👋Welcome to Origen Network Store
  • 🆘¿You need help?
  • ❓FAQS
  • 👮Origen Police
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
      • Pma-Voice
    • 📙Guide of Use
      • 💻Police CAD
        • Dispatch
        • Citizen Search
        • Reports
        • Vehicles
        • Criminal Code
        • Search and Capture
        • Debtors
        • Federal Management
        • Agent Management
        • Security Cameras
        • Radio
        • Time Control
        • Operations
      • 📄Interaction Menu
      • 📹Vehicle Radar
      • 🚔Sirens System
      • 🔦Evidence System
      • 🎛️Mini Dispatch
      • 🚁Helicopter Camera
      • 🪪Badges
      • ⛓️Federal System
      • 🔫Holster
      • 🐕K9 Dog
    • ❓Frequent Questions
    • ⚙️Configuration
      • Framework
      • Armoury
      • Commands
      • Confiscate
      • Evidences
      • Federal
      • Holster
      • K9
      • Licenses
      • Markers
      • Names
      • Outfits
      • Permissions
      • Props
      • Radio
      • Vehicles
    • #️⃣Exports
      • Client Exports
      • Server Exports
  • 📻Origen Radio
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
      • Pma-Voice
    • ⚙️Configuration
  • 🛠️Origen Admin
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
  • 🏎️Origen Races
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
    • #️⃣Exports
      • Client Exports
  • 🔫Origen Ilegal
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
      • qb-inventory
    • 💬Commands
    • ♻️Exports
  • 🏚️Origen Housing
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
    • ⚙️API
      • Exports
      • Hooks
      • Events
      • Scripts Support
        • 📱LB-Phone
  • 🚙Origen Parking
    • ⚠️Dependencies
    • 🔧Installation
      • QBCore SQL
      • ESX SQL
    • ⚙️Configuration
    • ♻️Exports
  • 💼origen_inventory
    • ⚠️Dependencies
    • 🔧Installation
      • SQL
    • ⛏️Scripts Support
      • 📱LB Phone
        • 2️From v2.1.14
      • 🏨QB Apartments
      • 🔫QB-Weapons
      • 🔨Jobs creator (Jaksam)
    • ♻️Exports
      • 🛥️Client Exports
      • ⚓Server
        • Hooks
    • How to
  • 🕵️‍♂️origen_hostage
    • 🔧Installation
  • 👷‍♂️Origen Masterjob
    • 🔧Installation
      • SQL
      • qb-inventory
      • qs-inventory
      • ox_inventory
    • ♻️Exports
  • QBCORE
    • 🍔origen_hud
      • ❔¿What is origen_hud?
      • 🔧Installations origen_hud
      • ❓FAQS origen_hud
    • 💬origen_notify
      • ❔¿What is origen_notify?
      • 🔧Installations origen_notify
      • ❓FAQS origen_notify
        • 🥬Snippets origen_notify
    • ⏸️origen_pausemenu
      • ❔¿What is origen_pausemenu?
      • 🔧Installations origen_pausemenu
      • ❓FAQS origen_pausemenu
      • 🔑EXPORTS origen_pausemenu
    • 🥷origen_blackmarket
      • ❔¿What is origen_blackmarket?
      • 🔧Installations origen_blackmarket
      • ❓FAQS origen_blackmarket
      • 🥬Snippets origen_blackmarket
    • 🧑‍🤝‍🧑origen_titlemenu
      • ❔¿What is origen_titlemenu?
      • 🔧Installations origen_titlemenu
      • ❓FAQS origen_titlemenu
      • 🥬Snippets origen_titles (soon)
    • 🚗origen_importheist
      • ❔¿What is origen_importheist?
      • 🔧Installations origen_importheist
      • ❓FAQS origen_importheist
      • 🥬Snippets origen_importheist (soon)
  • ESX
    • 🍔origen_hud
      • ❔¿What is origen_hud?
      • 🔧Installations origen_hud
      • ❓FAQS origen_hud
    • 💬origen_notify
      • ❔¿What is origen_notify?
      • 🔧Installations origen_notify
      • ❓FAQS origen_notify
      • 🥬Snippets origen_notify
    • ⏸️origen_pausemenu
      • ❔¿What is origen_pausemenu?
      • 🔧Installations origen_pausemenu
      • ❓FAQS origen_pausemenu
      • 🔑EXPORTS origen_pausemenu
    • 🧑‍🤝‍🧑origen_titlemenu
      • ❔¿What is origen_titlemenu?
      • 🔧Installations origen_titlemenu
      • ❓FAQS origen_titlemenu
      • 🥬Snippets origen_titles (soon)
    • 🚗origen_importheist
      • ❔¿What is origen_importheist?
      • 🔧Installations origen_importheist
      • ❓FAQS origen_importheist
      • 🥬Snippets origen_importheist (soon)
Powered by GitBook
On this page
  • registerHook
  • Hook: swapItems
  • Hook: openInventory
  • Hook: giveItem
  • Hook: buyItem
  • Hook: createDrop
  • removeHooks
  1. origen_inventory
  2. Exports
  3. Server

Hooks

Event hooks allow external resources to set new behavior without directly altering the inventory code.

Hooks has been done to make the system backward compatible with other resources on the market.

registerHook

exports.origen_inventory:registerHook(eventName, function(payload) end, options)
Argument
Type
Options

eventName

string

specific event

payload

table

specific response

options?

table

options.print?

boolean

Print to the console when triggering the event.

options.itemFilter?

{ [string]: true }

The event will only trigger for items defined as keys in a set.

options.inventoryFilter?

string[]

options.typeFilter?

[string]: true }

The event will only trigger for inventories with one of the provided types (e.g. 'player', 'stash')

Argument mark with ' ? ' is optional.

Return:

  • hookId: number

Hook: swapItems

  • Payload: table

    • source: number

    • action: 'move' or 'stack' or 'swap' or 'give'

    • fromInventory: table or string or number

    • toInventory: table or string or number

    • fromType: string

    • toType: string

    • fromSlot: table

    • toSlot?: table or number

    • count: number

    Triggered when moving any item from one slot to another, or when "giving" an item. By returning false, you can cancel the action and revert the inventory state.

local hookId = exports.origen_inventory:registerHook('swapItems', function(payload)
    print(json.encode(payload, { indent = true }))
    return false
end, {
    print = true,
    itemFilter = {
        tosti = true,
    },
    inventoryFilter = {
        '^glovebox[%w]+',
    }
})

Hook: openInventory

  • Payload: table

    • source: number

    • inventoryId: number or string

    • inventoryType: string

    Triggered when a player tries to open a secondary inventory. By returning false, you can cancel the action and keep the player's inventory closed.

Example

Disables gloveboxes and trunks.

local hookId = exports.origen_inventory:registerHook('openInventory', function(payload)
     print(json.encode(payload, { indent = true }))
     return false
end, {
      print = true,   
      inventoryFilter = {       
      '^glovebox[%w]+',       
      '^trunk[%w]+',   
    }
})

Hook: giveItem

Payload: table

  • source: number

  • fromInventory: table or string or number

  • toInventory: table or string or number

  • fromType: string

  • toType: string

  • fromSlot: table

  • toSlot?: table or number

  • count: number

Triggered when a player tries to give item to other player. By returning false, you can cancel the action and keep the player's inventory closed.

local hookId = exports.origen_inventory:registerHook('giveItem', function(payload)
     print(json.encode(payload, { indent = true }))
     return false
end, {
 print = true,
})

Hook: buyItem

  • Payload: table

    • source: number

    • shopType: string

    • shopId: number

    • toInventory: number

    • toSlot: number

    • itemName: string

    • metadata: table

    • count: number

    • price: number

    • totalPrice: number

    • currency?: string

    Triggered when an item is about to be purchased and can return false to prevent the transaction.

local hookId = exports.origen_inventory:registerHook('buyItem', function(payload)
    print(json.encode(payload, { indent = true, sort_keys = true }))
    return false
end, {
    print = true,
    itemFilter = {
        water = true
    },
})

Hook: createDrop

Payload: table

  • source: number

  • action: 'move'

  • fromInventory: 'player'

  • toInventory: 'drop'

  • fromType: string

  • toType: 'drop'

  • fromSlot: table

  • toSlot: table

  • count: number

Triggered when an item is about to be dropped and can return false to prevent the action.

local hookId = exports.origen_inventory:registerHook('createDrop', function(payload)
    print(json.encode(payload, { indent = true, sort_keys = true }))
    return false
end, {
    print = true,
})

removeHooks

Removes a hook created by the invoking resource with the specified ID. If no ID is specified, then all hooks registered by the resource are removed.

exports.origen_inventory:removeHooks(id)
  • id?: number

Soon

craftItem, createItem ⌛

PreviousServerNextHow to

Last updated 1 month ago

The event will only trigger for inventories that match one of the in the array.

💼
♻️
⚓
patterns(opens in a new tab)