> For the complete documentation index, see [llms.txt](https://ak-scripts.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ak-scripts.gitbook.io/docs/yi-lai/markdown/ti-huan-kuang-jia-mo-ren-zhi/ox/jin-du-tiao-progress.md).

# 进度条（Progress）

### ⚙️ 如何更改 ox\_lib 的默认进度条 <a href="#ru-he-geng-gai-esx-de-mo-ren-tong-zhi" id="ru-he-geng-gai-esx-de-mo-ren-tong-zhi"></a>

> 本节将教你如何将 `ox_lib` **默认进度条** 替换为 `ak-lib` **进度条**。
>
> 由于 `ox_lib` 不同版本在函数结构上略有差异，本次示例基于 `ox_lib` `3.31.4` 进行讲解

### 🧭 步骤一：打开文本脚本文件

导航到以下路径：

```
ox_lib/resource/interface/client/progress.lua
```

***

### 🧩 步骤二：替换 ox\_lib 整个进度条函数内容

```lua
local isFivem = cache and cache.game == 'fivem'

local function mapPosition(pos)
    if pos == 'middle' then return 'middle-center' end
    if pos == 'bottom' then return 'bottom-center' end
    return pos
end

function lib.progressBar(data)
    local ak = exports['ak-lib']:Progress({
        label       = data and data.label,
        duration    = data and data.duration,
        position    = data and mapPosition(data.position),
        style       = 'bar',
        anim        = data and data.anim,
        prop        = data and data.prop,
        disable     = data and data.disable,
        canCancel   = data and data.canCancel,
        useWhileDead= data and data.useWhileDead,
        allowRagdoll= data and data.allowRagdoll,
        allowCuffed = data and data.allowCuffed,
        allowFalling= data and data.allowFalling,
        allowSwimming= data and data.allowSwimming,
    })
    return ak
end

function lib.progressCircle(data)
    local ak = exports['ak-lib']:Progress({
        label       = data and data.label,
        duration    = data and data.duration,
        position    = data and mapPosition(data.position),
        style       = 'circle',
        anim        = data and data.anim,
        prop        = data and data.prop,
        disable     = data and data.disable,
        canCancel   = data and data.canCancel,
        useWhileDead= data and data.useWhileDead,
        allowRagdoll= data and data.allowRagdoll,
        allowCuffed = data and data.allowCuffed,
        allowFalling= data and data.allowFalling,
        allowSwimming= data and data.allowSwimming,
    })
    return ak
end

function lib.cancelProgress()
    local active, pdata = exports['ak-lib']:IsProgressActive()
    if not active then error('No progress bar is active') end
    if pdata and pdata.canCancel then
        exports['ak-lib']:StopProgress('cancel')
    end
end

function lib.progressActive()
    local active = exports['ak-lib']:IsProgressActive()
    return active and true or false
end

RegisterCommand('cancelprogress', function()
    local active, pdata = exports['ak-lib']:IsProgressActive()
    if active and pdata and pdata.canCancel then
        exports['ak-lib']:StopProgress('cancel')
    end
end)

if isFivem then
    RegisterKeyMapping('cancelprogress', locale('cancel_progress') or 'Cancel progress', 'keyboard', 'x')
end
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://ak-scripts.gitbook.io/docs/yi-lai/markdown/ti-huan-kuang-jia-mo-ren-zhi/ox/jin-du-tiao-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.
