🔗Progressbar

Progressbar Functions

startProgressbar(data, callback)

Starts a progress bar and returns a completion status.

Parameters:

  • data.icon (string) The FontAwesome icon to display.

  • data.label (string) The text to display on the progress bar.

  • data.time (number) The duration of the progress bar in seconds.

  • data.animation (table) Animation configuration:

    • data.animation.dict (string): The animation dictionary.

    • data.animation.name (string): The animation name.

  • data.inputBlock (table) Input blocking configuration:

    • data.inputBlock.keys (table): A list of keys to block.

  • data.cancelable (boolean) Specifies whether the progress bar can be canceled by pressing X (default is true).

  • callback (function) A callback function that returns:

    • true if the progress bar completed successfully,

    • false if it was canceled.


cancelProgressbar()

Cancels the active progress bar and stops any associated animation.


Exports

This module exports two functions for use in other scripts:

exports["script_name"]:startProgressbar(data, function(isDone) ... end)

exports["script_name"]:cancelProgressbar()


Usage Example

RegisterCommand("testprogress", function(source, args, rawCommand)
    local data = {
        icon = "fa-solid fa-hammer",
        label = "Sample progress...",
        time = 5,
        animation = {
            dict = "amb@world_human_hammering@male@base",
            name = "base"
        },
        inputBlock = {
            keys = {"W", "A", "S", "D"}
        },
        cancelable = true
    }
    
    exports["KOJA_HUD"]:startProgressbar(data, function(isDone)
        if isDone then
            print("Progressbar completed successfully!")
        else
            print("Progressbar was canceled!")
        end
    end)
end, false)

Last updated