Inventory Update
Added serverside iteminfo and consolidated image path. Now returns full nui path in .image
This commit is contained in:
1 parent
5d3a9d1950
commit
bd0074a156
22 files changed
+82
-8
No files matched your search
@@ -5,7 +5,7 @@ if GetResourceState('qbx_core') == 'started' then return end
|
|||||||
QBCore = exports['qb-core']:GetCoreObject()
|
QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
Framework.Shared = QBCore.Shared
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
return 'qb-core'
|
return 'qb-core'
|
||||||
end
|
end
|
||||||
@@ -222,7 +222,9 @@ Framework.AddHunger = function(src, value)
|
|||||||
local playerData = player.PlayerData
|
local playerData = player.PlayerData
|
||||||
local newHunger = (playerData.metadata.hunger or 0) + value
|
local newHunger = (playerData.metadata.hunger or 0) + value
|
||||||
player.Functions.SetMetaData('hunger', Math.Clamp(newHunger, 0, 100))
|
player.Functions.SetMetaData('hunger', Math.Clamp(newHunger, 0, 100))
|
||||||
|
TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, playerData.metadata.thirst)
|
||||||
--TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
--TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||||
|
|
||||||
return newHunger
|
return newHunger
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -235,6 +237,7 @@ Framework.AddThirst = function(src, value)
|
|||||||
local playerData = player.PlayerData
|
local playerData = player.PlayerData
|
||||||
local newThirst = (playerData.metadata.thirst or 0) + value
|
local newThirst = (playerData.metadata.thirst or 0) + value
|
||||||
player.Functions.SetMetaData('thirst', Math.Clamp(newThirst, 0, 100))
|
player.Functions.SetMetaData('thirst', Math.Clamp(newThirst, 0, 100))
|
||||||
|
TriggerClientEvent('hud:client:UpdateNeeds', src, playerData.metadata.hunger, newThirst)
|
||||||
--TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
--TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||||
return newThirst
|
return newThirst
|
||||||
end
|
end
|
||||||
@@ -412,8 +415,8 @@ Framework.SetMetadata = function(src, item, slot, metadata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
player.Functions.RemoveItem(item, 1, itemSlot)
|
if not player.Functions.RemoveItem(item, 1, itemSlot) then return false end
|
||||||
return player.Functions.AddItem(item, 1, freeSlot, metadata)
|
return player.Functions.AddItem(item, 1, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will get all owned vehicles for the player
|
---This will get all owned vehicles for the player
|
||||||
@@ -461,3 +464,4 @@ Framework.Commands = {}
|
|||||||
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,3 +27,10 @@ end
|
|||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
return "https://avatars.githubusercontent.com/u/47620135"
|
return "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.StripPNG = function(item)
|
||||||
|
if string.find(item, ".png") then
|
||||||
|
item = string.gsub(item, ".png", "")
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end
|
||||||
@@ -84,3 +84,10 @@ end
|
|||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
return "https://avatars.githubusercontent.com/u/47620135"
|
return "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.StripPNG = function(item)
|
||||||
|
if string.find(item, ".png") then
|
||||||
|
item = string.gsub(item, ".png", "")
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end
|
||||||
@@ -8,13 +8,14 @@ local codem = exports['codem-inventory']
|
|||||||
---@return table
|
---@return table
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = codem:GetItemList(item)
|
local itemData = codem:GetItemList(item)
|
||||||
|
local image = itemData.image and Inventory.GetImagePath(itemData.image) or Inventory.GetImagePath(item)
|
||||||
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",
|
||||||
stack = itemData.unique or "false",
|
stack = itemData.unique or "false",
|
||||||
weight = itemData.weight or "0",
|
weight = itemData.weight or "0",
|
||||||
description = itemData.description or "none",
|
description = itemData.description or "none",
|
||||||
image = itemData.image or Inventory.GetImagePath(item),
|
image = image,
|
||||||
}
|
}
|
||||||
return repackedTable or {}
|
return repackedTable or {}
|
||||||
end
|
end
|
||||||
@@ -43,6 +44,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("codem-inventory", string.format("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)
|
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"
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ Inventory.GetItemBySlot = function(src, slot)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("codem-inventory", string.format("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)
|
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"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ Inventory = Inventory or {}
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local core = exports.core_inventory
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ Inventory.SetMetadata = function(src, item, slot, metadata)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
|
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
|
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -16,6 +16,24 @@ Inventory.AddItem = function(src, item, count, slot, metadata)
|
|||||||
return ox_inventory:AddItem(src, item, count, metadata)
|
return ox_inventory:AddItem(src, item, count, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemInfo = function(item)
|
||||||
|
local itemData = ox_inventory:Items(item)
|
||||||
|
if not itemData then return {} end
|
||||||
|
local repackedTable = {
|
||||||
|
name = itemData.name or "Missing Name",
|
||||||
|
label = itemData.label or "Missing Label",
|
||||||
|
stack = itemData.stack or "true",
|
||||||
|
weight = itemData.weight or "0",
|
||||||
|
description = itemData.description or "none",
|
||||||
|
image = string.format("nui://ox_inventory/web/images/%s", itemData.client
|
||||||
|
and itemData.client.image
|
||||||
|
or string.format("%s.png", item)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
return repackedTable
|
||||||
|
end
|
||||||
|
-- string.format("nui://ox_inventory/web/images/%s.png", item)
|
||||||
|
|
||||||
---This will remove an item, and return true or false based on success
|
---This will remove an item, and return true or false based on success
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param item string
|
---@param item string
|
||||||
@@ -148,6 +166,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
|
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
|
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
@@ -35,7 +36,7 @@ Inventory.GetItemInfo = function(item)
|
|||||||
stack = itemData.unique,
|
stack = itemData.unique,
|
||||||
weight = itemData.weight,
|
weight = itemData.weight,
|
||||||
description = itemData.description,
|
description = itemData.description,
|
||||||
image = Inventory.GetImagePath(itemData.name)
|
image = Inventory.GetImagePath(itemData.image or itemData.name)
|
||||||
}
|
}
|
||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,10 +40,26 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Inventory.GetItemInfo = function(item)
|
||||||
|
local itemData = Framework.Shared.Items[item]
|
||||||
|
if not itemData then return {} end
|
||||||
|
local repackedTable = {
|
||||||
|
name = itemData.name,
|
||||||
|
label = itemData.label,
|
||||||
|
stack = itemData.unique,
|
||||||
|
weight = itemData.weight,
|
||||||
|
description = itemData.description,
|
||||||
|
image = Inventory.GetImagePath(itemData.image or itemData.name)
|
||||||
|
}
|
||||||
|
return repackedTable
|
||||||
|
end
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
-- check if contains.png and remove it if it does
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
|
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
|
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
|
||||||
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
|
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
|
||||||
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
|
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
item = Inventory.StripPNG(item)
|
||||||
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
|
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
|
||||||
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
|
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
|
||||||
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
|
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
|
||||||
|
|||||||
@@ -44,15 +44,19 @@ end
|
|||||||
---@param options table
|
---@param options table
|
||||||
---@param cb any
|
---@param cb any
|
||||||
---@param qbFormat boolean
|
---@param qbFormat boolean
|
||||||
---@return nil
|
---@return success boolean
|
||||||
function ProgressBar.Open(options, cb, qbFormat)
|
function ProgressBar.Open(options, cb, qbFormat)
|
||||||
if not exports['progressbar'] then return false end
|
if not exports['progressbar'] then return false end
|
||||||
|
|
||||||
if not qbFormat then
|
if not qbFormat then
|
||||||
options = convertFromOx(options)
|
options = convertFromOx(options)
|
||||||
end
|
end
|
||||||
|
local prom = promise.new()
|
||||||
exports['progressbar']:Progress(options, cb)
|
exports['progressbar']:Progress(options, function(cancelled)
|
||||||
|
if cb then cb(not cancelled) end
|
||||||
|
prom:resolve(not cancelled)
|
||||||
|
end)
|
||||||
|
return Citizen.Await(prom)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user