Jump to content
Sign in to follow this  
Rexxenexx

Scripting a trigger for any member of a specific group

Recommended Posts

I've tried so many ways and searched forever. It seems straight forward but I can't figure it out.


_trgMHQSpawn=createTrigger["EmptyDetector",getPos forwardFarpGL];
_trgMHQSpawn setTriggerArea[40,40,0,false];
_trgMHQSpawn setTriggerActivation["MEMBER","PRESENT",false];
//_leader = leader mygrp;
//hint format["%1",_leader];
_trgMHQSpawn triggerAttachVehicle [(leader mygrp)];
_trgMHQSpawn setTriggerStatements["this","hint 'Your MHQ will now respawn at the Forward FARP';forwardFarpSpawn = 1;publicVariable 'forwardFarpSpawn'",""];

The group is mygrp. I can do this in two seconds on the editor but I want to learn with scripts.

I can rem triggerAttachVehicle and change member to "WEST" and it works like normal, but I have units already there so I don't want to do that. What am I doing wrong with this? TIA

Share this post


Link to post
Share on other sites

Try something like:

_trgMHQSpawn=createTrigger["EmptyDetector",getPos forwardFarpGL];
Trigger1 = _trgMHQSpawn;
_trgMHQSpawn setTriggerArea[40,40,0,false];
_trgMHQSpawn setTriggerActivation["WEST","PRESENT",false];
_trgMHQSpawn setTriggerStatements["this","if ((leader mygrp) in list Trigger1) then {hint 'Your MHQ will now respawn at the Forward FARP';forwardFarpSpawn = 1;publicVariable 'forwardFarpSpawn'};",""];

I don't entirely understand what you are trying to do, but what I would do is create a trigger that gets activated by any WEST units, then detect if the unit you are looking for is in the list of units activating that trigger. Mind you, I didn't realise there was a MEMBER activation, so possibly my solution isn't the ideal way.

Share this post


Link to post
Share on other sites

won't that get triggered by the west units already there?

I have a Farp already occupied by west units (AI) and I want the players in "mygrp" group (any of them) to trigger that trigger. As if I put a trigger in the editor and dragged a group line from the trigger to the group and changed it to "any group member"

EDIT: I did it in the Editor with another character and this is what it put in the mission.sqm

	class Item15
	{
		position[]={6826.6509,329.47913,5814.2461};
		activationBy="MEMBER";
		interruptable=1;
		age="UNKNOWN";
		idVehicle=193;
		class Effects
		{
		};
	};

Edited by Rexxenexx

Share this post


Link to post
Share on other sites
won't that get triggered by the west units already there?

Yes, but I grouped the activated code in an "if" statement that means it only gets activated if a certain unit is detected within that trigger. Using MEMBER activation is probably best, but I'm not familiar at all with how that works.

Share this post


Link to post
Share on other sites

then

_trgMHQSpawn setTriggerActivation["WEST","PRESENT",false];

would need to be

_trgMHQSpawn setTriggerActivation["WEST","PRESENT",true];

to loop I think.

I'll try it out. I think repeating triggers slow down servers so I try to make them shoot once.

If I can't get that "MEMBER" -which I think is the correct one- to work I'll have to do it in the editor for the sake of finishing this mission.

EDIT:

This is the code in the mission.sqm when I made it for what I'm doing.

	class Item15
	{
		position[]={6759.6812,343.00092,5601.1167};
		a=40;
		b=46;
		rectangular=1;
		activationBy="MEMBER";
		interruptable=1;
		age="UNKNOWN";
		idVehicle=0;
		expActiv="hint ""Your MHQ will now spawn at the Forward FARP"";forwardFarpSpawn = 1;publicVariable ""forwardFarpSpawn"";";
		class Effects
		{
		};
	};

idVehicle is 0 which is Class Item0.....which is the mygrp leader....when I do

_trgMHQSpawn=createTrigger["EmptyDetector",getPos forwardFarpGL];
_trgMHQSpawn setTriggerArea[40,40,0,false];
_trgMHQSpawn setTriggerActivation["MEMBER","PRESENT",false];
_leader = leader player;
_leaderID = vehicle _leader;
_trgMHQSpawn triggerAttachVehicle [_leaderID];
_trgMHQSpawn setTriggerStatements["this","hint 'Your MHQ will now spawn at the Forward FARP';forwardFarpSpawn = 1;publicVariable 'forwardFarpSpawn'",""];

It won't trigger unless I walk into it -which I am the leader of the group. The rest of the members don't trigger it.

maybe if I put _trgMHQSpawn triggerAttachVehicle [0]; Lol I dunno...

For sure "MEMBER" -setTriggerActivation line- is the right setting, how to point it to the leader seems to be messed up. I'll fraps a vid of it working with the editors trigger maybe you guys will get another idea.

EDIT2: YouTube of it made with the editor.

Edited by Rexxenexx

Share this post


Link to post
Share on other sites

Hi Guys,

Hey..someone has the same problem as I do, what do you know : )

I am trying to get this working myself but with no success. I have tried similar parameters as above post with "MEMBER" and in settriggeractivation field but with no positive result.

The problem with the code below however is I think it tries to check that EVERY member of me's group is in the chopper as well as the other statements. Is there a way to change the triggerstatement that "ANY" of units group me are in the chopper?

I wish there was a "FORANY" command : P

_trigger7 = createTrigger ["EmptyDetector", getmarkerpos "wp2"]; 
_trigger7 setTriggerArea [150, 150, 0, false];
_trigger7 setTriggerActivation ["VEHICLE", "PRESENT", false];
_trigger7 triggerAttachVehicle [extractchopper];
_trigger7 setTriggerStatements ["{_x in extractchopper} foreach units (group me) && ((getposATL extractchopper) select 2 <= 2) && ((speed extractchopper) <=1) && ((extractchopper distance helipad) < 200)", "hint ""any member now works""", ""]; 

Thanks

Frosty

Edited by Rough Knight

Share this post


Link to post
Share on other sites

{group _x == groupName} count crew extractchopper > 0

{group _x == group unitName} count crew extractchopper > 0

{_x in extractchopper} count units groupName > 0

{_x in extractchopper} count units group unitName > 0

Share this post


Link to post
Share on other sites

LOL shk....you are a legend, that works like a charm.

Damn you guys make things look to easy sometimes.

just for reference, here is the completed scripted trigger.

_trigger7 = createTrigger ["EmptyDetector", getmarkerpos _wp2]; 
_trigger7 setTriggerArea [150, 150, 0, false];
_trigger7 setTriggerActivation ["VEHICLE", "PRESENT", false];
_trigger7 triggerAttachVehicle [Extractchopper];
_trigger7 setTriggerStatements ["({_x in extractchopper} count units group player > 0) && ((getposATL extractchopper) select 2 <= 2) && ((speed extractchopper) <=1) && ((extractchopper distance helipad) < 200)", "tskObj7 setTaskState ""SUCCEEDED""; tsk7 = 2; publicVariable ""tsk7""", ""]; 

Thanks mate.

Frosty

Share this post


Link to post
Share on other sites

I'll fraps a vid of it working with the editors trigger maybe you guys will get another idea.

No probs anymore for synch a scripted trigger with any member of a group till I place the "triggerAttachVehicle" command before the "setTriggerActivation" like this:

trg_pilot_rescued = CreateTrigger ["EmptyDetector",[2545.7014,2322.0735,0]];

trg_pilot_rescued SetTriggerArea [3,3,0,false];

// far_leader = group leader name on the editor

trg_pilot_rescued triggerAttachVehicle [far_leader];

trg_pilot_rescued setTriggerActivation ["MEMBER", "PRESENT", false];

trg_pilot_rescued SetTriggerStatements ["(this) && (alive pilot)", "server setvariable ['obj1_done',true,true]", ""];

The idea come after read this on the wiki:

   * If [] is given, the trigger is decoupled from the assigned vehicle.
   * If the activation source is "VEHICLE", "GROUP", "LEADER" or "MEMBER", it's changed to "NONE".
   * If [vehicle] is given, the trigger is coupled to the vehicle or its group.
   * When the source is "GROUP", "LEADER" or "MEMBER", it's coupled to the group, otherwise it's coupled to the vehicle and the source is changed to "VEHICLE". 

wiki triggerAttachVehicle

Edited by Reapy
correction

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  

×