🔧Installation Progress
This page explains how to integrate the 'Sweepz_Ui_Elements' script's progress bar system into other systems.
File Location: qb-core/client/functions.lua
Line Number: 192
function QBCore.Functions.Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
if GetResourceState('Sweepz_Ui_Elements') ~= 'started' then error('Sweepz_Ui_Elements needs to be started in order for QBCore.Functions.Progressbar to work') end
exports['Sweepz_Ui_Elements']:Progress({
name = name:lower(),
duration = duration,
label = label,
useWhileDead = useWhileDead,
canCancel = canCancel,
controlDisables = disableControls,
animation = animation,
prop = prop,
propTwo = propTwo,
}, function(cancelled)
if not cancelled then
if onFinish then
onFinish()
end
else
if onCancel then
onCancel()
end
end
end)
endFile Location: es_extended/client/functions.lua
Line Number: 144
function ESX.Progressbar(message, length, options)
if GetResourceState('Sweepz_Ui_Elements') ~= 'started' then error('Sweepz_Ui_Elements needs to be started in order for QBCore.Functions.Progressbar to work') end
exports['Sweepz_Ui_Elements']:Progress({
name = "esx_progress_"..math.random(1000, 9999),
duration = length,
label = message,
useWhileDead = false,
canCancel = true,
controlDisables = options.FreezePlayer,
animation = options.animation,
prop = {},
propTwo = {},
}, function(cancelled)
if not cancelled then
if options.onFinish then
options.onFinish()
end
else
if options.onCancel then
options.onCancel()
end
end
end)
end
function ESX.CancelProgressbar()
TriggerEvent('progressbar:client:cancel')
endFile Location: ox_lib/resource/interface/client/progress.lua
Replace the entire file with the code we provided.
local progress
local DisableControlAction = DisableControlAction
local DisablePlayerFiring = DisablePlayerFiring
local playerState = LocalPlayer.state
---@class ProgressProps
---@field label? string
---@field duration number
---@field position? 'middle' | 'bottom'
---@field useWhileDead? boolean
---@field allowRagdoll? boolean
---@field allowCuffed? boolean
---@field allowFalling? boolean
---@field allowSwimming? boolean
---@field canCancel? boolean
---@field anim? { dict?: string, clip: string, flag?: number, blendIn?: number, blendOut?: number, duration?: number, playbackRate?: number, lockX?: boolean, lockY?: boolean, lockZ?: boolean, scenario?: string, playEnter?: boolean }
---@field prop? { model: string, bone?: number, pos: vector3, rot: vector3 }
---@field disable? { move?: boolean, sprint?: boolean, car?: boolean, combat?: boolean, mouse?: boolean }
local function convertPropsToSweepz(data)
local sweepzData = {
name = "ox_progress_"..math.random(1000, 9999),
duration = data.duration,
label = data.label,
useWhileDead = data.useWhileDead or false,
canCancel = data.canCancel or false,
controlDisables = {
disableMovement = data.disable and data.disable.move or false,
disableCarMovement = data.disable and data.disable.car or false,
disableMouse = data.disable and data.disable.mouse or false,
disableCombat = data.disable and data.disable.combat or false
}
}
if data.anim then
sweepzData.animation = {
animDict = data.anim.dict,
anim = data.anim.clip,
flags = data.anim.flag or 49
}
end
if data.prop then
sweepzData.prop = {
model = data.prop.model,
bone = data.prop.bone or 60309,
coords = data.prop.pos,
rotation = data.prop.rot
}
end
return sweepzData
end
---@param data ProgressProps
---@return boolean?
function lib.progressBar(data)
while progress ~= nil do Wait(0) end
local sweepzData = convertPropsToSweepz(data)
local completed = false
exports['Sweepz_Ui_Elements']:Progress(sweepzData, function(cancelled)
completed = not cancelled
progress = nil
end)
progress = true
while progress ~= nil do Wait(0) end
return completed
end
---@param data ProgressProps
---@return boolean?
function lib.progressCircle(data)
return lib.progressBar(data)
end
function lib.cancelProgress()
if not progress then
error('No progress bar is active')
end
TriggerEvent('progressbar:client:cancel')
progress = false
end
---@return boolean
function lib.progressActive()
return progress and true
endLast updated