Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Title: NUP_fnc_loadSuppies
- //File: NUP\NUP_flagCapture\functions\fn_loadSuppies.sqf
- //Author: Dapperstache
- //Purpose: Stores a value in a param in the"Supply Truck", indicating whether or not it is loaded.
- //Usage: [ _veh, _trigger ] call NUP_fnc_loadSuppies;
- params ["_veh", "_trigger"];
- // Ensure the vehicle hasn't already loaded supplies
- if ((_veh getVariable ["NUP_SuppliesLoaded", 0]) != 1) then {
- params ["_veh", "_trigger"];
- private _driver = driver _veh;
- _damage = damage _veh;
- if (_damage > 0.01) exitWith {[["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'>SUPPLY VEHICLE DAMAGED. VISIT VEHICLE SERVICE BAY.</t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];};
- // Configurable time for service cooldown (in seconds)
- private _serviceCooldownTime = 120; // 2 minutes (change this to adjust cooldown time)
- // Get the last service time, defaulting to -1 if not set
- private _lastServiceTime = _veh getVariable ["NUP_lastServiceTime", -1]; // Use -1 to signify no prior service
- // Get the current server time
- private _currentTime = serverTime;
- if (speed _veh > 0) then {
- [["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'>COME TO A COMPLETE STOP AND DISABLE ENGINE</t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];
- if (_driver != driver _veh) exitWith {[["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'> </t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];};
- };
- if (_driver != driver _veh) exitWith {[["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'> </t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];};
- waitUntil {speed _veh == 0};
- if (speed _veh == 0 && (isEngineOn _veh)) then {
- [["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'>DISABLE ENGINE TO BEGIN LOADING SUPPLIES</t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];
- if (_driver != driver _veh) exitWith {[["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'> </t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];};
- };
- if (_driver != driver _veh) exitWith {[["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'> </t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];};
- waitUntil {!(isEngineOn _veh)};
- if (_driver != driver _veh) exitWith {[["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'> </t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];};
- [["<t font='PuristaMedium' shadow='2' color='#00ff00' size='1.5'> </t><br/>", "PLAIN", -1, true, true]] remoteExec ["titleText", owner _driver];
- // Show cinematic border and loading text
- [0, 1, true, false] remoteExec ["NUP_fnc_cinematicBorder", owner _driver];
- ["FD_Course_Active_F"] remoteExec ["playSound", owner _driver];
- _veh engineOn false;
- _veh addEventHandler ["Engine", { params ["_vehicle","_engineState"]; if (_engineState == true) then { _vehicle engineOn false}; }];
- // Create the progress bar dynamically
- ["progressBarRsc", "PLAIN"] call BIS_fnc_rscLayer;
- private _display = findDisplay 46; // Fetch the newly created display (46 is the ID of "RscDisplayEmpty")
- // Create the text above the progress bar
- private _progressTextCtrl = _display ctrlCreate ["RscText", 123457];
- _progressTextCtrl ctrlSetPosition [0.3, 0.56, 0.4, 0.03]; // Position the text above the bar
- _progressTextCtrl ctrlSetText "LOADING SUPPLIES..."; // Set the text
- _progressTextCtrl ctrlSetTextColor [0, 1, 0, 1];
- _progressTextCtrl ctrlSetFont "PuristaMedium";
- _progressTextCtrl ctrlCommit 0;
- private _progressBarCtrlBG = _display ctrlCreate ["RscProgress", 123455];
- private _progressBarCtrl = _display ctrlCreate ["RscProgress", 123456];
- _progressBarCtrlBG ctrlSetPosition [0.3, 0.60, 0.4, 0.03]; // [x, y, width, height]
- _progressBarCtrl ctrlSetPosition [0.3, 0.60, 0.4, 0.03]; // [x, y, width, height]
- _progressBarCtrlBG ctrlSetTextColor [0, 0, 0, 1];
- _progressBarCtrlBG ctrlSetBackgroundColor [0, 0, 0, 1];
- _progressBarCtrl ctrlSetBackgroundColor [0, 0, 0, 1];
- _progressBarCtrlBG ctrlCommit 0;
- _progressBarCtrl ctrlCommit 0;
- _progressBarCtrlBG progressSetPosition 100;
- _progressBarCtrl progressSetPosition 0;
- private _totalTime = 5; // Total loading time in seconds
- private _updateInterval = 0.003; // Progress bar update interval in seconds
- private _progress = 0;
- //attach Supply boxes to truck for visual reference
- // Create crates
- private _crate1 = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "NONE"];
- _crate1 allowDamage false;
- private _crate2 = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "NONE"];
- _crate2 allowDamage false;
- private _crate3 = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "NONE"];
- _crate3 allowDamage false;
- // Simulate loading with progress bar
- for "_i" from 0 to (_totalTime / _updateInterval) do {
- _progress = _i * (_updateInterval / _totalTime);
- _progressBarCtrl progressSetPosition _progress;
- if (_progress >= .33 && _progress <= 0.34) then {_crate1 attachTo [_veh, [0, 0, 0.2], "", false];};
- if (_progress >= .66 && _progress <= 0.67) then {_crate2 attachTo [_veh, [0, -1.5, 0.2], "", false];};
- if (_progress >= .99 && _progress <= 1.00) then {_crate3 attachTo [_veh, [0, -3.0, 0.2], "", false];};
- // Front crate
- sleep _updateInterval;
- };
- _veh setVariable ["NUP_vehCrates", [_crate1, _crate2, _crate3]];
- _progressBarCtrl progressSetPosition 0;
- _progressBarCtrlBG progressSetPosition 0;
- // Mark the vehicle as loaded
- _veh setVariable ["NUP_SuppliesLoaded", 1, true];
- //hint format ["Supplies Loaded Status: %1", _veh getVariable "NUP_SuppliesLoaded"];
- ["FD_Finish_F"] remoteExec ["playSound", owner _driver];
- _veh removeAllEventHandlers "Engine";
- _veh engineOn true;
- _barGate = nearestObject [_trigger, "Land_BarGate_01_open_F"];
- _barGate animateSource ["Door_1_source", 1];
- [_barGate] spawn {
- params ["_barGate"];
- sleep 20;
- _barGate animateSource ["Door_1_source", 0];
- };
- _progressTextCtrl ctrlSetText "SUPPLIES LOADED";
- // Remove cinematic border
- [1, 1, true, false] remoteExec ["NUP_fnc_cinematicBorder", owner _driver];
- _progressTextCtrl ctrlSetTextColor [0, 1, 0, 0];
- sleep 1.5;
- if (true) exitWith {};
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement