Advertisement
dapperstache

fn_virtualGarageDeploy.sqf

Nov 8th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.69 KB | None | 0 0
  1. params ["_desk", "_player"]; // Receive the passed desk object
  2. _terminalType = typeOf _desk;
  3.  
  4. private _arrows = nearestObjects [_desk, ["Sign_Arrow_Large_F"], 300];
  5. private _foundPad = false;
  6. _side = side _player;
  7. _playerUID = getPlayerUID _Player;
  8.  
  9. _air = {
  10. while { !_foundPad } do {
  11. {
  12. _arrow = _x;
  13. private _vehicles = nearestObjects [_arrow, ["Car", "Helicopter", "Tank"], 10]; // Filter for helicopter type
  14. titleText ["<t color='#00CC00' size='1.5'>WAITING FOR PAD VACANCY</t><br/>", "PLAIN", -1, false, true];
  15. sleep 1;
  16.  
  17. if (count _vehicles == 0) exitWith {
  18.  
  19. titleText ["<t color='#00CC00' size='1.5'> </t><br/>", "PLAIN", -1, false, true];
  20. disableSerialization;
  21. uiNamespace setVariable [ "current_garage", _arrow ];
  22. _fullVersion = missionNamespace getVariable [ "BIS_fnc_arsenal_fullGarage", false ];
  23. if !( isNull ( uiNamespace getVariable [ "BIS_fnc_arsenal_cam", objNull ] ) ) exitWith { "Garage Viewer is already running" call bis_fnc_logFormat; };
  24. _veh = createVehicle ["Land_HelipadEmpty_F", _arrow, [], 0, "CAN_COLLIDE"];
  25. uiNamespace setVariable [ "garage_pad", _veh ];
  26. missionNamespace setVariable [ "BIS_fnc_arsenal_fullGarage", [ true, 0, false, [ false ] ] call bis_fnc_param ];
  27. with missionNamespace do { BIS_fnc_garage_center = [ true, 1, _veh, [ objNull ] ] call bis_fnc_param; };
  28. [ missionNamespace, "garageOpened", {
  29. params[ "_display", "_toggleSpace" ];
  30. missionNamespace setVariable [ "bis_fnc_garage_data", [
  31. [], // CARS
  32. [], // ARMOR
  33. [ // HELIS
  34. "\a3\air_f\heli\B_Heli_Light_01_dynamicLoadout_F",
  35. [(configFile >> "CfgVehicles" >> "B_Heli_Light_01_dynamicLoadout_F")],
  36. "\a3\air_f\heli\B_Heli_Light_01_stripped_F",
  37. [(configFile >> "CfgVehicles" >> "B_Heli_Light_01_stripped_F")],
  38. "\a3\air_f\heli\B_Heli_Transport_01_F",
  39. [(configFile >> "CfgVehicles" >> "B_Heli_Transport_01_F")],
  40. "\a3\air_f\heli\B_Heli_Transport_01_camo_F",
  41. [(configFile >> "CfgVehicles" >> "B_Heli_Transport_01_camo_F")],
  42. "\a3\air_f\heli\B_Heli_Transport_03_F",
  43. [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_F")],
  44. "\a3\air_f\heli\B_Heli_Transport_03_unarmed_F",
  45. [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_unarmed_F")],
  46. "\a3\air_f\heli\B_Heli_Transport_03_black_F",
  47. [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_black_F")],
  48. "\a3\air_f\heli\B_Heli_Transport_03_unarmed_green_F",
  49. [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_unarmed_green_F")],
  50. "\a3\air_f\heli\B_CTRG_Heli_Transport_01_sand_F",
  51. [(configFile >> "CfgVehicles" >> "B_CTRG_Heli_Transport_01_sand_F")],
  52. "\a3\air_f\heli\B_CTRG_Heli_Transport_01_tropic_F",
  53. [(configFile >> "CfgVehicles" >> "B_CTRG_Heli_Transport_01_tropic_F")]
  54. ], // HELIS
  55. [], // PLANES
  56. [], // NAVAL
  57. [] // STATICS
  58. ]]; // End of variable assignment
  59.  
  60. {
  61. lbClear ( _display displayctrl (960 + _forEachIndex));
  62. } forEach (missionNamespace getVariable ["bis_fnc_garage_data", []]);;
  63.  
  64. missionNamespace setVariable [ "bis_fnc_garage_centerType", "\a3\air_f\heli\B_Heli_Light_01_dynamicLoadout_F" ];
  65.  
  66. ["ListAdd",[_display]] call BIS_fnc_garage;
  67.  
  68. }] call BIS_fnc_addScriptedEventHandler;
  69.  
  70. with uiNamespace do {
  71. _displayMission = [] call ( uiNamespace getVariable "bis_fnc_displayMission" );
  72. if !( isNull findDisplay 312 ) then { _displayMission = findDisplay 312; };
  73. _displayMission createDisplay "RscDisplayGarage";
  74. uiNamespace setVariable [ "running_garage", true ];
  75. waitUntil { sleep 0.25; isNull ( uiNamespace getVariable [ "BIS_fnc_arsenal_cam", objNull ] ) };
  76. _marker = uiNamespace getVariable "current_garage";
  77. _pad = uiNamespace getVariable "garage_pad";
  78. deleteVehicle _pad;
  79. _veh_list = ( getPos _marker ) nearEntities 5;
  80. {
  81. _vehType = typeOf _x;
  82. _textures = getObjectTextures _x;
  83.  
  84. deleteVehicle _x;
  85. sleep 0.5;
  86. _new_veh = createVehicle [ _vehType, getPos _marker, [], 0, "CAN_COLLIDE" ];
  87. _new_veh allowDamage false;
  88. _new_veh setPosATL [ ( position _new_veh select 0 ), ( position _new_veh select 1 ), 0.25 ];
  89. _vehDir = getDir _marker;
  90. _new_veh setDir _vehDir;
  91. private _entities = nearestObjects [_arrow, [], 10]; // Get all objects near _arrow
  92. private _vrSoldiers = _entities select {
  93. (typeOf _x == "B_Soldier_VR_F") ||
  94. (typeOf _x == "O_Soldier_VR_F") ||
  95. (typeOf _x == "I_Soldier_VR_F")
  96. };
  97.  
  98. if (count _vrSoldiers > 0) then {
  99. { deleteVehicle _x; } forEach _vrSoldiers;
  100. };
  101.  
  102. private _timeLimit = 10; // Set countdown time in seconds
  103. _playerUID = getPlayerUID _Player;
  104.  
  105. [_new_veh, _timeLimit, _playerUID] spawn {
  106. params ["_newVeh", "_timeLimit", "_playerUID"];
  107.  
  108. // Check if player is inside the vehicle before starting countdown
  109. private _isPlayerInVehicle = (vehicle player == _newVeh) && {getPlayerUID player == _playerUID};
  110.  
  111. // If the player is already in the vehicle, skip countdown
  112. if (_isPlayerInVehicle) exitWith {};
  113.  
  114. // Display countdown and cancellation message
  115. hint parseText format ["<t color='#FFFFFF' size='1.5' valign='bottom'>Storing vehicle in: %1 seconds. Press Esc to cancel request.</t>", _timeLimit]; // Replace titleText with hint and add valign
  116.  
  117. // Set up a variable to track if Escape has been pressed
  118. private _cancelled = false;
  119.  
  120. // Add event handler to listen for Escape key
  121. private _escHandlerID = (findDisplay 46) displayAddEventHandler ["KeyDown", {
  122. params ["_display", "_key"];
  123.  
  124. if (_key isEqualTo 1) then { // Key code 1 is Escape
  125. uiNamespace setVariable ["cancelGarageRequest", true];
  126. true // Exit from event handler
  127. } else {
  128. false
  129. };
  130. }];
  131.  
  132. // Countdown loop
  133. for "_i" from _timeLimit to 1 step -1 do {
  134. // Check if Escape was pressed and cancel request
  135. if (uiNamespace getVariable ["cancelGarageRequest", false]) exitWith {
  136. // Cancel request, delete vehicle, and clear hint
  137. deleteVehicle _newVeh;
  138. hint parseText "<t valign='bottom'>Request Cancelled | Vehicle Stored</t>"; // Replace titleText with hint and add valign
  139. _cancelled = true;
  140. uiNamespace setVariable ["cancelGarageRequest", false]; // Reset variable
  141. };
  142.  
  143. // Use the current countdown value _i instead of the fixed _timeLimit
  144. hint parseText format ["<t color='#FFFFFF' size='2' valign='bottom'>Storing vehicle in: %1 seconds. Press Esc to cancel request.</t>", _i]; // Replace titleText with hint and add valign
  145. sleep 1;
  146.  
  147. // If player enters vehicle during countdown, stop countdown
  148. if (vehicle player == _newVeh && getPlayerUID player == _playerUID) exitWith {};
  149. };
  150.  
  151. // Clean up: remove event handler
  152. (findDisplay 46) displayRemoveEventHandler ["KeyDown", _escHandlerID];
  153.  
  154. // Only proceed to vehicle check if not cancelled
  155. if (!_cancelled) then {
  156. // If player is not in vehicle, delete it
  157. if (!(vehicle player == _newVeh && getPlayerUID player == _playerUID)) then {
  158. deleteVehicle _newVeh;
  159. };
  160.  
  161. // Clear the hint text after countdown
  162. hint parseText ""; // Replace titleText with hint and add valign
  163. };
  164. };
  165.  
  166. _count = 0;
  167.  
  168. {
  169. _new_veh setObjectTexture [ _count, _x ];
  170. _count = _count + 1;
  171. } forEach _textures;
  172.  
  173. } forEach _veh_list;
  174. };
  175. _foundPad = true;
  176. };
  177. } forEach _arrows;
  178.  
  179. sleep 1;
  180.  
  181. };
  182. };
  183.  
  184. // Evaluate the switch statement to decide on deployment function
  185. switch (_terminalType) do {
  186. case "Land_BriefingRoomDesk_01_F": { [_desk] call _air; }; // Calls air deployment function
  187. //case "Land_FlatTV_01_F": { [_desk] call _fn_ground; }; // Calls ground deployment function
  188. };
  189.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement