Home   Help Search Login Register  

Author Topic: Problems with checking script  (Read 2458 times)

0 Members and 1 Guest are viewing this topic.

Offline Delta83_DK

  • Members
  • *
Problems with checking script
« 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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Problems with checking script
« Reply #1 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"