Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- params ["_desk", "_player"]; // Receive the passed desk object
- _terminalType = typeOf _desk;
- private _arrows = nearestObjects [_desk, ["Sign_Arrow_Large_F"], 300];
- private _foundPad = false;
- _side = side _player;
- _playerUID = getPlayerUID _Player;
- _air = {
- while { !_foundPad } do {
- {
- _arrow = _x;
- private _vehicles = nearestObjects [_arrow, ["Car", "Helicopter", "Tank"], 10]; // Filter for helicopter type
- titleText ["<t color='#00CC00' size='1.5'>WAITING FOR PAD VACANCY</t><br/>", "PLAIN", -1, false, true];
- sleep 1;
- if (count _vehicles == 0) exitWith {
- titleText ["<t color='#00CC00' size='1.5'> </t><br/>", "PLAIN", -1, false, true];
- disableSerialization;
- uiNamespace setVariable [ "current_garage", _arrow ];
- _fullVersion = missionNamespace getVariable [ "BIS_fnc_arsenal_fullGarage", false ];
- if !( isNull ( uiNamespace getVariable [ "BIS_fnc_arsenal_cam", objNull ] ) ) exitWith { "Garage Viewer is already running" call bis_fnc_logFormat; };
- _veh = createVehicle ["Land_HelipadEmpty_F", _arrow, [], 0, "CAN_COLLIDE"];
- uiNamespace setVariable [ "garage_pad", _veh ];
- missionNamespace setVariable [ "BIS_fnc_arsenal_fullGarage", [ true, 0, false, [ false ] ] call bis_fnc_param ];
- with missionNamespace do { BIS_fnc_garage_center = [ true, 1, _veh, [ objNull ] ] call bis_fnc_param; };
- [ missionNamespace, "garageOpened", {
- params[ "_display", "_toggleSpace" ];
- missionNamespace setVariable [ "bis_fnc_garage_data", [
- [], // CARS
- [], // ARMOR
- [ // HELIS
- "\a3\air_f\heli\B_Heli_Light_01_dynamicLoadout_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Light_01_dynamicLoadout_F")],
- "\a3\air_f\heli\B_Heli_Light_01_stripped_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Light_01_stripped_F")],
- "\a3\air_f\heli\B_Heli_Transport_01_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Transport_01_F")],
- "\a3\air_f\heli\B_Heli_Transport_01_camo_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Transport_01_camo_F")],
- "\a3\air_f\heli\B_Heli_Transport_03_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_F")],
- "\a3\air_f\heli\B_Heli_Transport_03_unarmed_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_unarmed_F")],
- "\a3\air_f\heli\B_Heli_Transport_03_black_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_black_F")],
- "\a3\air_f\heli\B_Heli_Transport_03_unarmed_green_F",
- [(configFile >> "CfgVehicles" >> "B_Heli_Transport_03_unarmed_green_F")],
- "\a3\air_f\heli\B_CTRG_Heli_Transport_01_sand_F",
- [(configFile >> "CfgVehicles" >> "B_CTRG_Heli_Transport_01_sand_F")],
- "\a3\air_f\heli\B_CTRG_Heli_Transport_01_tropic_F",
- [(configFile >> "CfgVehicles" >> "B_CTRG_Heli_Transport_01_tropic_F")]
- ], // HELIS
- [], // PLANES
- [], // NAVAL
- [] // STATICS
- ]]; // End of variable assignment
- {
- lbClear ( _display displayctrl (960 + _forEachIndex));
- } forEach (missionNamespace getVariable ["bis_fnc_garage_data", []]);;
- missionNamespace setVariable [ "bis_fnc_garage_centerType", "\a3\air_f\heli\B_Heli_Light_01_dynamicLoadout_F" ];
- ["ListAdd",[_display]] call BIS_fnc_garage;
- }] call BIS_fnc_addScriptedEventHandler;
- with uiNamespace do {
- _displayMission = [] call ( uiNamespace getVariable "bis_fnc_displayMission" );
- if !( isNull findDisplay 312 ) then { _displayMission = findDisplay 312; };
- _displayMission createDisplay "RscDisplayGarage";
- uiNamespace setVariable [ "running_garage", true ];
- waitUntil { sleep 0.25; isNull ( uiNamespace getVariable [ "BIS_fnc_arsenal_cam", objNull ] ) };
- _marker = uiNamespace getVariable "current_garage";
- _pad = uiNamespace getVariable "garage_pad";
- deleteVehicle _pad;
- _veh_list = ( getPos _marker ) nearEntities 5;
- {
- _vehType = typeOf _x;
- _textures = getObjectTextures _x;
- deleteVehicle _x;
- sleep 0.5;
- _new_veh = createVehicle [ _vehType, getPos _marker, [], 0, "CAN_COLLIDE" ];
- _new_veh allowDamage false;
- _new_veh setPosATL [ ( position _new_veh select 0 ), ( position _new_veh select 1 ), 0.25 ];
- _vehDir = getDir _marker;
- _new_veh setDir _vehDir;
- private _entities = nearestObjects [_arrow, [], 10]; // Get all objects near _arrow
- private _vrSoldiers = _entities select {
- (typeOf _x == "B_Soldier_VR_F") ||
- (typeOf _x == "O_Soldier_VR_F") ||
- (typeOf _x == "I_Soldier_VR_F")
- };
- if (count _vrSoldiers > 0) then {
- { deleteVehicle _x; } forEach _vrSoldiers;
- };
- private _timeLimit = 10; // Set countdown time in seconds
- _playerUID = getPlayerUID _Player;
- [_new_veh, _timeLimit, _playerUID] spawn {
- params ["_newVeh", "_timeLimit", "_playerUID"];
- // Check if player is inside the vehicle before starting countdown
- private _isPlayerInVehicle = (vehicle player == _newVeh) && {getPlayerUID player == _playerUID};
- // If the player is already in the vehicle, skip countdown
- if (_isPlayerInVehicle) exitWith {};
- // Display countdown and cancellation message
- 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
- // Set up a variable to track if Escape has been pressed
- private _cancelled = false;
- // Add event handler to listen for Escape key
- private _escHandlerID = (findDisplay 46) displayAddEventHandler ["KeyDown", {
- params ["_display", "_key"];
- if (_key isEqualTo 1) then { // Key code 1 is Escape
- uiNamespace setVariable ["cancelGarageRequest", true];
- true // Exit from event handler
- } else {
- false
- };
- }];
- // Countdown loop
- for "_i" from _timeLimit to 1 step -1 do {
- // Check if Escape was pressed and cancel request
- if (uiNamespace getVariable ["cancelGarageRequest", false]) exitWith {
- // Cancel request, delete vehicle, and clear hint
- deleteVehicle _newVeh;
- hint parseText "<t valign='bottom'>Request Cancelled | Vehicle Stored</t>"; // Replace titleText with hint and add valign
- _cancelled = true;
- uiNamespace setVariable ["cancelGarageRequest", false]; // Reset variable
- };
- // Use the current countdown value _i instead of the fixed _timeLimit
- 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
- sleep 1;
- // If player enters vehicle during countdown, stop countdown
- if (vehicle player == _newVeh && getPlayerUID player == _playerUID) exitWith {};
- };
- // Clean up: remove event handler
- (findDisplay 46) displayRemoveEventHandler ["KeyDown", _escHandlerID];
- // Only proceed to vehicle check if not cancelled
- if (!_cancelled) then {
- // If player is not in vehicle, delete it
- if (!(vehicle player == _newVeh && getPlayerUID player == _playerUID)) then {
- deleteVehicle _newVeh;
- };
- // Clear the hint text after countdown
- hint parseText ""; // Replace titleText with hint and add valign
- };
- };
- _count = 0;
- {
- _new_veh setObjectTexture [ _count, _x ];
- _count = _count + 1;
- } forEach _textures;
- } forEach _veh_list;
- };
- _foundPad = true;
- };
- } forEach _arrows;
- sleep 1;
- };
- };
- // Evaluate the switch statement to decide on deployment function
- switch (_terminalType) do {
- case "Land_BriefingRoomDesk_01_F": { [_desk] call _air; }; // Calls air deployment function
- //case "Land_FlatTV_01_F": { [_desk] call _fn_ground; }; // Calls ground deployment function
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement