function Functions.RegisterSafe(storeid, items)
local config = Config.Store[storeid]
if not config then return end
if config.safe.opened and config.safe.id then return end
if Config.Inventory == "qb" then
local stashid = RandomStr(2) .. RandomInt(2) .. RandomStr(2)
for _, v in pairs(items) do
---@type string
local itemname = v[1]
if not itemname then
warn("Itemname doesn't exist...")
end
---@type number
local itemCount = v[2]
local itemInfo = itemname and QBCore.Shared.Items[itemname]
if itemInfo then
items[#items + 1] = {
name = itemInfo.name,
amount = tonumber(itemCount),
info = {},
label = itemInfo.label,
description = itemInfo.description ~= nil and itemInfo.description or "",
weight = itemInfo.weight,
type = itemInfo.type,
unique = itemInfo.unique,
useable = itemInfo.useable,
image = itemInfo.image,
slot = #items + 1
}
else
warn("Can't find iteminfo for " .. itemname or "Unknown")
end
end
MySQL.insert.await(
"INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items", {
['stash'] = stashid,
['items'] = json.encode(items)
})
return stashid
elseif Config.Inventory == "ox" then
return ox_inventory:CreateTemporaryStash({
label = "Safe",
slots = 10,
maxWeight = 100000,
items = items
})
end
end
Came across this script and liked the idea and minigames, I also ran into some issues with the safe but have since fixed this.
If you or anyone else is interested and are running into this issue, (Seems to be QB related) I have updated the RegisterSafe function to work with current QB-Inv.
With this modification, the Functions.RegisterSafe function should work in conjunction with the GetStashItems function.
function Functions.RegisterSafe(storeid, items)
local config = Config.Store[storeid]
if not config then return end
if config.safe.opened and config.safe.id then return end
if Config.Inventory == "qb" then
local stashid = RandomStr(2) .. RandomInt(2) .. RandomStr(2)
local newItems = {} -- Create a new table to hold the modified items
for _, v in pairs(items) do
local itemname = v[1]
if not itemname then
warn("Itemname doesn't exist...")
end
local itemCount = v[2]
local itemInfo = itemname and QBCore.Shared.Items[itemname]
if itemInfo then
newItems[#newItems + 1] = {
name = itemInfo.name:lower(),
amount = tonumber(itemCount),
info = {},
label = itemInfo.label,
description = itemInfo.description ~= nil and itemInfo.description or "",
weight = itemInfo.weight,
type = itemInfo.type,
unique = itemInfo.unique,
useable = itemInfo.useable,
image = itemInfo.image,
slot = #newItems + 1
}
else
warn("Can't find iteminfo for " .. (itemname or "Unknown"))
end
end
MySQL.insert.await(
"INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items", {
['stash'] = stashid,
['items'] = json.encode(newItems) -- Use the modified items table
})
return stashid
elseif Config.Inventory == "ox" then
return ox_inventory:CreateTemporaryStash({
label = "Safe",
slots = 10,
maxWeight = 100000,
items = items
})
end
end
Is there a way to change the way it gives the money? It gives in amounts right now vs a the default qbcore markedbills. I will post a screenshot. https://i.imgur.com/xfHj2Hv.png