Jump to content
Sign in to follow this  
Blubu

Addaction radius

Recommended Posts

I wrote a simple script for this problem but it does not work. Any Ideas ?

_obj = _this select 0
_doOnce = 0
#loop
_dis = player distance _obj
if(_dis < 5 and _doOnce == 0) then {_id = _obj addAction["Whatever", "whatever.sqs"]; _doOnce = 1 }
if(_dis > 5 and _doOnce == 1) then {_obj removeAction _id; _doOnce = 0 }
if(_dis > 100) then { deleteVehicle _obj; exit }
goto "loop"

It adds the action correctly but does not remove it, but adds it again if the condition is true and again and again...

Share this post


Link to post
Share on other sites

Hi try my script it's remove action when you are to far from object

Check.sqs

; *****************************************************
; ** Check.sqs this script will check distance player and object to blow up
; ** Written by guziczek101 for Operation "Neptune" mission
; ** [object,distance,Place Charge] exec "Check.sqs"
; *****************************************************
_gun = _this select 0
_dis = _this select 1
_text = _this select 2
_checkarray = []

#loop
?(player distance _gun) < _dis && !(_gun in _checkarray): destroy = _gun addaction [_text,"stickybomb.sqs"]; _checkarray = _checkarray + [_gun]

?(player distance _gun) > _dis : _gun removeaction destroy; _checkarray = _checkarray - [_gun]
?(!(alive player) || !(alive _gun)) : exit

~0.5
goto "loop"

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×