Home   Help Search Login Register  

Author Topic: Yet another is soandso in a vehicle question - sorry  (Read 451 times)

0 Members and 1 Guest are viewing this topic.

grebz_uk

  • Guest
Hi Chaps,

I want to determine if an entire squad is in a vehicle before continuing.  I know I can loop through an array of units and check the 'x in y' status.  

Given the script below, what happens if units 0, 1 & 2 AREN'T in the vehicle but unit 3 IS?  The last time (x in y) is checked 'loaded' will be set to true and the script will exit - even though everybody isn't in the vehicle.  Is there a better way to do this?

On a related topic, using foreach how do you get goto statements to work?, do you need to 'escape' the "'s?  Know what I mean? like this line:-
    "?(_x In VehicleName):goto \"MainLoop\"" for each (Units group SquadUnitLeader)

I hope somebody understands my ramblings.


//SCRIPTSTART
SquadUnitLeader = this select 0
VehicleName = this select 1

#MainLoop
"?(_x In VehicleName):loaded=true" foreach (Units group SquadUnitLeader)

?(loaded=false):goto "MainLoop"

exit
//SCRIPTEND


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Yet another is soandso in a vehicle question - sorry
« Reply #1 on: 07 Apr 2004, 14:03:10 »
Here's a sketch, syntax not guaranteed.    Some tips:

- how to do loops is demostrated below

- always have a delay in a loop

- read the section "Scripting Topics" in the command reference

- learn about the command count, it's one way of doing this

- variable=false is wrong:  use not variable

- To use quotes within quotes " " " " use curly brackets " { } "

- In .sqs files use semicolon ; for comments.   Use // in description.ext.

- = defines something:  == checks if the statement is true.  Read the command ref.



#lop
; this is the main loop

~1
; this delays the loop for 1 second

? (count units grp1) == ("_x in chopper1" count units grp1): goto "allIn"

goto "lop"

#allIn
whatever
exit

There is an online version of the command reference in the Editors Depot, it's very helpful.

Oh, and

Welcome to the forum!
« Last Edit: 07 Apr 2004, 14:06:18 by macguba »
Plenty of reviewed ArmA missions for you to play