GieNkoV 30 Posted May 16, 2013 So basically i want to know distance from player to an IED, and so if player speed > 7 and player distance to IED < _dist then BOOM. Code works good for driving a vehicle (explosion), shooting IED (explosion) but it dont detect a player. So now I got this: if (((speed nearestObject [_IED])>7) and ((((nearestObject [_IED]) distance _IED)<_dist))) then { boomcode } This is the only part of the code that doesnt work. And it does not want to work (it has to work on dedicated server). I tried using player distance _IED but it doesnt work too. Anyone can help me? Share this post Link to post Share on other sites
killzone_kid 1326 Posted May 16, 2013 Check the nearestObject syntax http://community.bistudio.com/wiki/nearestObject Share this post Link to post Share on other sites
GieNkoV 30 Posted May 16, 2013 (edited) Still cannot get it to work. EDIT: Made it working. Can close thread. ---------- Post added at 23:10 ---------- Previous post was at 21:22 ---------- I forgot I was testing my code on ingame hosted server, not dedicated server, so I still have problem with making this code working. I will paste here all what I have written and all of this IS WORKING on ingame hosted server, but detecting player doesnt works on dedicated. _isIED={ _IED=_this select 0; _IED setvariable ["_IEDEnabled",true,true]; _loop=true; _dist=10+random(15); while {(!isnull _IED) and (_IED getvariable "_IEDEnabled") and (_loop)} do { { if !(isnull _x) then { if (({(speed _x)>7 && (_x distance _IED)<_dist} count allUnits) > 0) then { [_IED] call _isIEDExplosion; _loop=false; }; if ((speed vehicle _x)>7 and (((vehicle _x) distance _IED)<_dist )) then { [_IED] call _isIEDExplosion; _loop=false; }; if ((damage _IED)>0.05) then { [_IED] call _isIEDExplosion; _loop=false; }; }; } foreach allUnits; sleep 1; }; }; Edited May 16, 2013 by gienkov Share this post Link to post Share on other sites
killzone_kid 1326 Posted May 17, 2013 you dont need ({(speed _x)>7 && (_x distance _IED)<_dist} count allUnits) > 0 you are doing it for every unit anyway because of foreach loop (speed _x)>7 && (_x distance _IED)<_dist is enough but you don't need this either because this: (speed vehicle _x)>7 and (((vehicle _x) distance _IED)<_dist //one bracket too many? will take care of both players on foot and in vehicles also try playableUnits instead of allUnits on the dedi. Share this post Link to post Share on other sites