# progressbar

## Progressbar

<figure><img src="https://share.lvsoft.com.ar/images/KW9tq.jpg" alt=""><figcaption></figcaption></figure>

***

### How to use:

Client side using exports

**Example:**

```lua
exports.lvs_lib:Progress({
   name = "random_task",
   duration = 5000,
   label = "Doing something",
   useWhileDead = false,
   canCancel = true,
   controlDisables = {
       disableMovement = false,
       disableCarMovement = false,
       disableMouse = false,
       disableCombat = true,
   },
   animation = {
       animDict = "mp_suicide",
       anim = "pill",
       flags = 49,
   },
   prop = {},
   propTwo = {}
}, function(cancelled)
   if not cancelled then
       -- finished
   else
       -- cancelled
   end
end)
```

**Props Example:**

```lua
exports.lvs_lib:Progress({
   name = "random_task",
   duration = 5000,
   label = "Doing something",
   useWhileDead = false,
   canCancel = true,
   controlDisables = {
       disableMovement = false,
       disableCarMovement = false,
       disableMouse = false,
       disableCombat = true,
   },
   animation = {
       animDict = "missheistdockssetup1clipboard@base",
       anim = "pill",
       flags = 49,
   },
   prop = {
     model = 'prop_notepad_01',
     bone = 18905,
     coords = vec3(0.1, 0.02, 0.05),
     rotation = vec3(10.0, 0.0, 0.0),
     rotOrder = 1
   },
   propTwo = {
     model = 'prop_pencil_01',
     bone = 58866,
     coords = vec3(0.11, -0.02, 0.001),
     rotation = vec3(-120.0, 0.0, 0.0),
   }
}, function(cancelled)
   if not cancelled then
       -- finished
   else
       -- cancelled
   end
end)
```

***

<details>

<summary>isDoingSomething()</summary>

```lua
-- Returns a boolean (true/false) depending on if a progressbar is present.

local busy = exports.lvs_lib:isDoingSomething()
```

</details>

<details>

<summary>ProgressWithStartEvent(<strong>data</strong>: table, <strong>start</strong>: function, <strong>finish</strong>: function)</summary>

```lua
-- Works like a normal progressbar, the data parameter should be the same as the data passed into the Progress export above.
-- The start function gets triggered upon the start of the progressbar.
-- The finish handler is the same as the handler parameter in the Progress export above.
```

</details>

<details>

<summary>ProgressWithTickEvent(<strong>data</strong>: table, <strong>tick</strong>: function, <strong>finish</strong>: function)</summary>

```lua
-- Works like a normal progressbar, the data parameter should be the same as the data passed into the Progress export above.
-- The tick function gets triggered every frame while the progressbar is active.
-- The finish handler is the same as the handler parameter in the Progress export above.
```

</details>

<details>

<summary>ProgressWithTickEvent(<strong>data</strong>: table, <strong>start</strong>: function, <strong>tick</strong>: function, <strong>finish</strong>: function)</summary>

```lua
-- Works like a normal progressbar, the data parameter should be the same as the data passed into the Progress export above.
-- The start function gets triggered upon the start of the progressbar.
-- The tick function gets triggered every frame while the progressbar is active.
-- The finish handler is the same as the handler parameter in the Progress export above.
```

</details>

***

### QBCore Integration:

Edit `qb-core/client/functions.lua`, replace the function <mark style="background-color:green;">QBCore.Functions.Progressbar</mark>(line 121) with:

```lua
function QBCore.Functions.Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
    exports.lvs_lib: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
```


---

# 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://fivem.lvsoft.com.ar/qb-esx/lvs-lib/progressbar.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.
