FiveM Docs
Core Resources

esx_progressbar

esx_progressbar reference for ESX Legacy. Show timed progress bars with animations, freeze, onFinish and onCancel via ESX.Progressbar or the export.

esx_progressbar shows a timed progress bar at the bottom of the screen, with an optional animation or scenario and an optional player freeze. Use it for actions that take time, such as lockpicking, crafting or searching a trash bin. Call it from client code with ESX.Progressbar.

Overview

Resourceesx_progressbar
SideClient only
Dependenciesesx_lib and es_extended (both loaded via imports, not listed as manifest dependencies)
ConfigNone
RequiredYes if any script calls ESX.Progressbar; es_extended errors when it is missing

Functions

ESX.Progressbar

local started = ESX.Progressbar(message, length, options)
NameTypeDescription
messagestring?Text on the bar. Default "ESX-Framework". Supports color codes such as ~g~.
lengthnumber?Duration in milliseconds. Default 3000.
optionstable?See the options table below.

Returns boolean: true when the bar started, false when another bar is already running.

Options

FieldTypeDescription
FreezePlayerboolean?Freezes the player ped until the bar finishes or is canceled.
animationtable?Animation to play, see below.
onFinishfunction?Called when the bar completes.
onCancelfunction?Called when the bar is canceled.

animation has two forms:

FieldFormDescription
typeboth"anim" or "Scenario" (capital S, case-sensitive).
dictanimAnimation dictionary. Loaded through xLib.streaming.requestAnimDict.
libanimAnimation name inside the dictionary.
ScenarioScenarioScenario name, e.g. "PROP_HUMAN_BUM_BIN" (capital S).
client/main.lua
local function searchTrash()
    local started = ESX.Progressbar("Searching the trash...", 5000, {
        FreezePlayer = true,
        animation = {
            type = "Scenario",
            Scenario = "PROP_HUMAN_BUM_BIN",
        },
        onFinish = function()
            TriggerServerEvent("my_trash:searched")
        end,
        onCancel = function()
            ESX.ShowNotification("You stopped searching.", "info")
        end,
    })

    if not started then
        ESX.ShowNotification("You are already busy.", "error")
    end
end

Animation example:

client/main.lua
ESX.Progressbar("Unlocking storage", 3000, {
    FreezePlayer = true,
    animation = {
        type = "anim",
        dict = "anim@mp_player_intmenu@key_fob@",
        lib = "fob_click",
    },
    onFinish = function()
        TriggerServerEvent("my_storage:open")
    end,
})

ESX.CancelProgressbar

Cancels the active bar: closes the UI, clears the ped tasks, unfreezes the player and calls onCancel. Does nothing when no bar is active.

ESX.CancelProgressbar()

Use it when the player dies, gets into a vehicle or leaves the area:

client/main.lua
AddEventHandler("esx:onPlayerDeath", function()
    ESX.CancelProgressbar()
end)

Exports

The ESX functions are thin wrappers around these exports.

ExportSignature
Progressbarexports["esx_progressbar"]:Progressbar(message, length, options) returns boolean
CancelProgressbarexports["esx_progressbar"]:CancelProgressbar()

Controls

Key mappingDefaultAction
[ProgressBar] Cancel ProgressbarBackspaceCancels the active bar

Players can rebind it in Settings → Key Bindings → FiveM. The key is registered with xLib.addKeybind.

Common issues

  • Animation stops before the bar ends. The animation plays with the bar length as its duration and flag 1 (loop). If your animation still stops, another script is clearing the ped tasks.
  • Players skip timed actions. Every bar can be canceled with Backspace, and a modified client can call onFinish early. Never rely on the bar for timing on the server; check elapsed time server-side.
  • Scenario does not play. Use type = "Scenario" and the key Scenario with a capital S. "scenario" in lowercase is ignored.
  • ESX.Progressbar returns false. A bar is still running. Check the return value and tell the player they are busy, or cancel the old bar first.

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.
Edit on GitHub

Last updated on

On this page