Kartik Scripts

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 Items

This 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 leave consume out.
  • Do not add client.status, client.usetime, client.export or client.event to 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 consume or a client.status / usetime / export / event set.

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

On this page