From ac9f0ae77775ce44af258eca49ea3138e88cf9ea Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Fri, 29 Aug 2025 23:47:52 -0400 Subject: [PATCH] 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. --- modules/inventory/ox_inventory/server.lua | 45 ++++++----------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index 10730e0..71750be 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -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: