OX Inventory
Kartik-Business integrates seamlessly with ox_inventory, allowing business items (food, ingredients, products, etc.) to be dynamically registered into OX Inventory at runtime.
This integration ensures that items created or managed through the business system automatically appear inside ox_inventory without requiring manual item registration.
๐ฆ Requirements
Before proceeding, ensure the following dependencies are installed and running:
- ox_inventory
- oxmysql
- QBCore / QBX Core
- Kartik-Business
- kartik-laptop
๐ How the Integration Works
When Kartik-Business needs to register a new item:
- The item is dynamically inserted into
ox_inventory/data/items.lua - Item metadata such as weight, stack behavior, and description is applied
- If an image URL is provided, it is downloaded and saved automatically
- Items become immediately usable in inventory
This process is handled via a server event.
๐ Server Event: Insert Item into OX Inventory
Kartik-Business uses the following event to register items dynamically:
RegisterNetEvent("kartik-business:inventory:insertItem", function(item)
if not item or not item.name or not item.label then return end
local formatName = item.name:gsub("'", "\\'"):lower()
if ItemList[formatName] then return end
local stack = true
local resource = GetCurrentResourceName()
local path = GetResourcePath(resource)
item.close = true
item.stack = stack
item.consume = false
item.degrade = 0
item.weight = item.weight or 1000
-- Load items.lua
local file = { string.strtrim(LoadResourceFile(shared.resource, 'data/items.lua')) }
file[1] = file[1]:gsub('}$', '')
local itemFormat = [[
['%s'] = {
label = '%s',
weight = %s,
consume = %s,
degrade = %s,
stack = %s,
close = %s,
description = %s
},
]]
local fileSize = #file
file[fileSize + 1] = itemFormat:format(
formatName,
item.label:gsub("'", "\\'"),
item.weight,
item.consume,
item.degrade,
item.stack,
item.close,
item.description and ('"%s"'):format(item.description:gsub('"', '\\"')) or 'nil'
)
file[fileSize + 2] = '}'
SaveResourceFile(shared.resource, 'data/items.lua', table.concat(file), -1)
ItemList[formatName] = item
if item.image then
PerformHttpRequest(item.image, function(code, data)
if code >= 200 and code < 300 then
local image = io.open(path .. '/web/images/' .. formatName .. '.png', "wb")
if image then
image:write(data)
image:flush()
image:close()
end
end
end)
end
end)๐ ๏ธ Required OX Inventory Modification
To allow dynamic item insertion, you must register the item before OX Inventory returns the item list.
๐ File to Edit
ox_inventory/modules/items/server.lua๐ What to Do
Add the integration logic just before the following line:
return ItemsThis ensures:
- Items injected by Kartik-Business are included
- Inventory recognizes them instantly
- No server restart is required after item creation
โ ๏ธ Do not place this code after return Items, as it will never execute.
๐งช Example Use Case
-
Business owner creates a new food item
-
Kartik-Business triggers
kartik-business:inventory:insertItem -
Item is:
- Registered in ox_inventory
- Given weight & metadata
- Assigned an image
-
Players can immediately use, trade, or sell the item
โ ๏ธ Important Notes
-
Item names are forced lowercase
-
Duplicate items are automatically ignored
-
Images are saved inside:
ox_inventory/web/images/ -
Works without restarting the server
๐ Eating, Drinking and Item Removal
Kartik-Business handles using menu items itself: it plays the item's animation, gives hunger or thirst, and removes one item when the animation finishes (cancelling keeps the item). For this to work, ox_inventory must hand the item over to the script:
- Keep
consume = false(as the event above writes) or leaveconsumeout. - Do not add
client.status,client.usetime,client.exportorclient.eventto menu items. Any of these makes ox_inventory use the item on its own, so the business animation and effects never run.
A correct entry looks like this:
['burgershot_12'] = {
label = 'Bleeder Burger',
weight = 250,
stack = true,
close = true,
description = 'Double patty with cheese',
client = { image = 'https://example.com/burger.png' },
},Hunger and thirst amounts per category (Food, Drink, Side) can be changed in client/open/effects.lua.
Menu items work the same however the player got them: crafted in the kitchen, collected from an order, bought from the shop or given by an admin.
Console Checks
On start, Kartik-Business checks your menu items against ox_inventory and prints a yellow line in the server console if:
- a menu item is missing from
ox_inventory/data/items.lua, or - a menu item has
consumeor aclient.status/usetime/export/eventset.
If you do not use the insert event above, a new menu item created in the app prints a ready-to-paste entry for ox_inventory/data/items.lua. Add it and restart ox_inventory.
โ Integration Complete
Once configured, Kartik-Business and ox_inventory will work together automatically, handling item creation, inventory syncing, and usability with zero manual work.
For further customization, refer to:
- OX Inventory documentation
- Kartik-Business configuration options