Home   Help Search Login Register  

Author Topic: Compare a unit to units in an array  (Read 1162 times)

0 Members and 1 Guest are viewing this topic.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Compare a unit to units in an array
« on: 19 Mar 2007, 10:17:57 »
I am having a problem comparing a unit to an array of units and checking if the unit is already in the array.
The array is made in another script which I call in the main script. In the array all damaged vehicles (not yet exploded) will be added.
Now the main script selects units out of a list at random and I would like to make the script choose a different unit if the selected unit is in the array already.

I cant post the script right now since I am at work.
But after the script selected a random unit it will count how many units (if any) are in the array and than compare the selected unit to each unit in the array. If it sees the unit is the same it should go back to start and select another random unit.
And that is where the problem is, even when it selects a unit which is already in the array it doesnt see it is actuall the same.
So I have even tried to get the name of the selected unit and compare it to the name of the units in the array.
It sees the names are the same but still it doesnt go back to start to select a new unit.

What am I doing wrong here? How can I compare a unit to a unit to see if they are the same unit?
I have done this with a position array already (to see if a new position was close or the same to a position selected earlier) but comparing positions works.......comparing units not.

I have searched this weekend but to be honest I get so many hits when searching for compare, array etc etc,  its kind of a search without an ending.

I hope someone is able to help me with it, most preferable in .sqs style since I do not yet understand .sqf  :-[

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Compare a unit to units in an array
« Reply #1 on: 19 Mar 2007, 13:16:22 »
Are you using this command?


Planck
I know a little about a lot, and a lot about a little.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: Compare a unit to units in an array
« Reply #2 on: 19 Mar 2007, 14:55:29 »
Are you using this command?


Planck


 :-[
Pfew still much to learn with all the new stuff.
Completely overlooked this one.
Gonna give it a try when I get home.

Just as a quicky.
I guess for me it would be something like:

Code: [Select]
_unit = _this select 0
?(format ["%1",_unit]) = in [GRF_Damaged]

Where "GRF_Damaged" is the array in the other script containing the damaged (but still alive) units.

Looking good to me :)
I will be back cause I already know I have one more prob to sort with this array  :dunno: