StartProgress

The SD.StartProgress function is designed to manage and display progress bars.

Overview

Purpose: Initiates a progress bar using the most suitable method determined by the game's current setup, such as the available libraries or the active gaming framework.

Selecting the Progress Bar Method

The function utilizes a helper function, ProgressBar, which selects the appropriate method for displaying progress bars based on the environment:

  • Library Check: If a specific library (lib) is available, it uses lib.progressBar.

  • Framework Check: If the lib is not available, it checks the active game framework (Framework), which could be either 'esx' or 'qb', and selects the respective framework's progress bar implementation.

  • Fallback: If no library or framework method is applicable, it returns a fallback function that throws an error, indicating that no progress bar method is configured.

Parameters

  • identifier (string): A unique identifier for the progress instance.

  • label (string): A description label for the progress bar.

  • duration (number): The duration (in milliseconds) for which the progress should be tracked.

  • completed (function): A callback function that executes upon successful completion of the progress.

  • notfinished (function): A callback function that executes if the progress does not complete (e.g., if cancelled or fails).

Usage Example

RegisterNetEvent('sd-oilrig:client:SellBarrel', function(data)
  SD.StartProgress('selling', locale('progress.selling'), 6000,
  function()
    TriggerServerEvent('sd-oilrig:server:SellBarrel', data)
  end, function() -- Cancel
       -- notfinished function
  end)
  
end)

Last updated