ESX

This guide only applies if you are using origen_inventory and ESX

  • Go to origen_inventory/server/custom and create a new file, name it business.lua

  • Open business.lua and paste the following code:

AddEventHandler('inventory:refresh', function()
    local success, items = pcall(MySQL.query.await, 'SELECT * FROM av_items')
    if success and items and next(items) then
        local dump = {}
        local resource = GetCurrentResourceName()
        local path = GetResourcePath(resource)
        for i = 1, #items do
            local item = items[i]
            if not QBItems[item.name] then
                item.shouldClose = true
                item.unique = false
                item.useable = true
                item.description = item.description
                item.weight = item.weight or 100
                item.type = 'item'
                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()
                        else
                            print("Image URL not found for item " .. item.label)
                        end
                    end)
                end
                item.image = tostring(item.name .. '.png')
                QBItems[item.name] = item
            end
        end
    end
end)
  • Save the changes and you are good to go.

Last updated