Jump to content
Taylor1984

Make unit activate repeatable trigger only once?

Recommended Posts

Hi!

 

Is there a way of preventing a unit from activating a repeatable trigger more than once? I still want the trigger to be able to activate when other units enter it afterwards.

 

Thanks

Share this post


Link to post
Share on other sites

So, you don't want it to activate again for that specific player who has already triggered it?

Share this post


Link to post
Share on other sites

Yeah, of course. Create an array of units that already activated it and add a condition that units that can activate it can't be in said array.

Share this post


Link to post
Share on other sites

Okay. Something like:

Not tested!

someArr = [];

someArr pushBack player;

if !(player in someArr) then
{
	// do whatever...
};

someArr pushBack (name player);

if !(name player in someArr) then
{
	// do whatever...
};

 

Share this post


Link to post
Share on other sites

Alternative to creating an array would be to use setvariable/getvariable to tag the Unit.

Cond

{!(_x getvariable ["trig",false])} count thislist >0

 

On Act

{_x setVariable ["trig",true]} foreach thislist

 

Probably not the best method but it did work for me.

  • Like 2

Share this post


Link to post
Share on other sites
21 hours ago, f2k sel said:

Alternative to creating an array would be to use setvariable/getvariable to tag the Unit.

Cond


{!(_x getvariable ["trig",false])} count thislist >0

 

On Act


{_x setVariable ["trig",true]} foreach thislist

 

Probably not the best method but it did work for me.

Thanks, it worked :)

Share this post


Link to post
Share on other sites

Trigger script commands are EL( local effect only ). So if you change an editor placed trigger at runtime( e.g through initPlayerLocal.sqf ) it will only apply to the trigger on the machine you made the changes from.

You can for instance take a reference to an editor placed trigger and change its Activation to "VEHICLE" and Repeatable to False, then add the local client( player ) as the attached vehicle.

The trigger will then only activate for this client, by this client, once.

//initPlayerLocal.sqf

params[ "_player" ];

//Wait for mission to start
waitUntil { time > 0 };

//Get a reference to the editor placed trigger
_trigger = NameGivenToTriggerInEditor;

//Reassign it as active to the attached vehicle only, set unrepeatable
_trigger setTriggerActivation [ "VEHICLE", "PRESENT", false ];
//Set local player as triggers attached vehicle
_trigger triggerAttachVehicle [ _player ];

 

  • Like 2

Share this post


Link to post
Share on other sites

Wouldn't it suffice to delete the trigger locally after it was activated?

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

×