Skip to main content

ox_inventory support for QBOX

T
Written by Tim Plate
Updated today

visn_are/script/configuration/server_config.lua

 m_qbCoreResourceName = ""

visn_are/script/helpers/s_functions.lua Line 14-214 (approximately)

add these under each function pertaining to items where it says "-- Implement your own logic (standalone)"

HasItem

if ServerConfig.m_customInventory and ServerConfig.m_customInventory.inventory_type == "ox_inventory" then
return exports.ox_inventory:Search(source, 'count', item) >= amount
end

AddItem - make sure this is inserted before "return true"

if ServerConfig.m_customInventory and ServerConfig.m_customInventory.inventory_type == "ox_inventory" then
if exports.ox_inventory:CanCarryItem(source, item, amount) then
exports.ox_inventory:AddItem(source, item, amount)
return true
end
return false
end

RemoveItem

if ServerConfig.m_customInventory and ServerConfig.m_customInventory.inventory_type == "ox_inventory" then
exports.ox_inventory:RemoveItem(source, item, amount)
end

GetItems

if ServerConfig.m_customInventory and ServerConfig.m_customInventory.inventory_type == "ox_inventory" then
local items = {}
local inventory = exports.ox_inventory:GetInventory(source)

if inventory and inventory.items then
for _, itemData in pairs(inventory.items) do
if itemData.name and itemData.count and itemData.count > 0 then
items[itemData.name] = (items[itemData.name] or 0) + itemData.count
end
end
end

return items
end
Did this answer your question?