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
|
end
|
||||||
|
|
||||||
Framework.GetPlayerIdentifier = function()
|
Framework.GetPlayerIdentifier = function()
|
||||||
return ESX.GetPlayerData().identifier
|
local playerData = ESX.GetPlayerData()
|
||||||
|
return playerData.identifier
|
||||||
end
|
end
|
||||||
|
|
||||||
Framework.GetPlayerName = function()
|
Framework.GetPlayerName = function()
|
||||||
@@ -40,11 +41,13 @@ Framework.HasItem = function(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Framework.GetPlayerInventory = function()
|
Framework.GetPlayerInventory = function()
|
||||||
return ESX.GetPlayerData().inventory
|
local playerData = ESX.GetPlayerData()
|
||||||
|
return playerData.inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
Framework.GetIsPlayerDead = function()
|
Framework.GetIsPlayerDead = function()
|
||||||
return ESX.GetPlayerData().dead
|
local playerData = ESX.GetPlayerData()
|
||||||
|
return playerData.dead
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
|
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ Framework.GetPlayerInventory = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
Framework.GetIsPlayerDead = function()
|
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
|
end
|
||||||
|
|
||||||
Framework.Shared = QBCore.Shared
|
Framework.Shared = QBCore.Shared
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ Framework.GetPlayerInventory = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
Framework.GetIsPlayerDead = function()
|
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
|
end
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ Inventory = Inventory or {}
|
|||||||
local codem = exports['codem-inventory']
|
local codem = exports['codem-inventory']
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = codem:GetItemList()
|
local itemData = codem:GetItemList(item)
|
||||||
if not itemData[item] then return {} end
|
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
label = itemData.label or "Missing Label",
|
label = itemData.label or "Missing Label",
|
||||||
@@ -14,12 +13,7 @@ Inventory.GetItemInfo = function(item)
|
|||||||
description = itemData.description or "none",
|
description = itemData.description or "none",
|
||||||
image = itemData.image or Inventory.GetImagePath(item),
|
image = itemData.image or Inventory.GetImagePath(item),
|
||||||
}
|
}
|
||||||
return repackedTable
|
return repackedTable or {}
|
||||||
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"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function()
|
Inventory.GetPlayerInventory = function()
|
||||||
@@ -39,3 +33,9 @@ Inventory.GetPlayerInventory = function()
|
|||||||
end
|
end
|
||||||
return items
|
return items
|
||||||
end
|
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
|
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
local codem = exports['codem-inventory']
|
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
local codem = exports['codem-inventory']
|
||||||
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
|
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = codem:GetItemList()
|
local itemData = codem:GetItemList(item)
|
||||||
if not itemData[item] then return {} end
|
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
label = itemData.label or "Missing Label",
|
label = itemData.label or "Missing Label",
|
||||||
@@ -38,27 +14,55 @@ Inventory.GetItemInfo = function(item)
|
|||||||
description = itemData.description or "none",
|
description = itemData.description or "none",
|
||||||
image = itemData.image or Inventory.GetImagePath(item),
|
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
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
if metadata == nil then
|
if not slot and metadata then
|
||||||
return codem:GetItemsTotalAmount(src, item)
|
local inv = Inventory.GetPlayerInventory(src)
|
||||||
else
|
if not inv then return false end
|
||||||
local count = 0
|
for _, v in pairs(inv) do
|
||||||
local items = codem:GetInventory(nil, src)
|
if v.name == item and v.metadata == metadata then
|
||||||
for _, itemInfo in pairs(items) do
|
slot = v.slot
|
||||||
if itemInfo.name == item and itemInfo.info == metadata then
|
break
|
||||||
count = count + itemInfo.amount
|
|
||||||
end
|
end
|
||||||
return count
|
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
Inventory.GetItemBySlot = function(src, slot)
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
local slotData = codem:GetItemBySlot(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
|
for _, v in pairs(slotData) do
|
||||||
return {
|
return {
|
||||||
name = v.name,
|
name = v.name,
|
||||||
@@ -71,32 +75,10 @@ Inventory.GetItemBySlot = function(src, slot)
|
|||||||
description = v.description
|
description = v.description
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
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"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user