ESX

This guide only applies if you are using origen_inventory and ESX

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

  • Open business.lua and paste the following code:

AddEventHandler('inventory:refresh', function()
    MySQL.query('SELECT * FROM av_items', {}, function(result)
        if result and next(result) then
            local dump = {}
            local resource = GetCurrentResourceName()
            local path = GetResourcePath(resource)
            for i = 1, #result do
                local item = result[i]
                if not OrgItems[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')
                    OrgItems[item.name] = item
                end
            end
        end
    end)
end)
  • Save the changes and you are good to go.

Last updated