diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index 3e95598..282bfd9 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -86,19 +86,16 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ---@return nil -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.") end ----This will register a stash +--This will register a stash ---@param id number||string ---@param label string ---@param slots number @@ -107,8 +104,19 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.") + if Inventory.Stashes[id] then return true, id end + Inventory.Stashes[id] = { + id = id, + label = label, + slots = slots, + weight = weight, + owner = owner, + groups = groups, + coords = coords + } + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/codem-inventory/server.lua b/modules/inventory/codem-inventory/server.lua index 14434b5..c1d713f 100644 --- a/modules/inventory/codem-inventory/server.lua +++ b/modules/inventory/codem-inventory/server.lua @@ -97,15 +97,13 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ---@return nil -Inventory.OpenStash = function(src, id) - local stash = Inventory.Stashes[id] - assert(stash, "Stash not found", id) - local label = stash.label - local slots = stash.slots - local weight = stash.weight - TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = label, slots = slots, weight = weight }) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] + TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = tbl.label, slots = tbl.slots, weight = tbl.weight }) end @@ -118,8 +116,9 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end Inventory.Stashes[id] = { id = id, label = label, @@ -129,7 +128,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - return true + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/core_inventory/server.lua b/modules/inventory/core_inventory/server.lua index 13ecdf5..cdfdd3d 100644 --- a/modules/inventory/core_inventory/server.lua +++ b/modules/inventory/core_inventory/server.lua @@ -143,18 +143,13 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ---@return nil -Inventory.OpenStash = function(src, id) - local stash = Inventory.Stashes[id] - assert(stash, "Stash not found", id) - core:openInventory(src, id, 'stash', stash.slots, stash.weight, true, nil, false) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] + core:openInventory(src, id, _type, tbl.slots, tbl.weight, true, nil, false) end ---This will register a stash @@ -166,8 +161,9 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end if not slots then slots = 30 end local mathyShit = slots / 2 Inventory.Stashes[id] = { @@ -179,8 +175,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false) - return true + --core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false) + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/jpr-inventory/server.lua b/modules/inventory/jpr-inventory/server.lua index cee3f02..8362184 100644 --- a/modules/inventory/jpr-inventory/server.lua +++ b/modules/inventory/jpr-inventory/server.lua @@ -63,12 +63,13 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ---@return nil -Inventory.OpenStash = function(src, id) - local stash = Inventory.Stashes[id] - assert(stash, "Stash not found", id) - TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = stash.weight, slots = stash.slots }) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] + TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = tbl.weight, slots = tbl.slots }) end ---This will register a stash @@ -80,8 +81,9 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end Inventory.Stashes[id] = { id = id, label = label, @@ -91,7 +93,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - return true + return true, id end ---This will add items to a trunk, and return true or false based on success diff --git a/modules/inventory/origen_inventory/server.lua b/modules/inventory/origen_inventory/server.lua index 4c88b3d..594e9cf 100644 --- a/modules/inventory/origen_inventory/server.lua +++ b/modules/inventory/origen_inventory/server.lua @@ -143,18 +143,13 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ---@return nil -Inventory.OpenStash = function(src, id) - local stash = Inventory.Stashes[id] - assert(stash, "Stash not found", id) - return origin:OpenInventory(src, 'stash', id) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] + return origin:OpenInventory(src, _type, id) end ---This will register a stash @@ -167,7 +162,7 @@ end ---@param coords table ---@return boolean Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end Inventory.Stashes[id] = { id = id, label = label, @@ -177,7 +172,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - return origin:registerStash(id, label, slots, weight, owner, groups, coords) + origin:registerStash(id, label, slots, weight, owner, groups, coords) + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/ox_inventory/server.lua b/modules/inventory/ox_inventory/server.lua index 6d8ead7..2b077c1 100644 --- a/modules/inventory/ox_inventory/server.lua +++ b/modules/inventory/ox_inventory/server.lua @@ -112,9 +112,11 @@ end ---This will open the specified stash for the src passed. ---@param src number ---@param _type string ----@param id number|string +---@param id number||string ---@return nil Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + --local tbl = Inventory.Stashes[id] ox_inventory:forceOpenInventory(src, _type, id) end @@ -127,8 +129,9 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end Inventory.Stashes[id] = { id = id, label = label, @@ -138,7 +141,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - return ox_inventory:RegisterStash(id, label, slots, weight, owner, groups) + ox_inventory:RegisterStash(id, label, slots, weight, owner, groups) + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/ps-inventory/server.lua b/modules/inventory/ps-inventory/server.lua index d3b2a94..7bb44c2 100644 --- a/modules/inventory/ps-inventory/server.lua +++ b/modules/inventory/ps-inventory/server.lua @@ -102,16 +102,13 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ---@return nil -Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) - TriggerClientEvent('community_bridge:client:ps-inventory:openStash', src, id, { label = label, maxweight = weight, slots = slots, }) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] + TriggerClientEvent('community_bridge:client:ps-inventory:openStash', src, id, { label = tbl.label, maxweight = tbl.weight, slots = tbl.slots, }) end ---This will register a stash @@ -123,8 +120,9 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end Inventory.Stashes[id] = { id = id, label = label, @@ -133,8 +131,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor owner = owner, groups = groups, coords = coords - } - return true + } + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/qb-inventory/server.lua b/modules/inventory/qb-inventory/server.lua index da225a4..5807125 100644 --- a/modules/inventory/qb-inventory/server.lua +++ b/modules/inventory/qb-inventory/server.lua @@ -120,17 +120,18 @@ end ---This will open the specified stash for the src passed. ---@param src number ----@param id number|string +---@param _type string +---@param id number||string ---@return nil -Inventory.OpenStash = function(src, id) - local stash = Inventory.Stashes[id] - assert(stash, "Stash not found", id) +Inventory.OpenStash = function(src, _type, id) + _type = _type or "stash" + local tbl = Inventory.Stashes[id] if getInventoryNewVersion() then return qbInventory:OpenInventory(src, id) end - TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = stash.weight, slots = stash.slots}) + TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = tbl.weight, slots = tbl.slots}) end ---This will register a stash @@ -142,8 +143,9 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) - if Inventory.Stashes[id] then return true end + if Inventory.Stashes[id] then return true, id end Inventory.Stashes[id] = { id = id, label = label, @@ -153,7 +155,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - return true + return true, id end ---This will return a boolean if the player has the item. @@ -213,7 +215,7 @@ Inventory.UpdatePlate = function(oldplate, newplate) return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate) end --- This will open the specified shop for the src passed. +---This will open the specified shop for the src passed. ---@param src number ---@param shopTitle string Inventory.OpenShop = function(src, shopTitle) @@ -227,11 +229,11 @@ Inventory.OpenShop = function(src, shopTitle) end end --- 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 +--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 not shopTitle or not shopInventory then return end if registeredShops[shopTitle] then return true end diff --git a/modules/inventory/qs-inventory/server.lua b/modules/inventory/qs-inventory/server.lua index eb1236d..3d68dc3 100644 --- a/modules/inventory/qs-inventory/server.lua +++ b/modules/inventory/qs-inventory/server.lua @@ -137,18 +137,13 @@ end ---This will open the specified stash for the src passed. ---@param src number +---@param _type string ---@param id number||string ----@param label string ----@param slots number ----@param weight number ----@param owner string ----@param groups table ----@param coords table ---@return nil Inventory.OpenStash = function(src, _type, id) _type = _type or "stash" - local data = Inventory.Stashes[id] - TriggerEvent("inventory:server:OpenInventory", _type, id, data and { maxweight = data.weight, slots = data.slots }) + local tbl = Inventory.Stashes[id] + TriggerEvent("inventory:server:OpenInventory", _type, id, tbl and { maxweight = tbl.weight, slots = tbl.slots }) TriggerClientEvent("inventory:client:SetCurrentStash",src, id) end @@ -161,6 +156,7 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) if Inventory.Stashes[id] then return true end Inventory.Stashes[id] = { @@ -173,7 +169,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor coords = coords } --exports['qs-inventory']:RegisterStash(src, id, stashSlots, stashWeight) -- this needs to pass source to register, need to plan around this. - return true + return true, id end ---This will return a boolean if the player has the item. diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index aad62f6..f0c05fb 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -105,20 +105,11 @@ end ---This will open the specified stash for the src passed. ---@param src number ----@param _type string == "trunk" || "glovebox" || "stash" +---@param _type string ---@param id number||string ---@return nil Inventory.OpenStash = function(src, _type, id) - -- if id:sub(1, 5) == "trunk" then - -- _type = "trunk" - -- id = id:sub(5) - -- elseif id:sub(1, 6) == "glovebox" then - -- _type = "glovebox" - -- id = id:sub(6) - -- elseif id:sub(1, 5) == "stash" then - -- _type = "stash" - -- id = id:sub(5) - -- end + _type = _type or "stash" local tbl = Inventory.Stashes[id] return tgiann:ForceOpenInventory(src, _type, id, tbl and { maxWeight = tbl.weight , slots = tbl.slot, label = tbl.label}) end @@ -132,6 +123,7 @@ end ---@param groups table ---@param coords table ---@return boolean +---@return string Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) Inventory.Stashes[id] = { id = id, @@ -142,7 +134,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor groups = groups, coords = coords } - return id + return true, id end ---This will return a boolean if the player has the item.