Jump to content
simicsko

How to Set group's VariableName?

Recommended Posts

Hi guys!

I spawned infantry group with Spawn_RedSquad1.sqf script:

 

_REDSquad1 = [getMarkerPos _spawnMarker,East, (ConfigFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

 

How can i set the VariableName of this group in the script that will make it identifiable in a trigger?

Share this post


Link to post
Share on other sites

Use a global variable:

REDSquad1 = [getMarkerPos _spawnMarker, East, (ConfigFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

 

  • Like 2

Share this post


Link to post
Share on other sites

As Harzach pointed out, you need to use a global variable (without the _).

Be careful when using it in trigger, as it will throw an error if the trigger is created before the variable is defined. If that's the case, you'll need to first check if the variable is defined (isNil).

  • Like 2

Share this post


Link to post
Share on other sites
43 minutes ago, Harzach said:

Use a global variable:


REDSquad1 = [getMarkerPos _spawnMarker, East, (ConfigFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

 

Thanks bro. Its work.

Another question is: how can I detect this group when it enters a trigger zone?

Share this post


Link to post
Share on other sites
40 minutes ago, _foley said:

As Harzach pointed out, you need to use a global variable (without the _).

Be careful when using it in trigger, as it will throw an error if the trigger is created before the variable is defined. If that's the case, you'll need to first check if the variable is defined (isNil).

Thank you.

The triggers are currently static, the group is coming to play during the game. i don't judge yet how can I detect this group when it enters a trigger zone?

Share this post


Link to post
Share on other sites

One way to achieve this is to give the trigger a global variable name instead. Then you can do this in your spawn script (assuming that your trigger is assigned to myAreaTrigger)

_REDSquad1 = [getMarkerPos _spawnMarker,East, (ConfigFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

_REDSquad1 spawn {
	waitUntil {
		sleep 1;
		(leader _this) inArea myAreaTrigger;
	};

	// Your "on activation" code goes here
	// _this refers to the spawned group 
};
  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, _foley said:

One way to achieve this is to give the trigger a global variable name instead. Then you can do this in your spawn script (assuming that your trigger is assigned to myAreaTrigger) 


_REDSquad1 = [getMarkerPos _spawnMarker,East, (ConfigFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

_REDSquad1 spawn {
	waitUntil {
		sleep 1;
		(leader _this) inArea myAreaTrigger;
	};

	// Your "on activation" code goes here
	// _this refers to the spawned group 
};

 

How to define this group leader for a trigger condition in the editor?

 

Update:

Found it:   leader REDSquad1 inArea thisTrigger

 

Harzach and Foley, thank you very much for your help! 😉

  • Like 2

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

×