QB/PS/LJ Inventory

  • This guide applies for qb-inventory, ps-inventory and lj-inventory.

  • Go to qb-core/server/main.lua and add this code at the bottom:

  • Don't forget to replace GetResourcePath('qb-inventory') with your inventory name (lj-inventory / ps-inventory)

AddEventHandler('inventory:refresh', function()
    local success, items = pcall(MySQL.query.await, 'SELECT * FROM av_items')
    if success and items and next(items) then
        local path = GetResourcePath('qb-inventory') -- Rename it to lj-inventory or ps-inventory
        for i = 1, #items do
            local item = items[i]
            if not QBShared.Items[item['name']] then
                QBShared.Items[item['name']] = {
                    name = item['name'],
                    label = item['label'],
                    weight = item['weight'],
                    type = 'item',
                    image = item['name']..'.png',
                    unique = false,
                    useable = true,
                    shouldClose = true,
                    combinable = {},
                    description = item['description']
                }
                if item.image then
                    PerformHttpRequest(item.image, function (errorCode, resultData, resultHeaders)
                        if errorCode >= 200 and errorCode < 300 then
                            local image = assert(io.open(path..'/html/images/'..item.name..'.png', "wb"))
                            image:write(resultData)
                            image:flush()
                            image:close()
                        end
                    end)
                end
            end
        end
        TriggerEvent('QBCore:Server:UpdateObject')
    end
end)
  • If you are using qb-inventory 2.0.0 or newer (verify the fxmanifest version) you are good to go, if not then go to your inventory/server/main.lua and add this event at the bottom:

RegisterNetEvent('QBCore:Server:UpdateObject', function()
    if source ~= '' then return end
    QBCore = exports['qb-core']:GetCoreObject()
end)

Last updated