Jump to content
Sign in to follow this  
MAJORdorMo

Count units inside trigger area

Recommended Posts

I'm trying to write a script that creates a trigger on a unit and detects how many civilians are inside the trigger area.

Here is what I have:

_unit = _this select 0;

_trig = createTrigger["PRESENT",getPos _unit];
_trig setTriggerArea[100,100,0,false];
_trig setTriggerActivation ["CIV", "PRESENT",true];
_count = count list _trig;
titleText[str(_count),"PLAIN DOWN"];

However, _count is always 0, no matter how many civilians are in the trigger area.

I've also tried using

_trig = createTrigger["EmptyDetector",getPos _unit];

but I got the same results.

Share this post


Link to post
Share on other sites

Did you try delay before counting? Too tired right now, but delays are usually the first thing I try when I'm not getting obvious results back.

Share this post


Link to post
Share on other sites

Carl is right. It needs a small delay.

This worked, so does a simple sleep.

_unit = _this select 0;

_trig = createTrigger["EmptyDetector",getPos _unit];
_trig setTriggerArea[100,100,0,false];
_trig setTriggerActivation ["CIV", "PRESENT",true];
waituntil {count list _trig > 0};
_count = count list _trig;
titleText[str(_count),"PLAIN DOWN"];

Share this post


Link to post
Share on other sites

<offtopic but maybe relevant>

count list doesn't work for radio triggers.

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  

×