Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NUP\NUP_flagCapture\functions\fn_initFlag.sqf
- if !( isServer ) exitWith {};
- params
- [
- [ "_logic", objNull, [ objNull ] ],
- [ "_markerSize", [ 10, 10 ], [ [] ], 2 ],
- [ "_startingSide", sideUnknown, [ sideUnknown ] ]
- ];
- // Find the triggers synchronized to the logic entity that spawns the flag
- // Create a temporary variable for each synchronized object and store them as strings in _rawAllSynced array
- _rawAllSynced = [];
- {
- _rawAllSynced pushBack str _x;
- } forEach synchronizedObjects _logic;
- // Step 2: Filter _rawAllSynced for partial string matches with "OBR_repair" and store any matches as text entries in _rawRepair
- _rawRepair = [];
- {
- if (toLower _x find "obr_repair" >= 0) then {
- _rawRepair pushBack _x;
- };
- } forEach _rawAllSynced;
- // Step 3: Sort through _rawRepair using missionNamespace getVariable to get the actual object
- _repairTriggers = [];
- {
- _repairTriggers pushBack (missionNamespace getVariable _x);
- } forEach _rawRepair;
- // Display the filtered repair triggers in the log
- diag_log format["Repair Triggers: %1", _repairTriggers];
- // Iterate through _repairTriggers and log the type of each element
- {
- diag_log format ["Type of element: %1", typeName _x];
- } forEach _repairTriggers;
- //Make sure parameters are valid
- if ( isNull _logic || { !( _logic isKindOf "Logic" ) } ) exitWith{ [ "Invalid Flag given" ] call BIS_fnc_error };
- if ( { _x isEqualType 0 }count _markerSize isNotEqualTo 2 ) exitWith{ [ "MarkerSize array must contain Numbers" ] call BIS_fnc_error };
- if !( _startingSide in [ east, west, independent, civilian, sideUnknown ] ) exitWith{ [ "Invalid Flag Side given" ] call BIS_fnc_error };
- //Spawn Flag
- _flag = createVehicle[ "PortableFlagPole_01_F", getPosATL _logic, [], 0, "CAN_COLLIDE" ];
- _flag setVariable ["TER_flagName", format ["flagPole_%1", _flagID], true];
- _flag allowDamage false;
- // Check if _repairTriggers is an array
- {
- _flag synchronizeObjectsAdd [_x];
- } forEach _repairTriggers;
- // Log synchronized objects to _flagPole
- diag_log format ["Triggers Synced: %1", _synchronizedFlagPoleObjects];
- //Spawn Marker
- _marker = createMarker[ format[ "flagMarker_%1", _flag call BIS_fnc_netId ], getPosATL _logic ];
- _marker setMarkerShape "ELLIPSE";
- _marker setMarkerSize _markerSize;
- _marker setMarkerDir 0;
- _marker setMarkerBrush "Solid";
- _marker setMarkerColor "ColorGrey";
- _marker setMarkerAlpha 1;
- //Set defaults
- _flag setVariable[ "NUP_flagMarker", _marker, true ];
- [ _flag, _startingSide, true ] call NUP_fnc_captureFlag;
- //Get any flag supplies
- [ _logic, _flag ] call NUP_fnc_getFlagSupplies;
- //Add flags holdAction
- [ _flag ] remoteExec [ "NUP_fnc_addFlagHoldAction", [ 0, -2 ] select isDedicated, true ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement