Advertisement
dapperstache

fn_initSafezone.sqf

May 10th, 2024 (edited)
671
0
169 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 8.36 KB | Gaming | 0 0
  1. //NUP\NUP_flagCapture\functions\NUP_fnc_initSafezone.sqf
  2.  
  3.  
  4. if !(isServer) exitWith {};
  5.  
  6. // Check if sidesArray already exists and initialize if not
  7. if (isNil "sidesArray") then {
  8.     sidesArray = [East, West, Civilian, Independent];
  9. };
  10.  
  11. // Ensure there are sides in the array before proceeding
  12. if !(count sidesArray > 0) exitWith {};
  13.  
  14. params
  15. [
  16.     ["_logic", objNull, [objNull]],
  17.     ["_markerSize", [250, 140], [[]], 2]
  18. ];
  19.  
  20. // Randomly select a side
  21. _side = sidesArray call BIS_fnc_selectRandom;
  22. diag_log format ["_side: %1", _side];
  23.  
  24. _flagSide = "Flag_White_F";
  25. _szMarkerColor = "ColorBlack";
  26. _spawnName = "HQ";
  27.  
  28. // Define flag color based on side
  29. switch (_side) do
  30. {
  31.     case east:
  32.     {
  33.         _flagSide = "Flag_Red_F";
  34.         _szMarkerColor = "ColorOPFOR";
  35.         _spawnName = "Opfor HQ";
  36.     };
  37.     case west:
  38.     {
  39.         _flagSide = "Flag_Blue_F";
  40.         _szMarkerColor = "ColorBLUFOR";
  41.         _spawnName = "Blufor HQ";
  42.     };
  43.     case civilian:
  44.     {
  45.         _flagSide = "Flag_FD_Purple_F";
  46.         _szMarkerColor = "ColorCivilian";
  47.         _spawnName = "Civilian HQ";
  48.     };
  49.     case independent:
  50.     {
  51.         _flagSide = "Flag_Green_F";
  52.         _szMarkerColor = "ColorIndependent";
  53.         _spawnName = "Indepdendent HQ";
  54.     };
  55. };
  56.  
  57. // Create safezone marker
  58. _safezoneMarker = createMarker [format ["safezoneMarker_%1", _side], getPosATL _logic];
  59. _safezoneMarker setMarkerShape "ELLIPSE";
  60. _safezoneMarker setMarkerSize _markerSize;
  61. _safezoneMarker setMarkerDir 0;
  62. _safezoneMarker setMarkerBrush "Solid";
  63. _safezoneMarker setMarkerColor "colorBlack";
  64. _safezoneMarker setMarkerAlpha 0.85;
  65.  
  66. // Create respawn marker
  67. _respawnMarker = createMarker [format ["respawn_%1", _side], getPosATL _logic];
  68. _respawnMarker setMarkerType "b_hq";
  69. _respawnMarker setMarkersize [1, 1];
  70. _respawnMarker setMarkerAlpha 1;
  71. _respawnMarker setMarkerColor _szMarkerColor;
  72. _respawnMarker setMarkerText format ["%1",_spawnName];
  73.  
  74. // Spawn flag
  75. _flag = createVehicle[_flagSide, getPosATL _logic, [], 0, "CAN_COLLIDE"];
  76. _flag allowDamage false;
  77. _flag setVariable[ "NUP_respawnMarker", _respawnMarker, true ];
  78. _flag setVariable[ "NUP_safezoneMarker", _safezoneMarker, true ];
  79.  
  80. // Remove selected side from the array
  81. sidesArray = sidesArray - [_side];
  82.  
  83. // Debugging
  84. diag_log str allMapMarkers;
  85. diag_log format ["_logic: %1", _logic];
  86.  
  87. _baseEntry1 = objNull;
  88. _baseEntry2 = objNull;
  89. _baseExit1 = objNull;
  90. _baseExit2 = objNull;
  91.  
  92.  
  93. //Initialize Elevators
  94. _syncedobjs = synchronizedObjects _logic;
  95. {
  96.     if (toLower str _x find "base_exit_1_" == 0) then
  97.     {
  98.         _baseExit1 = _x;
  99.     }
  100. } forEach _syncedobjs;
  101.  
  102. _syncedobjs = synchronizedObjects _logic;
  103. {
  104.     if (toLower str _x find "base_exit_2" == 0) then
  105.     {
  106.         _baseExit2 = _x;
  107.     }
  108. } forEach _syncedobjs;
  109.  
  110. _syncedobjs = synchronizedObjects _logic;
  111. {
  112.     if (toLower str _x find "base_entry_1" == 0) then
  113.     {
  114.         _baseEntry1 = _x;
  115.     }
  116. } forEach _syncedobjs;
  117.  
  118. _syncedobjs = synchronizedObjects _logic;
  119. {
  120.     if (toLower str _x find "base_entry_2" == 0) then
  121.     {
  122.         _baseEntry2 = _x;
  123.     }
  124. } forEach _syncedobjs;
  125.  
  126. // Log the names of the objects assigned to variables
  127. diag_log format["logic instance: %1", _logic];
  128. diag_log format["_baseExit1: %1", _baseExit1];
  129. diag_log format["_baseExit1 position: %1", getPosATL _baseExit1];
  130. diag_log format["_baseExit2: %1", _baseExit2];
  131. diag_log format["_baseExit2 position: %1", getPosATL _baseExit2];
  132. diag_log format["_baseEntry1: %1", _baseEntry1];
  133. diag_log format["_baseEntry1 position: %1", getPosATL _baseEntry1];
  134. diag_log format["_baseEntry2: %1", _baseEntry2];
  135. diag_log format["_baseEntry2 position: %1", getPosATL _baseEntry2];
  136.  
  137. [
  138.     params ["_baseExit1", "_baseEntry1"];
  139.     _baseExit1, // Object the action is attached to
  140.     "Exit to Helipads", // Title of the action
  141.     "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff2_ca.paa", // Icon Idle
  142.     "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff2_ca.paa", // Icon Progress
  143.     "_this distance player < 1", // Condition for the action to be shown
  144.     "_this distance player < 1", // Condition for the action to progress
  145.     {}, // Code executed when action starts (leave blank)
  146.     {}, // Code executed on every progress tick (leave blank)
  147.     {
  148.         [0, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  149.         sleep 0.5;
  150.         player setPosATL (getPosATL _baseEntry2);
  151.         [1, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  152.     }, // Code executed on completion
  153.     {}, // Code executed on interruption (leave blank)
  154.     [], // Arguments passed to the scripts as _this select 3 (empty array)
  155.     6, // Action duration in seconds
  156.     0, // Priority
  157.     false, // Remove on completion
  158.     false // Show in unconscious state
  159. ] remoteExec ["BIS_fnc_holdActionAdd", 0, _baseExit1]; // MP-compatible implementation
  160.  
  161. [
  162.     params ["_baseExit2", "_baseEntry2"];
  163.     _baseExit2, // Object the action is attached to
  164.     "Exit to Vehicle Lot", // Title of the action
  165.     "\a3\Missions_F_Orange\Data\Img\Showcase_LawsOfWar\action_exit_CA.paa", // Icon Idle
  166.     "\a3\Missions_F_Orange\Data\Img\Showcase_LawsOfWar\action_exit_CA.paa", // Icon Progress
  167.     "_this distance player < 1", // Condition for the action to be shown
  168.     "_this distance player < 1", // Condition for the action to progress
  169.     {}, // Code executed when action starts (leave blank)
  170.     {}, // Code executed on every progress tick (leave blank)
  171.     {
  172.         [0, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  173.         sleep 0.5;
  174.        
  175.         player setPosATL (getPosATL _baseEntry2);
  176.         [1, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  177.     }, // Code executed on completion
  178.     {}, // Code executed on interruption (leave blank)
  179.     [], // Arguments passed to the scripts as _this select 3 (empty array)
  180.     6, // Action duration in seconds
  181.     0, // Priority
  182.     false, // Remove on completion
  183.     false // Show in unconscious state
  184. ] remoteExec ["BIS_fnc_holdActionAdd", 0, _baseExit2]; // MP-compatible implementation
  185.  
  186. [
  187.     params ["_baseEntry1", "_baseExit1"];
  188.     _baseEntry1, // Object the action is attached to
  189.     "", // Title of the action
  190.     "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff1_ca.paa", // Icon Idle
  191.     "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff1_ca.paa", // Icon Progress
  192.     "_this distance player < 1", // Condition for the action to be shown
  193.     "_this distance player < 1", // Condition for the action to progress
  194.     {}, // Code executed when action starts (leave blank)
  195.     {}, // Code executed on every progress tick (leave blank)
  196.     {
  197.         [0, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  198.         sleep 0.5;
  199.        
  200.         // Set the player position to the new position
  201.         player setPosATL (getPosATL _baseExit1);
  202.         [1, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  203.     }, // Code executed on completion
  204.     {}, // Code executed on interruption (leave blank)
  205.     [], // Arguments passed to the scripts as _this select 3 (empty array)
  206.     6, // Action duration in seconds
  207.     0, // Priority
  208.     false, // Remove on completion
  209.     false // Show in unconscious state
  210. ] remoteExec ["BIS_fnc_holdActionAdd", 0, _baseEntry1]; // MP-compatible implementation
  211.  
  212. [
  213.     params ["_baseEntry2", "_baseExit2"];
  214.     _baseEntry2, // Object the action is attached to
  215.     "Enter Base", // Title of the action
  216.     "\a3\Missions_F_Orange\Data\Img\Showcase_LawsOfWar\action_exit_CA.paa", // Icon Idle
  217.     "\a3\Missions_F_Orange\Data\Img\Showcase_LawsOfWar\action_exit_CA.paa", // Icon Progress
  218.     "_this distance player < 1", // Condition for the action to be shown
  219.     "_this distance player < 1", // Condition for the action to progress
  220.     {}, // Code executed when action starts (leave blank)
  221.     {}, // Code executed on every progress tick (leave blank)
  222.     {
  223.         [0, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  224.         sleep 0.5;
  225.         // Set the player position to the new position
  226.         player setPosATL (getPosATL _baseEexit2);
  227.         [1, "BLACK", 1, 1] spawn BIS_fnc_fadeEffect;
  228.     }, // Code executed on completion
  229.     {}, // Code executed on interruption (leave blank)
  230.     [], // Arguments passed to the scripts as _this select 3 (empty array)
  231.     6, // Action duration in seconds
  232.     0, // Priority
  233.     false, // Remove on completion
  234.     false // Show in unconscious state
  235. ] remoteExec ["BIS_fnc_holdActionAdd", 0, _baseEntry2]; // MP-compatible implementation
  236.  
  237.  
Tags: arma
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement