OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Delta83_DK on 21 Jan 2012, 18:11:05

Title: Problems with checking script
Post by: Delta83_DK on 21 Jan 2012, 18:11:05
Hi Guys

Having some problems with this script.
I want to get displayed how many units remaining in group, but nothing happens.
What's wrong?  ???

Code: [Select]

#Start

Hint "Alive checking script ON"

#Check1
~1
?{Alive _x} count units grp_1 == 6 : HintSilent "6 soldiers left" and goto "Check1"
?{Alive _x} count units grp_1 == 5 : HintSilent "5 soldiers left" and goto "Check1"
?{Alive _x} count units grp_1 == 4 : HintSilent "4 soldiers left" and goto "Check1"
?{Alive _x} count units grp_1 == 3 : HintSilent "3 soldiers left" and goto "Check1"
?{Alive _x} count units grp_1 == 2 : HintSilent "2 soldiers left" and goto "Check1"
?{Alive _x} count units grp_1 == 1 : HintSilent "1 soldier left" and goto "Check1"
?{Alive _x} count units grp_1 == 0 : HintSilent "They are all dead!" and goto "End"

Goto "Check1"

#End
Hint "Alive checking script OFF"
~1
Exit
Title: Re: Problems with checking script
Post by: bedges on 21 Jan 2012, 21:30:55
Without the context of the mission, this question is very difficult to answer usefully.

Is there a group called grp_1?
How is this script being called?
Are there more than 6 units in the group to begin with?

On the face of it there's nothing wrong with the syntax of your code, however it could be written in a much more elegant way, i.e.

Code: [Select]
hint "Alive checking script ON"

#loop
~1
? ({alive _x} count units grp_1) == 0 : hintsilent "They are all dead" ; exit

hintsilent format["%1 soldiers left", {Alive _x} count units grp_1]

goto "loop"