mattsmith94 10 Posted March 29, 2016 Is there a way of extending the range of the fired near event handler. I am looking to be able to detect a firer with in the range of up to 1km minimum. Thanks in advance Share this post Link to post Share on other sites
mattsmith94 10 Posted March 29, 2016 this addEventHandler ["FiredNear", "if (drone1 distance (_this select 1) < 3500) then {hint 'unit in range';}"] this is my current init line above in the the drone (drone1) how ever even if I change it to the following bellow this addEventHandler ["FiredNear", "if (drone1 distance (_this select 1) > 1000) then {hint 'unit in range';}"] it doesnt seem to make a difference, the range still seems limited to 50m Again thanks to anyone who can shead some light on this Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted March 29, 2016 Why not use a fired eventhandler and check for distance to the unit in question instead? Cheers Share this post Link to post Share on other sites
mattsmith94 10 Posted March 29, 2016 because I want to have unit A ... a drone moving and detecting fire with in 1km .. i tried using fired but it ment needing to add an event handler to every other unit in the game. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted March 29, 2016 u only need to add the fired EH to every unit within 1000 m of the drone. if a unit leaves that circle u can delete the EH from it. II know that not a good solution because u need an endless loop for it which should be avoided by the use of an EH. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted March 29, 2016 Exactly. What's stopping you from doing it? Eventhandlers are the only performance friendly way to achieve what you want. addEH.sqf: somecondition= true; _allUnits = allUnits; while {somecondition} do { { if (_x getvariable ["MyFiringEH",-1] isEqualTo -1) then { _eventHandlerID = _x addEventHandler ["Fired",{"yourcodeHere"}]; _x setvariable ["MyFiringEH",_eventHandlerID]; }; } foreach _allUnits; waituntil {sleep 1;!(_allUnits isEqualTo allUnits)}; _allUnits = allUnits; }; { _x removeEventHandler ["Fired",(_x getvariable ["MyFiringEH",-1])]; } foreach allUnits; Not that hard and shouldn't cost any performance unless you're running thousands of units (you won't). Once somecondition turns false the eventhandlers will automatically be removed from all units. Cheers 1 Share this post Link to post Share on other sites