Advertisement
dapperstache

fn_updateProgressBar.sqf

Dec 5th, 2024 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.19 KB | Gaming | 0 0
  1. [] spawn {
  2.     // Wait until the ScoreHUD is properly initialized
  3.     waitUntil {
  4.         private _scoreHUD = uiNamespace getVariable ["ScoreHUD", displayNull];
  5.         !isNull _scoreHUD
  6.     };
  7.  
  8.     // Retrieve the ScoreHUD display and progress bar control
  9.     private _scoreHUD = uiNamespace getVariable "ScoreHUD";
  10.     private _progressCtrl = _scoreHUD displayCtrl 1300;
  11.  
  12.     // Check if the progress bar control exists
  13.     if (!isNull _progressCtrl) then {
  14.         private _NUP_scoringInterval = missionNamespace getVariable ["NUP_scoringInterval", 25];
  15.         private _NUP_startTime = missionNamespace getVariable ["NUP_startTime", time];
  16.  
  17.         // Update the progress bar continuously
  18.         while {true} do {
  19.             private _elapsedTime = time - _NUP_startTime;
  20.             private _progress = (_elapsedTime / _NUP_scoringInterval) max 0 min 1; // Clamp progress to [0,1]
  21.  
  22.             // Update the progress bar's position
  23.             _progressCtrl progressSetPosition _progress;
  24.  
  25.             // Sleep for 0.1 seconds before updating again
  26.             sleep 0.1;
  27.         };
  28.     } else {
  29.         diag_log "Error: Progress bar control not found in ScoreHUD!";
  30.     };
  31. };
  32.  
Tags: arma SQF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement