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}) TriggerClientEvent('ox_inventory:openInventory', src, 'shop', {type = title})
end end
-- This will register a shop, if it already exists it will return true. -- 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))
---@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
--- Creates a new shop if it doesn't already exist. -- This will register a shop, if it already exists it will return true.
--- ---@param shopTitle string
--- @class ShopData ---@param shopInventory table
--- @field id string|nil -- Unique identifier for the shop (optional, falls back to title) ---@param shopCoords table
--- @field name string -- Display name of the shop ---@param shopGroups table
--- @field items table -- Table of items available in the shop Inventory.RegisterShop = function(shopTitle, shopInventory, shopCoords, shopGroups)
--- @field coords table|nil -- Optional coordinates for the shop location if registeredShops[shopTitle] then return true end
--- @field groups table|nil -- Optional groups allowed to access the shop registeredShops[shopTitle] = true
--- ox_inventory:RegisterShop(shopTitle, { name = shopTitle, inventory = shopInventory, groups = shopGroups, })
--- @param data ShopData -- Table containing shop properties --return Inventory.OpenShop(src, shopTitle)
--- @return string|boolean -- Returns the shop ID if the shop was created, false if it already exists return true
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
end end
---UNUSED: ---UNUSED: