Jump to content
Blitzen88

Delete units of a particular side when a unit leaves the trigger area

Recommended Posts

Greetings,

 

Im using a trigger which is activated whenever Blufor are present. Due to the spawn script that I am using, the trigger needs to be a “Blufor Present” type of trigger. 

 

Is there a way to delete all units of a particular side whenever Blufor units leave the trigger area? I looked into using the Deactivation part of the trigger but, per the wiki, it seems like you cant use the “this list” command on trigger deactivation. Does any one know how to do this?

 

Thanks

 

 

Share this post


Link to post
Share on other sites

in deact field:

{deleteVehicle _x} foreach (allunits select {_x inArea thisTrigger && side _x == THESIDEYOUWANT})

 

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, pierremgi said:

in deact field:

{deleteVehicle _x} foreach (allunits select {_x inArea thisTrigger && side _x == THESIDEYOUWANT})

 

This worked like a charm, thank you!

 

I was unaware of the inArea command!

Share this post


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

How do I put a delay on this?

More than 3 years?

Share this post


Link to post
Share on other sites

Ha, just trying to build a mission but completely new to it. Came across this post on how to remove them. I just wondered if a delay can be added for say 15 minutes. 😄

Share this post


Link to post
Share on other sites

Not sure what you're asking for...

What delay?

If you want to add a delay:

- on activation : just set the timer type countdown in the trigger. (in seconds) . So the activation code will run after that. See also timeOut which needs the condition stays true during the whole delay.

 

- on deactivation: if you want to run some code after a delay, just spawn and sleep the deactivation code:

[] spawn {sleep 60; {deleteVehicle _x} foreach (allunits select {_x inArea thisTrigger && side _x == THESIDEYOUWANT}) }; // example for 1 minute

thisTrigger spawn {sleep 60; {deleteVehicle _x} foreach (allunits select {_x inArea _this && side _x == Blufor}) };

 

- now, if you want to stop the repetition for act/deact because you don't need to re-activate the trigger at once after a deactivation, you need to add a variable like this:

on condition:

<your condition> && isnil "myDelay"

on act:

<your code>; myDelay = TRUE;    // so the condtion is no more OK

on deact:

[] spawn {<your code if any>; sleep 60; myDelay = nil};     // so the condition could be OK (depending on the former condition) as myDelay is nil after 1 minute.

 

EDITED

 

 

Share this post


Link to post
Share on other sites

I am trying to use in the deact trigger box [] spawn {sleep 60;  {deleteVehicle _x} foreach (allunits select {_x inArea thisTrigger && side _x == Blufor}) };

It just brings up error invalid number in expression...

 

So what I am trying to do is when I leave the trigger zone the units will be deleted after around 10 minutes. lets say 60 seconds as your example. Appreciate the help 🙂 

Share this post


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

invalid number in expression...

 

9wjDtq1.png

 

Always use code blocks when pasting code to the forums. Hidden/corrupt characters will appear as red dots.

 

To clean your code:

  • open a code block
  • paste your code
  • delete red dots
  • re-copy code

Share this post


Link to post
Share on other sites
[] spawn {sleep 60;  {deleteVehicle _x} foreach (allunits select {_x inArea thisTrigger && side _x == Blufor}) };

Says undefined variable in thisTrigger when it tries to run the code.

I don't see any red dots in the code.

 

Cheers

 

Share this post


Link to post
Share on other sites

oups! sorry

thisTrigger spawn {sleep 60; {deleteVehicle _x} foreach (allunits select {_x inArea _this && side _x == Blufor}) };

  • Like 1

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

×