- Open qb-smallresources/client/consumables.lua
- Search this event:
RegisterNetEvent('consumables:client:Custom', function(itemName)
- Check that your code is the same as the code in the version I’m using:
RegisterNetEvent('consumables:client:Custom', function(itemName)
QBCore.Functions.TriggerCallback('consumables:itemdata', function(data)
QBCore.Functions.Progressbar('custom_consumable', data.progress.label, data.progress.time, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true
}, {
animDict = data.animation.animDict,
anim = data.animation.anim,
flags = data.animation.flags
}, {
model = data.prop.model,
bone = data.prop.bone,
coords = data.prop.coords,
rotation = data.prop.rotation
}, {}, function() -- Done
ClearPedTasks(PlayerPedId())
TriggerEvent('qb-inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove')
if data.replenish.type then
TriggerServerEvent('consumables:server:add' .. data.replenish.type, QBCore.Functions.GetPlayerData().metadata[string.lower(data.replenish.type)] + data.replenish.replenish)
end
if data.replenish.isAlcohol then
alcoholCount += 1
AlcoholLoop()
if alcoholCount > 1 and alcoholCount < 4 then
TriggerEvent('evidence:client:SetStatus', 'alcohol', 200)
elseif alcoholCount >= 4 then
TriggerEvent('evidence:client:SetStatus', 'heavyalcohol', 200)
end
end
if data.replenish.event then
TriggerEvent(data.replenish.event)
end
end)
end, itemName)
end)
4. Edit this event according to this page: Github (Red row has been removed, green rows have been added)
You can also try downloading this entire file or resource, but there may have been some updates in qbcore, so it might not work. It’s important to have this event edited so that you can use two props.
5. Now you can use this template in qb-smallresources/config.lua
if you need 2 props:
['item_name'] = {
progress = {
label = 'Using Item...',
time = 5000
},
animation = {
animDict = 'bzzz@restaurant@eat', --(animDict)
anim = 'bzzz_restaurant_eat', --(animName)
flags = 17,
},
prop = {
model = 'first_prop_name',
bone = 18905,
coords = vector3(0.0, 0.0, 0.0), -- vector 3 format
rotation = vector3(0.0, 0.0, 0.0), -- vector 3 format
},
prop2 = {
model = 'second_prop_name',
bone = 28422,
coords = vec3(0.0, 0.0, 0.0),
rotation = vec3(0.0, 0.0, 0.0),
},
replenish = {
type = 'Hunger', -- replenish type 'Hunger'/'Thirst' / false
replenish = math.random(20, 40),
isAlcohol = false, -- if you want it to add alcohol count
event = false, -- 'eventname' if you want it to trigger an outside event on use useful for drugs
server = false -- if the event above is a server event
}
},
6. Of course, you must also add the item to qb-core/shared/items.lua
to use it.
item_name = { name = 'item_name', label = 'Item Label', weight = 500, type = 'item', image = 'image_name.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Bon appetit' },
7. You insert the item image into qb-inventory/html/images
, and the image name must be the same as the name mentioned above (image_name.png).