Boerstil 8 Posted October 24, 2016 I'm working on a Artillery script. I want the artillery to fire if someone on the same side has spotted a playableUnit. This is what I've got so far. Is there a more efficient way to do this? if (!isServer) exitWith {}; private ["_veh","_side","_ammo"]; _veh = _this select 0; _side = side _veh; _ammo = getArtilleryAmmo [_veh] select 0; _veh setVariable ["Target",nil]; [_veh,_side,_ammo] spawn { params ["_veh","_side","_ammo"]; private ["_spotter","_targetPos"]; while {true} do { { if ((side _x) == _side) then { _spotter = _x; }; { if ((_spotter knowsAbout _x) > 1.5) then { _targetPos = ((_spotter targetKnowledge _x) select 6); hint format ["%1 has ben spotted at %2",(name _x),_targetPos]; _veh setVariable ["Target",_targetPos]; }, { _veh setVariable ["Target",nil]; }; } forEach playableUnits; } forEach AllUnits; sleep 5; }; }; [_veh,_side,_ammo] spawn { params ["_veh","_side","_ammo"]; private ["_spotter","_targetPos"]; while {true} do { if (!isNil {_veh getVariable "Target"}) then { if((_veh getVariable "Target") inRangeOfArtillery [[_veh], _ammo]) then { hint format ["%1 Is Ready To Fire At %2",(name _veh),(_veh getVariable "Target")]; sleep 60; }; }; sleep 5; }; }; Share this post Link to post Share on other sites