Qbus Item Creation

Test:

```
QBCore.Functions.CreateUseableItem(“cigars”, function(source, item)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.Functions.RemoveItem(item.name, 1, item.slot) then
TriggerClientEvent(“consumables:client:UseArmor”, src)
TriggerClientEvent(“consumables:client:Usecigars”, src)
end
end)
```
Ugh that’s using ```

No no, you are not understanding.
Please just share your “consumables:client:UseArmor” event.
Not the trigger or anything. The client event. Like you shared “consumables:client:Usecigars”
I am trying to help you.

RegisterNetEvent('consumables:client:UseArmor', function()
    if GetPedArmour(PlayerPedId()) >= 75 then QBCore.Functions.Notify('You already have enough armor on!', 'error') return end
    QBCore.Functions.Progressbar("use_armor", "Putting on the body armour..", 5000, false, true, {
        disableMovement = false,
        disableCarMovement = false,
		disableMouse = false,
		disableCombat = true,
    }, {}, {}, {}, function() -- Done
        TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items["armor"], "remove")
        TriggerServerEvent('hospital:server:SetArmor', 75)
        TriggerServerEvent("QBCore:Server:RemoveItem", "armor", 1)
        SetPedArmour(PlayerPedId(), 75)
    end)
end)

I know you’re trying to help, I appreciate it.

So this is what I was trying to explain to you;

Server File:

QBCore.Functions.CreateUseableItem("cigars", function(source, item)
	local src = source
	local Player = QBCore.Functions.GetPlayer(src)
	if Player.Functions.RemoveItem(item.name, 1, item.slot) then
		TriggerClientEvent("consumables:client:UseCigars", src)
	end
end)

Client File:

RegisterNetEvent("consumables:client:UseCigars", function()
	QBCore.Functions.Progressbar("smoke_cigars", "Lighting cigars…", 1500, false, true, {
		disableMovement = false,
		disableCarMovement = false,
		disableMouse = false,
		disableCombat = true,
		}, {}, {}, {}, function()
		local ped = PlayerPedId()
		TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items["cigars"], "remove")
		if IsPedInAnyVehicle(ped, false) then
			TriggerEvent("animations:client:EmoteCommandStart", {"smoke3"})
		else
			TriggerEvent("animations:client:EmoteCommandStart", {"smokeweed"})
		end
		if GetPedArmour(ped) < 75 then
			TriggerServerEvent('hospital:server:SetArmor', 75)
			SetPedArmour(ped, 75)
		end
		TriggerEvent("evidence:client:SetStatus", "weedsmell", 300)
		TriggerEvent("animations:client:SmokeWeed")
	end)
end)

Here you have the code from the joint event, inside a new cigars event. Then I took some code from the armor event and put it inside as well. So only 1 progress bar, but it does both smoke animation and armor. That is how to code. Not settle for triggering 2 events that you don’t need. Make your own. So there you go. Please mark this as the solution. Enjoy! :spades:

Don’t worry, you had it right the first time. DrAceMisanthrope was replying to me, telling me how to escape the characters to show you an example. Don’t use the backslashes, only three backticks.

1 Like

I did. Thank you very much. So just replace my existing code with this yea? Thank you. It actually did work, I just forgot to change my server side code & remove the “UseArmor” section.

This topic can be closed. Thank you

1 Like