Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treasure Chest and Key wont remove #28

Open
jessemel opened this issue Nov 4, 2023 · 1 comment
Open

Treasure Chest and Key wont remove #28

jessemel opened this issue Nov 4, 2023 · 1 comment

Comments

@jessemel
Copy link

jessemel commented Nov 4, 2023

when I have a treasure chest and key, I can open the chest but the key and chest will not be removed from inventory. this allows the chest to be opened over and over again

@ssthethird
Copy link

ssthethird commented Nov 6, 2023

I would do this in your Client file

openedTreasureChest = function()
	if math.random(1,15) == 10 then
		TriggerServerEvent('fishing:server:removeFishingKey')
		QBCore.Functions.Notify("The corroded key has snapped", "error", 7500)
	end
	TriggerServerEvent('fishing:server:openedTreasureChest')
	TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items["fishinglootbig"], "remove", 1)
	QBCore.Functions.Notify("Treasure chest opened! Be sure to collect all of your loot!!", "success", 7500)
	local ShopItems = {} 
	ShopItems.label = "Treasure Chest"
	ShopItems.items = Config.largeLootboxRewards
	ShopItems.slots = #Config.largeLootboxRewards
	TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_", ShopItems)
end

Then add these in your server file

RegisterNetEvent('fishing:server:openedTreasureChest', function()
	local src = source
    local Player = QBCore.Functions.GetPlayer(source)
	Player.Functions.RemoveItem('fishinglootbig', 1)
end)

RegisterNetEvent('fishing:server:removeFishingKey', function()
	local src = source
    local Player = QBCore.Functions.GetPlayer(source)
    Player.Functions.RemoveItem('fishingkey', 1)
end)

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants