SupremeTDM 2 Posted February 1, 2023 Hello, Quick problem I've run into. {!alive _x;} forEach [target2,target3,target4,target5,target6,target7]; I have this in a trigger condition. I want the trigger to activate when all opfor targets are killed. When I try this script I get back "error: type nothing, expected bool". Im guessing that's the _x but don't understand why this doesn't work. I have this earlier in the mission {_x moveInCargo truck1;} forEach [player,pax1,pax2,pax3,pax4,pax5,pax6,pax7,pax8,pax9]; and this works perfectly so I'm just not understanding !alive or how it works with forEach or something. Any help is greatly appreciated! Share this post Link to post Share on other sites
_foley 192 Posted February 1, 2023 It doesn't work because whatever you put in trigger condition needs to return true or false, whereas forEach doesn't return anything. You're looking for this: {alive _x} count [target2,target3,target4,target5,target6,target7] == 0 1 Share this post Link to post Share on other sites
SupremeTDM 2 Posted February 1, 2023 10 minutes ago, _foley said: It doesn't work because whatever you put in trigger condition needs to return true or false, whereas forEach doesn't return anything. You're looking for this: {alive _x} count [target2,target3,target4,target5,target6,target7] == 0 Sweet! thanks for explaining it, that's what I was really looking for. I had never seen the count while searching around so this explains a lot. opPatrol = [target2,target3,target4,target5,target6,target7]; {!alive _x;} forEach opPatrol; I came up with this and it seems to be accepted but I will try yours instead, it looks cleaner to me Share this post Link to post Share on other sites
mrcurry 511 Posted February 3, 2023 On 2/1/2023 at 11:48 PM, SupremeTDM said: came up with this and it seems to be accepted That code may be syntactically correct but suffers from a logical mistake. forEach returns only the last result from all executions on the list, a.k.a. the alive check on the last element in the array. So in your code only killing the last target in the array will result in forEach returning true, if the other targets are alive or dead is not considered, the result of those checks simply discarded. If that's what you want you're better of just doing: !alive target7 otherwise, as you already intend to, use @_foley's example. 2 1 Share this post Link to post Share on other sites
SupremeTDM 2 Posted February 3, 2023 2 minutes ago, mrcurry said: the alive check on the last element in the array. I didn't know this, very helpful! I went with Foleys example and it has been great to use, much cleaner than what I did. I hadn't discovered count either so great to know for the future. and yes, I want all opfor dead, not just the target7. Can't have any survivors! lol Share this post Link to post Share on other sites