Home   Help Search Login Register  

Author Topic: Checking if a unit is in a group  (Read 1320 times)

0 Members and 1 Guest are viewing this topic.

Offline Ironman

  • Former Staff
  • ****
    • {GSF} Home Page
Checking if a unit is in a group
« on: 16 Apr 2008, 07:58:12 »
Ok, I tried searching for about 45min for a cure to this but haven't seen it. I want to make a trigger set the player group(s) [sf1, sf2] to non-captives if they capture an enemy officer. I thought something like this would work, but I get an error complaining about how "e1_3 in sf2" is expecting an Array.... not a group name.

In trigger:
Code: [Select]
Condition: this || e1_3 in sf1|| e1_3 in sf2
Activation: player setCaptive false;
TS3 IP: tor.zebgames.com:9992

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Checking if a unit is in a group
« Reply #1 on: 16 Apr 2008, 08:36:55 »
what are el_3, sf1 and sf2?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Checking if a unit is in a group
« Reply #2 on: 16 Apr 2008, 08:50:59 »
Indeed so: el_3 is a UNIT whereas sf1/2 are GROUPS. To be able to compare units to units, you need to use (units sf1), as so:

 
Code: [Select]
this || e1_3 in (units sf1)|| e1_3 in (units sf2)
Should work, try it out!  :good:

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Checking if a unit is in a group
« Reply #3 on: 16 Apr 2008, 09:29:36 »
if sf1 and sf2 are groups and el_1 is a unit it might be more efficient to just compare with the group:
Code: [Select]
group el_1 in [sf1, sf2]or
Code: [Select]
(group el_1 == sf1) || (group el_1 == sf2)

Offline Ironman

  • Former Staff
  • ****
    • {GSF} Home Page
Re: Checking if a unit is in a group
« Reply #4 on: 16 Apr 2008, 11:27:14 »
I am sorry I wasn't more precise... yes e1_3 is a unit where as sf1/2 are groups

Thanks for your immediate help guys.... I tell everyone I know to come here... unless I know the answer...  :dunno:
« Last Edit: 16 Apr 2008, 11:28:46 by Ironman »
TS3 IP: tor.zebgames.com:9992