OX Inventory

  1. 1.
    Change AV Restaurants config file to Config.ESXInventory = 'ox_inventory'
  2. 2.
    Go to ox_inventory/modules/items and paste this code inside server.lua right before the return Items line at bottom:
AddEventHandler('inventory:refresh',function()
local success, items = pcall(MySQL.query.await, 'SELECT * FROM av_items')
if success and items and next(items) then
local resource = GetCurrentResourceName()
local path = GetResourcePath(resource)
local dump = {}
for i = 1, #items do
local item = items[i]
if not ItemList[item.name] then
item.close = item.closeonuse == nil and true or item.closeonuse
item.stack = item.stackable == nil and true or item.stackable
item.description = item.description
item.weight = item.weight or 0
dump[i] = 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..'/web/images/'..item.name..'.png', "wb"))
image:write(resultData)
image:flush()
image:close()
end
end)
end
end
end
if table.type(dump) ~= "empty" then
local file = {string.strtrim(LoadResourceFile(shared.resource, 'data/items.lua'))}
file[1] = file[1]:gsub('}$', '')
local itemFormat = [[
['%s'] = {
label = '%s',
weight = %s,
stack = %s,
close = %s,
description = %s
},
]]
local fileSize = #file
for _, item in pairs(dump) do
local formatName = item.name:gsub("'", "\\'"):lower()
if not ItemList[formatName] then
fileSize += 1
file[fileSize] = (itemFormat):format(formatName, item.label:gsub("'", "\\'"):lower(), item.weight, item.stack, item.close, item.description and ('"%s"'):format(item.description) or 'nil')
ItemList[formatName] = item
end
end
file[fileSize+1] = '}'
SaveResourceFile(shared.resource, 'data/items.lua', table.concat(file), -1)
end
end
end)
3. Join Discord if you need help with anything, enjoy the script <3.
Last modified 9mo ago