Jump to content
Sign in to follow this  
nullsystems

Checking if units in trigger are of certain name..

Recommended Posts

Hi all,

Im just looking for a trigger to kill people when they enter it if they arent: civ1, civ2,civ3,civ4,civ5 etc.

I came up with this, it works but im concerned about lag. I dont think it will lag, but if I have a few of these running it might?

Could anyone come up with some tips or better solution?

Trigger

-------

Cond: Civilian, Present, Repeatedly.

OnAct: civis = thisList; [civis] exec "script.sqs"

Script.sqs

----------

Quote[/b] ]

? not local server: exit;

#start

_civis = _this select 0;

_select = 0;

_maxcount = count _civis

#count

unit=(_civis select _select)

hint format["%1",unit]

?(unit == civ1) : goto "next"

?(unit == civ2) : goto "next"

?(unit == civ3) : goto "next"

?(unit == civ4) : goto "next"

?(unit == civ5) : goto "next"

unit setdamage 1

#next

_select = _select + 1

~1

?_select<_maxcount:goto "count"

~0.5

goto "start"

exit

Share this post


Link to post
Share on other sites

Use of command in and forEach should shorten the loop considerably:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? not local server: exit;

_civis = _this select 0;

{?!(_x in [civ1, civ2, civ3, civ4, civ5]): _x setDamage 1;} forEach _civis

Untested, but it should work like this.

Share this post


Link to post
Share on other sites

It produced an error:

|#|forEach, expected type string.

I presume but _civis is an array thats why there is an error.

But im still lost and testing smile_o.gif

---

When I put:

{?!(_x in [civ1, civ2, civ3, civ4, civ5]): _x setDamage 1;} forEach thisList

Into the OnAct in trigger to test it produced the same error at forEach.

Share this post


Link to post
Share on other sites
{?!(_x in [civ1, civ2, civ3, civ4, civ5]): _x setDamage 1;} forEach thisList

{if (!(_x in [civ1, civ2, civ3, civ4, civ5])) then {_x setDamage 1}} forEach thisList

Share this post


Link to post
Share on other sites

Thanks for your reply.

That works perfectly if there are no civilians in the trigger area called civ1 - 5. However if they are, and you enter ( not bieng one of the numbers ) then it doesnt do anything.

Any ideas on how to get around this?

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  

×