HasItem + partial support for shops

This commit is contained in:
MrNewb committed 2025-03-07 04:08:40 -05:00
1 parent f28e511de6
commit dee14600ba
14 files changed
+220 -7

No files matched your search

@@ -17,6 +17,14 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
return true
end
---comment
---@param src number
---@param item string
---@return boolean
Inventory.HasItem = function(src, item)
return jpr:HasItem(src, item, 1)
end
---comment
---@param src number
---@param id string||number
@@ -64,4 +72,27 @@ Inventory.UpdatePlate = function(oldplate, newplate)
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
local registeredShops = {}
Inventory.OpenShop = function(src, shopTitle)
return jpr:OpenShop(src, shopTitle)
end
Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopGroups)
if not shopTitle or not shopInventory or not shopCoords then return end
if registeredShops[shopTitle] then return true end
local repackItems = {}
local repackedShopItems = {name = shopTitle, label = shopTitle, coords = shopCoords, items = repackItems, slots = #shopInventory, }
for k, v in pairs(shopInventory) do
table.insert(repackItems, { name = v.name, price = v.price or 1000, amount = v.count or 1, slot = k })
end
jpr:CreateShop(repackedShopItems)
registeredShops[shopTitle] = true
--Inventory.OpenShop(src, shopTitle)
return true
end