Restore legacy shop logic

Reverts shop registration to pre-commit #e06e04a behavior, removing the CreateShop function and restoring RegisterShop. This fixes breaking changes affecting multiple resources and inventories without any deprecation path.
This commit is contained in:
MrNewb committed 2025-08-29 23:47:52 -04:00
1 parent 996339f0bc
commit ac9f0ae777
1 file changed
+12 -33
+12 -33
View File
@@ -199,40 +199,19 @@ Inventory.OpenShop = function(src, id)
TriggerClientEvent('ox_inventory:openInventory', src, 'shop', {type = title})
end
-- This will register a shop, if it already exists it will return true.
---@param title string
---@param items table
---@param coords table
---@param groups table
Inventory.RegisterShop = function(title, items, coords, groups)
return Inventory.CreateShop({id = title, name = title, items = items, coords = coords, groups = groups})
end
-- restores shops to before commit #e06e04a (no depreication path followed, breaking change and not present on all inventories so undoing it. (also breaking multiple resources))
--- Creates a new shop if it doesn't already exist.
---
--- @class ShopData
--- @field id string|nil -- Unique identifier for the shop (optional, falls back to title)
--- @field name string -- Display name of the shop
--- @field items table -- Table of items available in the shop
--- @field coords table|nil -- Optional coordinates for the shop location
--- @field groups table|nil -- Optional groups allowed to access the shop
---
--- @param data ShopData -- Table containing shop properties
--- @return string|boolean -- Returns the shop ID if the shop was created, false if it already exists
Inventory.CreateShop = function(data)
assert(data, "CreateShop: data is required")
local id = data.id or data.name
if registeredShops[id] then return id end
assert(data.name, "CreateShop: name is required")
assert(data.items and type(data.items) == "table", "CreateShop: items table is required")
registeredShops[id] = {
name = data.name,
items = data.items,
coords = data.coords,
groups = data.groups
}
ox_inventory:RegisterShop(id, data)
return id
-- This will register a shop, if it already exists it will return true.
---@param shopTitle string
---@param shopInventory table
---@param shopCoords table
---@param shopGroups table
Inventory.RegisterShop = function(shopTitle, shopInventory, shopCoords, shopGroups)
if registeredShops[shopTitle] then return true end
registeredShops[shopTitle] = true
ox_inventory:RegisterShop(shopTitle, { name = shopTitle, inventory = shopInventory, groups = shopGroups, })
--return Inventory.OpenShop(src, shopTitle)
return true
end
---UNUSED: