Advertisement
Guest User

Untitled

a guest
Mar 13th, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1.  
  2. //NUP\NUP_flagCapture\functions\fn_initFlag.sqf
  3.  
  4. if !( isServer ) exitWith {};
  5.  
  6. params
  7. [
  8. [ "_logic", objNull, [ objNull ] ],
  9. [ "_markerSize", [ 10, 10 ], [ [] ], 2 ],
  10. [ "_startingSide", sideUnknown, [ sideUnknown ] ]
  11. ];
  12.  
  13. // Find the triggers synchronized to the logic entity that spawns the flag
  14.  
  15. // Create a temporary variable for each synchronized object and store them as strings in _rawAllSynced array
  16. _rawAllSynced = [];
  17. {
  18. _rawAllSynced pushBack str _x;
  19. } forEach synchronizedObjects _logic;
  20.  
  21. // Step 2: Filter _rawAllSynced for partial string matches with "OBR_repair" and store any matches as text entries in _rawRepair
  22. _rawRepair = [];
  23. {
  24. if (toLower _x find "obr_repair" >= 0) then {
  25. _rawRepair pushBack _x;
  26. };
  27. } forEach _rawAllSynced;
  28.  
  29. // Step 3: Sort through _rawRepair using missionNamespace getVariable to get the actual object
  30. _repairTriggers = [];
  31. {
  32. _repairTriggers pushBack (missionNamespace getVariable _x);
  33. } forEach _rawRepair;
  34.  
  35. // Display the filtered repair triggers in the log
  36. diag_log format["Repair Triggers: %1", _repairTriggers];
  37. // Iterate through _repairTriggers and log the type of each element
  38. {
  39. diag_log format ["Type of element: %1", typeName _x];
  40. } forEach _repairTriggers;
  41.  
  42.  
  43.  
  44. //Make sure parameters are valid
  45. if ( isNull _logic || { !( _logic isKindOf "Logic" ) } ) exitWith{ [ "Invalid Flag given" ] call BIS_fnc_error };
  46. if ( { _x isEqualType 0 }count _markerSize isNotEqualTo 2 ) exitWith{ [ "MarkerSize array must contain Numbers" ] call BIS_fnc_error };
  47. if !( _startingSide in [ east, west, independent, civilian, sideUnknown ] ) exitWith{ [ "Invalid Flag Side given" ] call BIS_fnc_error };
  48.  
  49. //Spawn Flag
  50. _flag = createVehicle[ "PortableFlagPole_01_F", getPosATL _logic, [], 0, "CAN_COLLIDE" ];
  51. _flag setVariable ["TER_flagName", format ["flagPole_%1", _flagID], true];
  52. _flag allowDamage false;
  53.  
  54.  
  55. // Check if _repairTriggers is an array
  56. {
  57. _flag synchronizeObjectsAdd [_x];
  58. } forEach _repairTriggers;
  59. // Log synchronized objects to _flagPole
  60.  
  61. diag_log format ["Triggers Synced: %1", _synchronizedFlagPoleObjects];
  62.  
  63.  
  64. //Spawn Marker
  65. _marker = createMarker[ format[ "flagMarker_%1", _flag call BIS_fnc_netId ], getPosATL _logic ];
  66. _marker setMarkerShape "ELLIPSE";
  67. _marker setMarkerSize _markerSize;
  68. _marker setMarkerDir 0;
  69. _marker setMarkerBrush "Solid";
  70. _marker setMarkerColor "ColorGrey";
  71. _marker setMarkerAlpha 1;
  72.  
  73. //Set defaults
  74. _flag setVariable[ "NUP_flagMarker", _marker, true ];
  75. [ _flag, _startingSide, true ] call NUP_fnc_captureFlag;
  76.  
  77. //Get any flag supplies
  78. [ _logic, _flag ] call NUP_fnc_getFlagSupplies;
  79.  
  80. //Add flags holdAction
  81. [ _flag ] remoteExec [ "NUP_fnc_addFlagHoldAction", [ 0, -2 ] select isDedicated, true ];
  82.  
  83.  
  84.  
  85.  
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement