QBCore
This guide only applies if you are using QBCore and Quasar Inventory.
Go to qb-core/server/main.lua and add this code at the bottom:
local decayTypes = { -- float or false. The higher the value, the faster it wears out
['food'] = false, -- 0.07 (for example)
['drink'] = false,
['joint'] = false,
['alcohol'] = false,
}
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('qs-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',
decay = decayTypes[item['type']] or false,
image = item['name']..'.png',
unique = true,
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("quasar:refresh")
end
end)
Go to qs-inventory/server/custom/framework/qb.lua and add this event at bottom
RegisterNetEvent('quasar:refresh', function()
QBCore = exports['qb-core']:GetCoreObject()
ItemList = QBCore.Shared.Items
end)
Last updated