For the complete documentation index, see llms.txt. This page is also available as Markdown.

Developer API

Every upstream ox_inventory export still works. See the official docs. These are the ones added by the rework.

Server

-- Create a clothing item for a player
local ok, response = exports.ox_inventory:CreateClothingItem(playerId, 'torso', 15, 0, { label = 'Leather jacket' })
-- returns false, 'clothing_disabled' when Config.Clothing.Enabled = false

-- Move the whole player inventory into a drop at their feet
local dropId = exports.ox_inventory:CreateDropFromPlayer(playerId)

-- Get the ground inventory near the player, or create one
local inv = exports.ox_inventory:GetOrCreateGroundInventory(source, GetPlayerPed(source), coords?)

-- The equipped backpack, or the box being carried
local backpack = exports.ox_inventory:GetEquippedBackpack(source)

-- Clear items but keep worn clothing and the backpack
exports.ox_inventory:ClearInventoryItems(inv)

Client

exports.ox_inventory:placeItem(itemName, slot)
exports.ox_inventory:throwItem(itemName, slot)

-- Placement tool for your own scripts
exports.ox_inventory:startFreePlacement(itemName, slot, modelOverride, {
    requireFlat = true,
    onConfirm = function(coords, rotation) end,
    onCancel = function() end,
})

exports.ox_inventory:suppressItemNotifications(true) -- hide the add/remove popups
local injuries = exports.ox_inventory:getInjuries()
exports.ox_inventory:clearInjuries()                -- e.g. from your ambulance job

Hooks

The 7 upstream hooks are unchanged (openInventory, usingItem, swapItems, craftItem, createItem, openShop, buyItem). swapItems adds two cases:

  • action = 'give' when an item is handed to another player;

  • toInventory = 'newdrop' (with dropId) when an item is dropped on the ground.

State bags

Key
Content

Player(id).state.injuries

Current injuries

Player(id).state.instance

Routing bucket used to show and hide drops


9. Discord logs

Every inventory log is also sent to Discord. It is set in Config.Logs:

  • A URL sends that event to that channel.

  • '' sends it to the fallback Webhook. If that is empty too, the event is not logged.

  • false turns the event off.

  • set inventory:loglevel 0 turns all logs off, Discord included. 2 also logs every add/remove and every purchase.

  • A failed Discord request never breaks the action it was logging.


Last updated