client side GetItemCount
Qbox is hardcoded for ox and the only inventory I know that supports it other than ox is quasar, both are bridged so should be completely fine
This commit is contained in:
1 parent
9ad8c6188c
commit
e5190cdca0
8 files changed
+70
No files matched your search
@@ -80,6 +80,15 @@ Framework.GetPlayerInventory = function()
|
|||||||
return playerData.inventory
|
return playerData.inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Framework.GetItemCount = function(item)
|
||||||
|
local inventory = Framework.GetPlayerInventory()
|
||||||
|
if not inventory then return 0 end
|
||||||
|
return inventory[item].count or 0
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
|
|||||||
@@ -79,6 +79,20 @@ Framework.HasItem = function(item)
|
|||||||
return QBCore.Functions.HasItem(item)
|
return QBCore.Functions.HasItem(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Framework.GetItemCount = function(item)
|
||||||
|
local frameworkInv = QBCore.Functions.GetPlayerData().items
|
||||||
|
local count = 0
|
||||||
|
for _, v in pairs(frameworkInv) do
|
||||||
|
if v.name == item then
|
||||||
|
count = count + v.amount
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
Framework.GetPlayerInventory = function()
|
Framework.GetPlayerInventory = function()
|
||||||
local items = {}
|
local items = {}
|
||||||
local frameworkInv = QBCore.Functions.GetPlayerData().items
|
local frameworkInv = QBCore.Functions.GetPlayerData().items
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ Framework.GetPlayerInventory = function()
|
|||||||
return QBox.GetPlayerData().items
|
return QBox.GetPlayerData().items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Framework.GetItemCount = function(item)
|
||||||
|
-- This seems to be exclusively for ox_inventory, if other inventories are used, they need to be bridged in the inventory module. Until then we will return 0 and a print.
|
||||||
|
return 0, print("Community_bridge:WARN: GetItemCount is not implemented for this framework, please use the inventory module to get the item count. If you are using a diffrent inventory please let us know so we can bridge it and have less nonsense.")
|
||||||
|
end
|
||||||
|
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
local platerData = QBox.GetPlayerData()
|
local platerData = QBox.GetPlayerData()
|
||||||
return platerData.metadata["isdead"] or platerData.metadata["inlaststand"]
|
return platerData.metadata["isdead"] or platerData.metadata["inlaststand"]
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ Inventory.HasItem = function(item)
|
|||||||
return Framework.HasItem(item)
|
return Framework.HasItem(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemCount = function(item)
|
||||||
|
return Framework.GetItemCount(item)
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
|
|||||||
@@ -27,6 +27,18 @@ Inventory.HasItem = function(item)
|
|||||||
return origin:HasItem(item)
|
return origin:HasItem(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Inventory.GetItemCount = function(item)
|
||||||
|
local searchItem = origin:Search('slots', item)
|
||||||
|
local count = 0
|
||||||
|
for _, v in pairs(searchItem) do
|
||||||
|
count = count + v.count
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ Inventory.HasItem = function(item)
|
|||||||
return hasItem
|
return hasItem
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Inventory.GetItemCount = function(item)
|
||||||
|
return ox_inventory:GetItemCount(item, nil, false)
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ Inventory.GetImagePath = function(item)
|
|||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Inventory.GetItemCount = function(item)
|
||||||
|
local searchItem = quasar:Search(item)
|
||||||
|
return searchItem or 0
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@return table
|
---@return table
|
||||||
Inventory.GetPlayerInventory = function()
|
Inventory.GetPlayerInventory = function()
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ Inventory.GetItemInfo = function(item)
|
|||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param item string
|
||||||
|
---@return number
|
||||||
|
Inventory.GetItemCount = function(item)
|
||||||
|
local searchItem = tgiann:GetItemCount(item, nil, false)
|
||||||
|
return searchItem or 0
|
||||||
|
end
|
||||||
|
|
||||||
---This will return a boolean if the player has the item in the inventory
|
---This will return a boolean if the player has the item in the inventory
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|||||||
Reference in new issue
Block a user