cleaned up intelisense, finsihed adding type to openstash, registration tweaks

This commit is contained in:
MrNewb committed 2025-06-07 21:55:14 -04:00
1 parent fcf0bec75a
commit baf1c3b2a9
10 files changed
+89 -96

No files matched your search

+17 -9
View File
@@ -86,19 +86,16 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||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 ---@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.") return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.")
end end
---This will register a stash --This will register a stash
---@param id number||string ---@param id number||string
---@param label string ---@param label string
---@param slots number ---@param slots number
@@ -107,8 +104,19 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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 end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+8 -9
View File
@@ -97,15 +97,13 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||string ---@param id number||string
---@return nil ---@return nil
Inventory.OpenStash = function(src, id) Inventory.OpenStash = function(src, _type, id)
local stash = Inventory.Stashes[id] _type = _type or "stash"
assert(stash, "Stash not found", id) local tbl = Inventory.Stashes[id]
local label = stash.label TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = tbl.label, slots = tbl.slots, weight = tbl.weight })
local slots = stash.slots
local weight = stash.weight
TriggerClientEvent('community_bridge:client:codem-inventory:openStash', src, id, { label = label, slots = slots, weight = weight })
end end
@@ -118,8 +116,9 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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] = { Inventory.Stashes[id] = {
id = id, id = id,
label = label, label = label,
@@ -129,7 +128,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords coords = coords
} }
return true return true, id
end end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+9 -13
View File
@@ -143,18 +143,13 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||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 ---@return nil
Inventory.OpenStash = function(src, id) Inventory.OpenStash = function(src, _type, id)
local stash = Inventory.Stashes[id] _type = _type or "stash"
assert(stash, "Stash not found", id) local tbl = Inventory.Stashes[id]
core:openInventory(src, id, 'stash', stash.slots, stash.weight, true, nil, false) core:openInventory(src, id, _type, tbl.slots, tbl.weight, true, nil, false)
end end
---This will register a stash ---This will register a stash
@@ -166,8 +161,9 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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 if not slots then slots = 30 end
local mathyShit = slots / 2 local mathyShit = slots / 2
Inventory.Stashes[id] = { Inventory.Stashes[id] = {
@@ -179,8 +175,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords coords = coords
} }
core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false) --core:openInventory(nil, id, 'stash', mathyShit, mathyShit, false, nil, false)
return true return true, id
end end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+8 -6
View File
@@ -63,12 +63,13 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||string ---@param id number||string
---@return nil ---@return nil
Inventory.OpenStash = function(src, id) Inventory.OpenStash = function(src, _type, id)
local stash = Inventory.Stashes[id] _type = _type or "stash"
assert(stash, "Stash not found", id) local tbl = Inventory.Stashes[id]
TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = stash.weight, slots = stash.slots }) TriggerClientEvent('community_bridge:client:jpr-inventory:openStash', src, id, { weight = tbl.weight, slots = tbl.slots })
end end
---This will register a stash ---This will register a stash
@@ -80,8 +81,9 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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] = { Inventory.Stashes[id] = {
id = id, id = id,
label = label, label = label,
@@ -91,7 +93,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords coords = coords
} }
return true return true, id
end end
---This will add items to a trunk, and return true or false based on success ---This will add items to a trunk, and return true or false based on success
+8 -12
View File
@@ -143,18 +143,13 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||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 ---@return nil
Inventory.OpenStash = function(src, id) Inventory.OpenStash = function(src, _type, id)
local stash = Inventory.Stashes[id] _type = _type or "stash"
assert(stash, "Stash not found", id) local tbl = Inventory.Stashes[id]
return origin:OpenInventory(src, 'stash', id) return origin:OpenInventory(src, _type, id)
end end
---This will register a stash ---This will register a stash
@@ -167,7 +162,7 @@ end
---@param coords table ---@param coords table
---@return boolean ---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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] = { Inventory.Stashes[id] = {
id = id, id = id,
label = label, label = label,
@@ -177,7 +172,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords 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 end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+7 -3
View File
@@ -112,9 +112,11 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string ---@param _type string
---@param id number|string ---@param id number||string
---@return nil ---@return nil
Inventory.OpenStash = function(src, _type, id) Inventory.OpenStash = function(src, _type, id)
_type = _type or "stash"
--local tbl = Inventory.Stashes[id]
ox_inventory:forceOpenInventory(src, _type, id) ox_inventory:forceOpenInventory(src, _type, id)
end end
@@ -127,8 +129,9 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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] = { Inventory.Stashes[id] = {
id = id, id = id,
label = label, label = label,
@@ -138,7 +141,8 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords 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 end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+8 -10
View File
@@ -102,16 +102,13 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||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 ---@return nil
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords) Inventory.OpenStash = function(src, _type, id)
TriggerClientEvent('community_bridge:client:ps-inventory:openStash', src, id, { label = label, maxweight = weight, slots = slots, }) _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 end
---This will register a stash ---This will register a stash
@@ -123,8 +120,9 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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] = { Inventory.Stashes[id] = {
id = id, id = id,
label = label, label = label,
@@ -134,7 +132,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords coords = coords
} }
return true return true, id
end end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+15 -13
View File
@@ -120,17 +120,18 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param id number|string ---@param _type string
---@param id number||string
---@return nil ---@return nil
Inventory.OpenStash = function(src, id) Inventory.OpenStash = function(src, _type, id)
local stash = Inventory.Stashes[id] _type = _type or "stash"
assert(stash, "Stash not found", id) local tbl = Inventory.Stashes[id]
if getInventoryNewVersion() then if getInventoryNewVersion() then
return qbInventory:OpenInventory(src, id) return qbInventory:OpenInventory(src, id)
end 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 end
---This will register a stash ---This will register a stash
@@ -142,8 +143,9 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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] = { Inventory.Stashes[id] = {
id = id, id = id,
label = label, label = label,
@@ -153,7 +155,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords coords = coords
} }
return true return true, id
end end
---This will return a boolean if the player has the item. ---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) return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
end 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 src number
---@param shopTitle string ---@param shopTitle string
Inventory.OpenShop = function(src, shopTitle) Inventory.OpenShop = function(src, shopTitle)
@@ -227,11 +229,11 @@ Inventory.OpenShop = function(src, shopTitle)
end end
end end
-- This will register a shop, if it already exists it will return true. --This will register a shop, if it already exists it will return true.
-- @param shopTitle string ---@param shopTitle string
-- @param shopInventory table ---@param shopInventory table
-- @param shopCoords table ---@param shopCoords table
-- @param shopGroups table ---@param shopGroups table
Inventory.RegisterShop = function(shopTitle, shopInventory, shopCoords, shopGroups) Inventory.RegisterShop = function(shopTitle, shopInventory, shopCoords, shopGroups)
if not shopTitle or not shopInventory then return end if not shopTitle or not shopInventory then return end
if registeredShops[shopTitle] then return true end if registeredShops[shopTitle] then return true end
+5 -9
View File
@@ -137,18 +137,13 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string
---@param id number||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 ---@return nil
Inventory.OpenStash = function(src, _type, id) Inventory.OpenStash = function(src, _type, id)
_type = _type or "stash" _type = _type or "stash"
local data = Inventory.Stashes[id] local tbl = Inventory.Stashes[id]
TriggerEvent("inventory:server:OpenInventory", _type, id, data and { maxweight = data.weight, slots = data.slots }) TriggerEvent("inventory:server:OpenInventory", _type, id, tbl and { maxweight = tbl.weight, slots = tbl.slots })
TriggerClientEvent("inventory:client:SetCurrentStash",src, id) TriggerClientEvent("inventory:client:SetCurrentStash",src, id)
end end
@@ -161,6 +156,7 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) 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 end
Inventory.Stashes[id] = { Inventory.Stashes[id] = {
@@ -173,7 +169,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
coords = coords coords = coords
} }
--exports['qs-inventory']:RegisterStash(src, id, stashSlots, stashWeight) -- this needs to pass source to register, need to plan around this. --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 end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.
+4 -12
View File
@@ -105,20 +105,11 @@ end
---This will open the specified stash for the src passed. ---This will open the specified stash for the src passed.
---@param src number ---@param src number
---@param _type string == "trunk" || "glovebox" || "stash" ---@param _type string
---@param id number||string ---@param id number||string
---@return nil ---@return nil
Inventory.OpenStash = function(src, _type, id) Inventory.OpenStash = function(src, _type, id)
-- if id:sub(1, 5) == "trunk" then _type = _type or "stash"
-- _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
local tbl = Inventory.Stashes[id] local tbl = Inventory.Stashes[id]
return tgiann:ForceOpenInventory(src, _type, id, tbl and { maxWeight = tbl.weight , slots = tbl.slot, label = tbl.label}) return tgiann:ForceOpenInventory(src, _type, id, tbl and { maxWeight = tbl.weight , slots = tbl.slot, label = tbl.label})
end end
@@ -132,6 +123,7 @@ end
---@param groups table ---@param groups table
---@param coords table ---@param coords table
---@return boolean ---@return boolean
---@return string
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords) Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
Inventory.Stashes[id] = { Inventory.Stashes[id] = {
id = id, id = id,
@@ -142,7 +134,7 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coor
groups = groups, groups = groups,
coords = coords coords = coords
} }
return id return true, id
end end
---This will return a boolean if the player has the item. ---This will return a boolean if the player has the item.