OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Pimmelorus on 11 Apr 2003, 08:45:29

Title: "Is vehicleX part of array? Then......" how is it done?
Post by: Pimmelorus on 11 Apr 2003, 08:45:29
Hmm, I forgot about and I just cannot remember.

I have an array of vehicles "choppers"

In my script I want to check if a particular vehicle is part of this array. the reasoning is as followed:

?(vehicleA xxxx choppers): bla bla bla

What is the command to put on the xxxx?

Thnx in advance,

Pimmelorus
Title: Re:"Is vehicleX part of array? Then......" how is it done?
Post by: macguba on 11 Apr 2003, 09:00:22
x in array
Operand types:
    x: Any Value
    array: Array
Type of returned value:
    Boolean
Description:
    Check if x is equal to any element of array.

Example:
    1 in [0, 1, 2] , result is true

Title: Re:"Is vehicleX part of array? Then......" how is it done?
Post by: Pimmelorus on 11 Apr 2003, 10:15:29
Ah I interpreted the "value" in the command reference as a strickt  numerical variable. But I guess its not then :)

Thnx, Pimmelorus
Title: Re:"Is vehicleX part of array? Then......" how is it done?
Post by: Pimmelorus on 11 Apr 2003, 11:23:05
I have another problem now. Fact is activation of script.sqs works:

<assume here the vehicle is of class A>
?(_class == A OR _class == B): _vehicle exec "script.sqs"

I am using many vehicle types so I dont want to write "OR _class == etc. etc." for each vehicle type. My solution for tis was to declare an array of vehicle types in the init.sqs that contains the appropriate groups of vehicle types. like this:

In init.sqs
classes = ["A","B"]

But now if I want to activate the script.sqs again like this:

?(_class in classes): _vehicle exec "script.sqs"

this does not work. Does anyone know why?

Yhnx, Pimmelorus