Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define the repair function
- params ["_veh", "_thistrigger"];
- [_veh, _thistrigger] spawn {
- _veh = _this select 0;
- _thistrigger = _this select 1;
- // Get the last repair time from the player's vehicle
- _lastRepairTime = player getVariable ["lastRepairTime", 0];
- // Get the timeout value from the player
- _timeOut = player getVariable ["repairTimeout", 0];
- _elapsedTime=0;
- // If the timeout value is 0 (unset), set it to 0 initially to allow repairs
- if (_timeOut == 0) then {
- _timeOut = 0;
- };
- // Initialize remaining time to 0 initially
- _remainingTime = 0;
- // Check if the player has already repaired and calculate the remaining time accordingly
- if (_lastRepairTime > 0) then {
- // Calculate the time elapsed since the last repair
- _elapsedTime = time - _lastRepairTime;
- // Calculate the remaining time until the next repair is available
- _remainingTime = _timeOut - _elapsedTime;
- // Check if remaining time is less than or equal to 0
- if (_remainingTime <= 0) then {
- // Reset remaining time to 0
- _remainingTime = 0;
- };
- };
- /// Check if the remaining time is less than or equal to 0, indicating that the player can repair
- if (_remainingTime > 0 && (vehicle _veh inArea _thisTrigger)) then {
- // Display a silent hint with the remaining time until the player can repair again
- while {_remainingTime > 0} do {
- // Recalculate remaining time until the next repair is available
- _elapsedTime = time - _lastRepairTime;
- _remainingTime = _timeOut - _elapsedTime;
- // Display the updated silent hint
- _hint = format["Vehicle Service Lockout: %1", [(_remainingTime / 60) + 0.01, "HH:MM"] call BIS_fnc_timetostring];
- hintSilent _hint;
- // Wait for 1 second before checking again
- sleep 1;
- // Check if the player has left the trigger area
- if !(vehicle _veh inArea _thisTrigger) exitWith { hintSilent ""; };
- };
- };
- // Get vehicle damage, fuel level, and ammo
- _vehicleDamage = damage _veh;
- _vehicleFuel = fuel _veh;
- // Check if the vehicle needs repair
- if (_vehicleDamage >= 0.90 && _vehicleFuel >= 0.90) exitWith {};
- // Monitor conditions and initiate repair process
- while {true} do {
- // Recalculate remaining time until the next repair is available
- if (_lastRepairTime > 0) then {
- // Calculate the time elapsed since the last repair
- _elapsedTime = time - _lastRepairTime;
- // Calculate the remaining time until the next repair is available
- _remainingTime = _timeOut - _elapsedTime;
- // Check if remaining time is less than or equal to 0
- if (_remainingTime <= 0) then {
- // Reset remaining time to 0
- _remainingTime = 0;
- }
- };
- if (driver _veh == player && !(isEngineOn _veh) && vehicle player == _veh && _veh inArea _thisTrigger) then {
- // Check if repair service is available
- if (_remainingTime <= 0) then {
- // Call the cinematic border function to activate it
- [0, 1, true, false] call NUP_fnc_cinematicBorder;
- // Disable user input during repair
- //disableUserInput true;
- // Display repair messages
- titleText ["<t color='#00ff00' size='2'>Initializing vehicle services, please wait...</t><br/>", "PLAIN", -1, true, true];
- sleep 3.5;
- titleText ["<t color='#00ff00' size='2'>Assessing vehicle for damages...</t><br/>", "PLAIN", -1, true, true];
- sleep 1.5;
- titleText ["<t color='#00ff00' size='2'>Assessing any vehicle armaments...</t><br/>", "PLAIN", -1, true, true];
- sleep 1.5;
- titleText ["<t color='#00ff00' size='2'>Assessing vehicle fuel level...</t><br/>", "PLAIN", -1, true, true];
- sleep 1.5;
- titleText ["<t color='#00ff00' size='2'>Repairing vehicle... 25% Complete.</t><br/>", "PLAIN", -1, true, true];
- sleep 3;
- titleText ["<t color='#00ff00' size='2'>Repairing vehicle... 50% Complete.</t><br/>", "PLAIN", -1, true, true];
- sleep 3;
- titleText ["<t color='#00ff00' size='2'>Repairing vehicle... 75% Complete.</t><br/>", "PLAIN", -1, true, true];
- sleep 3;
- titleText ["<t color='#00ff00' size='2'>Repairing vehicle... 99% Complete.</t><br/>", "PLAIN", -1, true, true];
- sleep 3;
- _veh setDamage 0;
- _veh setVehicleAmmo 1;
- _veh setFuel 1;
- ["A3\Sounds_F\sfx\blip1.wss", 0.3] remoteExec ["playSoundUI", player];
- titleText ["<t color='#00ff00' size='2'>Vehicle service complete.</t><br/>", "PLAIN", -1, true, true];
- } else {
- // Display lockout message
- hintSilent format["Vehicle Service Lockout: %1", [(_remainingTime / 60) + 0.01, "HH:MM"] call BIS_fnc_timetostring];
- };
- // Re-enable user input after repair
- //disableUserInput false;
- // Call the cinematic border function to deactivate it
- [1, 1, true, false] call NUP_fnc_cinematicBorder;
- // Store the current time as the last repair time
- player setVariable ["lastRepairTime", time, true];
- // Set the repair timeout to 2 minutes after the first repair
- if (_timeOut == 0) then {
- player setVariable ["repairTimeout", 25, true]; // Set timeout to 2 minutes (2 * 60 seconds)
- };
- // Clear any messages
- hintSilent "";
- break; // Exit the loop once service is complete
- } else {
- if (driver _veh == player && (isEngineOn _veh) && vehicle player == _veh && (_veh inArea _thisTrigger) && (_remainingTime <= 0)) then
- {
- // Display lockout message if repair service is not available
- titleText ["<t color='#FFA500' size='2'>Disable engine to initiate vehicle services.</t><br/>", "PLAIN", -1, true, true];
- };
- };
- sleep 1; // Check conditions every second
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement