Home   Help Search Login Register  

Author Topic: Why does this scripts not work?  (Read 589 times)

0 Members and 1 Guest are viewing this topic.

Pimmelorus

  • Guest
Why does this scripts not work?
« on: 11 Apr 2003, 18:10:18 »
I have a scripting problem. For a fact the  activation of script.sqs works if put down like this:

<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 this isto 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

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:Why does this scripts not work?
« Reply #1 on: 12 Apr 2003, 02:39:49 »
Given the above classes=["A","B"] defined in init.sqs the line

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

works just fine for me as long as _class has a string value  such as "A".
By "works just fine" I mean that  "_class in classes" is true and script.sqs gets run.

So, the question is: are you sure that the variable _class in your code really
is string-valued?

A couple of notes:

  • _class = A;     no good for what you want (means that _class refers to an object with name "A")
  • _class = "A";  would work.
Wild guessing here: you're not putting the whole ?-expression above as a condition in a trigger, are you? That would be, well, strange...  ;) (Just "_class in classes" is OK, of course)

Hope I'm not just stating things you already know... ;)

Pimmelorus

  • Guest
Re:Why does this scripts not work?
« Reply #2 on: 13 Apr 2003, 09:49:52 »
No, _class is a string-variable in that gets read from the init field of my vehicles and is passed to the vehicle respawn script. The init.field look like this:

[this, "T80"] exec "vehicle.sqs

Ïn vehicle.sqs:

_vehicle = _this select 0
_class = _this select 1

In the vehicle.sqs is the code as described in the first message.

So you see that _class is a string. As I define the classes array to contain strings I expected no problem here. Well, in fact it is not the "?(_class in classes): bla bla" that does not work; when I put a hint-line behind it, it gets displayed as expected. But the script ("script.sqs"in first message) that was working before, is not executed.

I know it is odd,

Thnx,
« Last Edit: 13 Apr 2003, 09:51:04 by Pimmelorus »