Jump to content
Sign in to follow this  
joltan

Objects within a trigger

Recommended Posts

I want to use the following script to remove all unit from an area defined by a trigger (once the trigger gets toggled). So I start this script from the trigger's on-activation field using the command line '[] exec "rvtrigger.sqs"'. But the seems to be a problem with either the "_unitlist=list trigger1" or the "_unit=_unitlist select _no" command as I always get an 'division by zero' error.

What am I doing wrong? I should have an array containing the units from within the trigger, and I should be able to choose elements from within the array using the select comand. It just doesn't work...

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unitlist=list trigger1

_noarray=count _unitlist

_no=0

hint "start delete"

~1

#loop

~0.5

_unit=_unitlist select _no

deletevehicle _unit

_no=_no+1

?(_no == _noarray):goto "end"

goto "loop"

#end

hint "finished"

exit<span id='postcolor'>

Share this post


Link to post
Share on other sites

Ok, solved it:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">;loop through trigger array

#loop

_unitlist=+(list trigger1)

_noarray=count _unitlist

?(_noarray==0):goto "end"

~0.01

_unit=_unitlist select 0

deletevehicle _unit

goto "loop"

;end script

#end

exit<span id='postcolor'>

Finds all units within trigger1 and deletes them. Array is read anew each loop to catch those units leaving deleted vehicles. Dead units will not be removed by this script.

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  

×