# Installation Progress

{% tabs %}
{% tab title="QBCore" %}

* File Location: qb-core/client/functions.lua
* Line Number: 192

```lua
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)
end
```

{% endtab %}

{% tab title="ESX" %}

* File Location: es\_extended/client/functions.lua
* Line Number: 144

```lua
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')
end
```

{% endtab %}

{% tab title="Ox\_Lib" %}

* File Location: ox\_lib/resource/interface/client/progress.lua
* Replace the entire file with the code we provided.

```lua
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
end
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sweepz-shop.gitbook.io/docs/scripts/sweepz-ui-elements/installation-progress.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
