Jump to content
Sign in to follow this  
Hawk666

loop over all groups

Recommended Posts

Hi,

sorry if this is a noobe question, but at least I've tried to search for the solution ;-):

Is it possible to loop over all existing groups (regardless of the side) ?

I've the problem, that some external scripts creates groups on the fly and I want to include these groups in my scripts. Of course I could directly access the global variables which store the groups but that's ugly coding: When I add new scripts I've to adapt my coding etc.

Thanks in advance guys.

Share this post


Link to post
Share on other sites

I use a trigger called IslandTrigger.

Although note that triggers are very tricky to use during initialisation or before the mission actually begins.

Try something like this:

mission.sqm:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class Sensors

{

class Item0

{

position[]={12140.961914,-19.595369,10696.132813};

a=12000.000000;

b=12000.000000;

rectangular=1;

repeating=0;

activationBy="ANY";

interruptable=1;

age="UNKNOWN";

text="islandTrigger";

name="islandTrigger";

class Effects

{

};

};

};

IslandTriggerInit.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Note: people inside vehicles need to be added separately

fn_getGroupsList =

{

private ["_allUnits", "_groupList", "_unit", "_vehicle", "_group", "_crewman"];

_allUnits = list islandTrigger;

_groupList = [];

{

_unit = _x;

_vehicle = vehicle _unit;

// if person

if !([_vehicle] call fn_IsVehicle) then

//if (_vehicle == _unit) then

{

_group = group _unit;

if (!isNull _group && !(_group in _groupList) && side _unit != sidelogic) then

{

_groupList = _groupList+[_group];

};

}

else // if vehicle

{

{

_crewman = _x;

_group = group _crewman;

if (!isNull _group && !(_group in _groupList) && side _crewman != sidelogic) then

{

_groupList = _groupList+[_group];

};

} forEach (crew _vehicle);

};

} forEach _allUnits;

_groupList;

};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×