Merge branch 'dev' of https://github.com/The-Order-Of-The-Sacred-Framework/community_bridge into dev
This commit is contained in:
commit
b125a1f937
5 files changed
+61
-74
No files matched your search
@@ -21,7 +21,8 @@ Framework.Notify = function(message, type, time)
|
||||
end
|
||||
|
||||
Framework.GetPlayerIdentifier = function()
|
||||
return ESX.GetPlayerData().identifier
|
||||
local playerData = ESX.GetPlayerData()
|
||||
return playerData.identifier
|
||||
end
|
||||
|
||||
Framework.GetPlayerName = function()
|
||||
@@ -40,11 +41,13 @@ Framework.HasItem = function(item)
|
||||
end
|
||||
|
||||
Framework.GetPlayerInventory = function()
|
||||
return ESX.GetPlayerData().inventory
|
||||
local playerData = ESX.GetPlayerData()
|
||||
return playerData.inventory
|
||||
end
|
||||
|
||||
Framework.GetIsPlayerDead = function()
|
||||
return ESX.GetPlayerData().dead
|
||||
local playerData = ESX.GetPlayerData()
|
||||
return playerData.dead
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
|
||||
|
||||
@@ -80,7 +80,8 @@ Framework.GetPlayerInventory = function()
|
||||
end
|
||||
|
||||
Framework.GetIsPlayerDead = function()
|
||||
return QBCore.Functions.GetPlayerData().metadata["isdead"] or QBCore.GetPlayerData().metadata["inlaststand"]
|
||||
local playerData = QBCore.Functions.GetPlayerData()
|
||||
return playerData.metadata["isdead"] or playerData.metadata["inlaststand"]
|
||||
end
|
||||
|
||||
Framework.Shared = QBCore.Shared
|
||||
|
||||
@@ -36,7 +36,8 @@ Framework.GetPlayerInventory = function()
|
||||
end
|
||||
|
||||
Framework.GetIsPlayerDead = function()
|
||||
return QBox.GetPlayerData().metadata["isdead"] or QBox.GetPlayerData().metadata["inlaststand"]
|
||||
local platerData = QBox.GetPlayerData()
|
||||
return platerData.metadata["isdead"] or platerData.metadata["inlaststand"]
|
||||
end
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||
|
||||
@@ -4,8 +4,7 @@ Inventory = Inventory or {}
|
||||
local codem = exports['codem-inventory']
|
||||
|
||||
Inventory.GetItemInfo = function(item)
|
||||
local itemData = codem:GetItemList()
|
||||
if not itemData[item] then return {} end
|
||||
local itemData = codem:GetItemList(item)
|
||||
local repackedTable = {
|
||||
name = itemData.name or "Missing Name",
|
||||
label = itemData.label or "Missing Label",
|
||||
@@ -14,12 +13,7 @@ Inventory.GetItemInfo = function(item)
|
||||
description = itemData.description or "none",
|
||||
image = itemData.image or Inventory.GetImagePath(item),
|
||||
}
|
||||
return repackedTable
|
||||
end
|
||||
|
||||
Inventory.GetImagePath = function(item)
|
||||
local imagePath = string.format("nui://codem-inventory/html/images/%s.png", item)
|
||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||
return repackedTable or {}
|
||||
end
|
||||
|
||||
Inventory.GetPlayerInventory = function()
|
||||
@@ -39,3 +33,9 @@ Inventory.GetPlayerInventory = function()
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
Inventory.GetImagePath = function(item)
|
||||
local file = LoadResourceFile("codem-inventory", string.format("html/images/%s.png", item))
|
||||
local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item)
|
||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||
end
|
||||
@@ -1,35 +1,11 @@
|
||||
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||
|
||||
local codem = exports['codem-inventory']
|
||||
|
||||
Inventory = Inventory or {}
|
||||
|
||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
||||
|
||||
return codem:AddItem(src, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||
if metadata == nil then
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
|
||||
return codem:RemoveItem(src, item, count, slot)
|
||||
else
|
||||
local items = codem:GetInventory(nil, src)
|
||||
for _, itemInfo in pairs(items) do
|
||||
if itemInfo.name == item then
|
||||
if itemInfo.info == metadata then
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = itemInfo.slot, metadata = metadata})
|
||||
return codem:RemoveItem(src, item, count, itemInfo.slot)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local codem = exports['codem-inventory']
|
||||
|
||||
Inventory.GetItemInfo = function(item)
|
||||
local itemData = codem:GetItemList()
|
||||
if not itemData[item] then return {} end
|
||||
local itemData = codem:GetItemList(item)
|
||||
local repackedTable = {
|
||||
name = itemData.name or "Missing Name",
|
||||
label = itemData.label or "Missing Label",
|
||||
@@ -38,27 +14,55 @@ Inventory.GetItemInfo = function(item)
|
||||
description = itemData.description or "none",
|
||||
image = itemData.image or Inventory.GetImagePath(item),
|
||||
}
|
||||
return repackedTable or {}
|
||||
end
|
||||
|
||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
||||
return codem:AddItem(src, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.GetItemBySlot = function(src, slot)
|
||||
return codem:GetItemBySlot(src, slot)
|
||||
end
|
||||
|
||||
Inventory.GetPlayerInventory = function(src)
|
||||
local identifier = Framework.GetPlayerIdentifier(src)
|
||||
local playerItems = codem:GetInventory(identifier, src)
|
||||
local repackedTable = {}
|
||||
for _, v in pairs(playerItems) do
|
||||
table.insert(repackedTable, {
|
||||
name = v.name,
|
||||
count = v.amount,
|
||||
metadata = v.info,
|
||||
slot = v.slot,
|
||||
})
|
||||
end
|
||||
return repackedTable
|
||||
end
|
||||
|
||||
Inventory.GetItemCount = function(src, item, metadata)
|
||||
if metadata == nil then
|
||||
return codem:GetItemsTotalAmount(src, item)
|
||||
else
|
||||
local count = 0
|
||||
local items = codem:GetInventory(nil, src)
|
||||
for _, itemInfo in pairs(items) do
|
||||
if itemInfo.name == item and itemInfo.info == metadata then
|
||||
count = count + itemInfo.amount
|
||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||
if not slot and metadata then
|
||||
local inv = Inventory.GetPlayerInventory(src)
|
||||
if not inv then return false end
|
||||
for _, v in pairs(inv) do
|
||||
if v.name == item and v.metadata == metadata then
|
||||
slot = v.slot
|
||||
break
|
||||
end
|
||||
return count
|
||||
end
|
||||
end
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
|
||||
return codem:RemoveItem(src, item, count, slot)
|
||||
end
|
||||
|
||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||
return codem:SetItemMetadata(src, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.GetItemBySlot = function(src, slot)
|
||||
local slotData = codem:GetItemBySlot(src, slot)
|
||||
-- The keys are not documented, so this is a best guess
|
||||
if not slotData then return {} end
|
||||
for _, v in pairs(slotData) do
|
||||
return {
|
||||
name = v.name,
|
||||
@@ -71,32 +75,10 @@ Inventory.GetItemBySlot = function(src, slot)
|
||||
description = v.description
|
||||
}
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
Inventory.GetPlayerInventory = function(src)
|
||||
local items = codem:GetInventory(nil, src)
|
||||
local repackedTable = {}
|
||||
for _, v in pairs(items) do
|
||||
table.insert(repackedTable, {
|
||||
name = v.name,
|
||||
count = v.amount,
|
||||
metadata = v.info,
|
||||
slot = v.slot,
|
||||
})
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||
codem:SetItemMetadata(src, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
||||
TriggerEvent('codem-inventory:server:openstash', id, slots, weight, label)
|
||||
end
|
||||
|
||||
Inventory.GetImagePath = function(item)
|
||||
local imagePath = string.format("nui://codem-inventory/html/images/%s.png", item)
|
||||
local file = LoadResourceFile("codem-inventory", string.format("html/images/%s.png", item))
|
||||
local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item)
|
||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||
end
|
||||
Reference in new issue
Block a user