OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: klavan on 29 Oct 2005, 12:45:30

Title: What's the problem here?
Post by: klavan on 29 Oct 2005, 12:45:30
Code: [Select]
#Next2
~5.5
player sidechat "I wonder what the hell....."
~3
playsound "GENB_Growl"
"gmer_civie_01" createunit [getmarkerpos "SkePos1",FakeRussi,"mon1=this",0.7,"Private"]
[mon1] join grpnull

@ {!alive _x} foreach [mon1]
~3
hint "done"
exit

I don't receive any error message, but the hint doesn't appears after  the created unit is killed. This script is under development and when finished, it will include about 20 created units (mon1 to mon20).
What do you think the problem is?
Thanks
Klavan
Title: Re:What's the problem here?
Post by: Baddo on 29 Oct 2005, 13:19:06
I think the problem is that forEach does not return anything, so you can't use it as a condition.
Title: Re:What's the problem here?
Post by: klavan on 29 Oct 2005, 13:44:25
OK, thank you Baddo.
Klavan
Title: RE: What's the problem here?
Post by: Trapper on 29 Oct 2005, 14:19:25
try to use

Code: [Select]
#wait1
~0.5
{if (alive _x) then {goto "wait1"}} foreach [mon1]
Title: Re:What's the problem here?
Post by: bedges on 29 Oct 2005, 14:27:56
alternatively...

Code: [Select]
#Next2
~5.5
player sidechat "I wonder what the hell....."
~3
playsound "GENB_Growl"
"gmer_civie_01" createunit [getmarkerpos "SkePos1",FakeRussi,"mon1=this",0.7,"Private"]
[mon1] join grpnull

@ (({alive _x} count [mon1]) == 0)
~3
hint "done"
exit

simply counts the number of units alive in the array containing mon1, and waits until it's 0.
Title: Re:What's the problem here?
Post by: klavan on 29 Oct 2005, 15:03:30
Problem solved!
I've adopted bedges's solution.
Sintax always drive me mad!   ;D
Thank to all you guys for your help.
Be prepared to be scared........ 8)
klavan