//unitAreasOnMap Script - made by Moerderhoschi v1.3 - 13.02.2015 0 = [ thisTrigger ] spawn { if (!isServer) exitWith {}; _startPosX = 0; _startPosY = 0; _endPosX = 1; _endPosY = 1; _refreshTime = if (count _this > 1) then {_this select 1} else {15}; _markerLifeTime = 0; _scriptStartTime = time; _scriptLifeTime = 0; _exitScript = false; _markerColor = if (count _this > 3) then {_this select 3} else {"red"}; _markers = []; _unitSide = "ANY"; _markerAlpha = if (count _this > 4) then {_this select 4} else {0.2}; _markerCorrectionX = if (count _this > 2) then {(_this select 2) select 0} else {0}; _markerCorrectionY = if (count _this > 2) then {(_this select 2) select 1} else {0}; if (typeName _refreshTime == "ARRAY") then { if (count _refreshTime > 2) then {_scriptLifeTime = _refreshTime select 2}; if (count _refreshTime > 1) then {_markerLifeTime = _refreshTime select 1}; _refreshTime = _refreshTime select 0; }; if (_refreshTime < 1) then {_refreshTime = 1}; if (_markerLifeTime > _refreshTime) then {_markerLifeTime = 0}; if (_markerAlpha < 0.1) then {_markerAlpha = 0.1}; if (typeName (_this select 0) == "ARRAY") then { _startPosX = (((_this select 0) select 0) select 0); _startPosY = (((_this select 0) select 0) select 1); _endPosX = _startPosX + (((_this select 0) select 1) select 0); _endPosY = _startPosY + (((_this select 0) select 1) select 1); _unitSide = if (count _this > 5) then {_this select 5} else {"ANY"}; } else { _startPosX = (((getpos (_this select 0)) select 0) - ((triggerArea (_this select 0)) select 0)); _startPosY = (((getpos (_this select 0)) select 1) - ((triggerArea (_this select 0)) select 1)); _endPosX = (((getpos (_this select 0)) select 0) + ((triggerArea (_this select 0)) select 0)); _endPosY = (((getpos (_this select 0)) select 1) + ((triggerArea (_this select 0)) select 1)); _unitSide = if (count _this > 5) then {_this select 5} else {(triggerActivation (_this select 0)) select 0}; }; if (!(typeName _unitSide == "SIDE")) then { if (typeName _unitSide == "STRING") then { _unitSide = toUpper _unitSide; switch (_unitSide) do { case "WEST": {_unitSide = west}; case "EAST": {_unitSide = east}; case "GUER": {_unitSide = resistance}; case "CIV": {_unitSide = civilian}; default {_unitSide = "ANY"}; } } else { _unitSide = "ANY" } }; _sideCheck = { if (typeName _unitSide == "SIDE") then {side _x == _unitSide} else {true} }; _sectorAdd = { _addSector = true; for "_i" from 0 to ((count _sectors) - 1) do { if ( _sectors select _i select 0 == _pos select 0 && _sectors select _i select 1 == _pos select 1 ) then { _addSector = false }; }; if (_addSector) then { _sectors = _sectors + [_pos]; }; }; while {true} do { _sectors = []; _markersDel = []; _markersKeep = []; if (typeName (_this select 0) == "ARRAY") then { { _pos = [(((floor(((getPos vehicle _x select 0)-_markerCorrectionX) / 100))*100)+50+_markerCorrectionX), (((floor(((getPos vehicle _x select 1)-_markerCorrectionY) / 100))*100)+50+_markerCorrectionY)]; if ( getPos vehicle _x select 0 <= _endPosX && getPos vehicle _x select 0 >= _startPosX && getPos vehicle _x select 1 <= _endPosY && getPos vehicle _x select 1 >= _startPosY && call _sideCheck ) then { call _sectorAdd }; } forEach allUnits; } else { { _pos = [(((floor(((getPos vehicle _x select 0)-_markerCorrectionX) / 100))*100)+50+_markerCorrectionX), (((floor(((getPos vehicle _x select 1)-_markerCorrectionY) / 100))*100)+50+_markerCorrectionY)]; if ( call _sideCheck && !(_x isKindOf "Animal") ) then { call _sectorAdd }; } forEach list (_this select 0); }; for "_i" from 0 to ((count _sectors)-1) do { _deleteFromCreationList = false; for "_i2" from 0 to ((count _markers)-1) do { if ( ((getMarkerPos (_markers select _i2)) select 0) == ((_sectors select _i) select 0) && ((getMarkerPos (_markers select _i2)) select 1) == ((_sectors select _i) select 1) ) then { _markersKeep = _markersKeep + [_markers select _i2]; _deleteFromCreationList = true; }; }; if (_deleteFromCreationList) then { _sectors set [_i,-1]; }; }; _sectors = _sectors - [-1]; _markersDel = _markers - _markersKeep; {deleteMarker _x} forEach _markersDel; _markers = _markers - _markersDel; { _mdh_unitAresOnMapMarker = createMarker [ "mdh_unitArasOnMapMarkerName_" + format ["%1_%2",time,random 1000], _x]; _markers = _markers + [_mdh_unitAresOnMapMarker]; _mdh_unitAresOnMapMarker setMarkerShape "RECTANGLE"; _mdh_unitAresOnMapMarker setMarkerSize [50, 50]; _mdh_unitAresOnMapMarker setMarkerAlpha _markerAlpha; _mdh_unitAresOnMapMarker setMarkerBrush "Solid"; _mdh_unitAresOnMapMarker setMarkerColor ("color" + _markerColor); } forEach _sectors; if (_scriptLifeTime > 0) then { if (time > (_scriptStartTime + _scriptLifeTime)) then { _exitScript = true; }; }; if (_exitScript) exitWith { {deleteMarker _x} forEach _markers; }; if (_markerLifeTime > 0) then { _mFactor = 100; _mAlphaSub = (_markerAlpha / _mFactor); _mFadeTime = (_markerLifeTime / _mFactor); for "_i" from 1 to _mFactor do { sleep _mFadeTime; {_x setMarkerAlpha ((markerAlpha _x) - _mAlphaSub) } forEach _markers; }; {deleteMarker _x} forEach _markers; _markers = []; sleep (_refreshTime - _markerLifeTime); } else { sleep _refreshTime; }; }; };