🥪Food & Drink Props
Installation:
For qb-smallresources:
RegisterNetEvent('consumables:client:Custom', function(itemName) QBCore.Functions.TriggerCallback('consumables:itemdata', function(data) local propsList = {} if data.prop then if type(data.prop) == 'table' and data.prop[1] then propsList = data.prop elseif type(data.prop) == 'table' and data.prop.model then propsList = { data.prop } end end local attachedProps = {} local function spawnProps() local ped = PlayerPedId() for _, propData in ipairs(propsList) do local model = type(propData.model) == 'number' and propData.model or GetHashKey(propData.model) if not HasModelLoaded(model) then RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end local obj = CreateObject(model, 0.0, 0.0, 0.0, true, true, false) local boneIndex = GetPedBoneIndex(ped, propData.bone or 60309) local ox, oy, oz = 0.0, 0.0, 0.0 if propData.coords then ox, oy, oz = propData.coords.x, propData.coords.y, propData.coords.z end local rx, ry, rz = 0.0, 0.0, 0.0 if propData.rotation then rx, ry, rz = propData.rotation.x, propData.rotation.y, propData.rotation.z end AttachEntityToEntity(obj, ped, boneIndex, ox, oy, oz, rx, ry, rz, true, true, false, true, 1, true) table.insert(attachedProps, obj) end end local function cleanupProps() for _, obj in ipairs(attachedProps) do if DoesEntityExist(obj) then DeleteEntity(obj) end end attachedProps = {} end spawnProps() 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 }, {}, {}, function() cleanupProps() 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, function() cleanupProps() QBCore.Functions.Notify(Lang:t('consumables.canceled'), 'error') end) end, itemName) end)
Last updated
