Files
community_bridge/modules/progressbar/qb-progressbar/client.lua
T

87 lines
2.5 KiB
Lua
Raw Normal View History

2025-03-04 22:42:35 -05:00
local resourceName = "progressbar"
local configValue = BridgeClientConfig.ProgressBarSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
2025-02-21 11:02:18 -06:00
ProgressBar = ProgressBar or {}
local function convertFromOx(options)
if not options then return options end
2025-02-24 17:14:55 -05:00
local prop1 = options.prop?[1] or options.prop or {}
local prop2 = options.prop?[2] or {}
2025-02-21 11:02:18 -06:00
return {
name = options.label,
duration = options.duration,
label = options.label,
useWhileDead = options.useWhileDead,
canCancel = options.canCancel,
controlDisables = {
disableMovement = options.disable?.move,
disableCarMovement = options.disable?.car,
disableMouse = options.disable?.mouse,
disableCombat = options.disable?.combat
},
animation = {
animDict = options.anim?.dict,
2025-04-13 12:49:35 +01:00
anim = options.anim?.clip,
flags = 49
2025-02-21 11:02:18 -06:00
},
2025-02-22 06:42:11 -06:00
prop = {
model = prop1.model,
bone = prop1.bone,
coords = prop1.pos,
rotation = prop1.rot
},
propTwo = {
model = prop2.model,
bone = prop2.bone,
coords = prop2.pos,
rotation = prop2.rot
}
2025-02-21 11:02:18 -06:00
}
end
2025-03-03 01:37:29 -05:00
---comment
---@param options table
---@param cb any
---@param qbFormat boolean
2025-04-16 05:24:03 -05:00
---@return success boolean
2025-04-28 10:31:14 -04:00
---@diagnostic disable-next-line: duplicate-set-field
2025-02-21 11:02:18 -06:00
function ProgressBar.Open(options, cb, qbFormat)
if not exports['progressbar'] then return false end
2025-03-03 01:37:29 -05:00
2025-02-21 11:02:18 -06:00
if not qbFormat then
options = convertFromOx(options)
end
2025-04-16 05:24:03 -05:00
local prom = promise.new()
exports['progressbar']:Progress(options, function(cancelled)
if cb then cb(not cancelled) end
prom:resolve(not cancelled)
end)
return Citizen.Await(prom)
end
2025-02-21 11:02:18 -06:00
-- Example usage:
2025-03-03 01:37:29 -05:00
--[[
2025-02-21 11:02:18 -06:00
RegisterCommand("progressbar", function()
ProgressBar.Open({
duration = 5000,
label = "Searching",
disable = {
move = true,
combat = true
},
anim = {
dict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
clip = "machinic_loop_mechandplayer"
2025-02-22 06:42:11 -06:00
},
prop = {
model = "prop_ar_arrow_3",
pos = vector3(0.0, 0.0, 0.0),
rot = vector3(0.0, 0.0, 0.0)
},
2025-02-21 11:02:18 -06:00
}, function(cancelled)
print(cancelled and "Cancelled" or "Complete")
end)
end)
2025-04-13 12:49:35 +01:00
--]]