AddEventHandler('inventory:refresh', function()
local resource = GetCurrentResourceName()
local path = GetResourcePath(resource)
MySQL.Async.fetchAll("SELECT * FROM av_items",{},function(items)
for _,item in ipairs(items) do
item.name = item.name:lower()
item.unique = false
item.weight = 1
itemTemplates[item.name] = 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..'/nui/items/'..item.name..'.png', "wb"))
image:write(resultData)
image:flush()
image:close()
end
end)
end
end
end)
end)
MySQL.Async.fetchAll("SELECT * FROM av_items",{},function(items)
for _,item in ipairs(items) do
item.name = item.name:lower()
item.unique = false
item.weight = 1
itemTemplates[item.name] = item
end
end)