Open jessemel opened 12 months ago
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
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