Home   Help Search Login Register  

Author Topic: delete all units inside a trigger area  (Read 12147 times)

0 Members and 1 Guest are viewing this topic.

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
delete all units inside a trigger area
« on: 19 Nov 2007, 21:00:30 »
Hi
can someone help me out with this. I need all units in a trigger area deleted once the player is distant from the trigger. i did a search but didn't find anything.
What is the right syntax? I know the deletevehicle command, but I need everything in the trigger area to be deleted.
( deleteVehicle_x) forEach units thisList . . . I tried this but it gave me an error message. Can someone tell me the right syntax?
Any help is really appreciated.
thanks in advance
nettrucker :dunno:

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: delete all units inside a trigger area
« Reply #1 on: 19 Nov 2007, 21:30:27 »
The above syntax is correct, except for the fact you need to use curled braces {} for the forEach, and you don't need to use the units command (units is only used in conjunction with groups):

Code: [Select]
{deleteVehicle _x} forEach thisList

Remember to set the trigger activation to "Anybody", otherwise it'll just delete the units of the side specified. :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: delete all units inside a trigger area
« Reply #2 on: 19 Nov 2007, 22:31:48 »
Hi wolfrug
thanks for your swift reply mate. I checked it and it worked right away but I'm still stuck maybe I should have explained myself a little bitter better and more precisely in the first message. Since the player is moving away from the trigger1 area where all units are supposed to be deleted I need this delete trigger1 to be activated by another trigger2 as a condition. Player reaches the new trigger2 area so the former trigger1 area will delete all units inside range.
I set trigger1
condition:  delete
activation: {deleteVehicle _x} forEach thisList

trigger2 - activated by player
condition: this
activation: delete = true

but it doesn't work.
any ideas?
thanks
nettrucker :D :dunno:

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: delete all units inside a trigger area
« Reply #3 on: 19 Nov 2007, 22:35:56 »
If you're sure you've set up the triggers correctly, the problem may lie in your variable definition: it's always a good idea to first define a variable before using it (i.e., by giving it some value such as delete = false). So try putting somewhere (in your init.sqf/sqs preferably, but the Player unit's init field works fine for tests and such too) delete=false to declare that variable: it might work then!  :good: Also, if you want to see if there's something wrong with the script you've written or something wrong with the trigger's activation, add a hint to the other trigger, something like: hint "Trigger started!"; to make sure it's at least triggered.  :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: delete all units inside a trigger area
« Reply #4 on: 19 Nov 2007, 22:42:38 »
Thanks a bunch I gonna try that right away.
nettrucker :D

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: delete all units inside a trigger area
« Reply #5 on: 19 Nov 2007, 22:45:37 »
Beware the anybody type triggers, you might end deleting also gamelogics vital for your game. Also, if you delete a vehicle, its crew will be "ejected" from it. So, for each vehicle you should take care to remove its crew first.

I havent tested nested foreach, it is up to you to try it:
Code: [Select]
{if (typeOf _x != "logic") then {{deleteVehicle _x} forEach crew _x;deleteVehicle _x};} forEach thisList

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: delete all units inside a trigger area
« Reply #6 on: 19 Nov 2007, 22:58:27 »
Hi Mandoble
Thanks for your help. I'll try that one too. well what i want to achieve is simply deleting units and objects in the trigger area to free ressources for the 2nd part of the mission so it won't be causing lag. i need simply to shift place in the mission. At a certain point all units in trigger1 aren't neccessary anymore and therefore i need them deleted.
I try to use the snippet you suggested now.
thanks for your reply
nettrucker :D

EDIT:

Both solutions worked perfectly thanks a lot. :good:
Regards
nettrucker :D
« Last Edit: 19 Nov 2007, 23:28:39 by nettrucker »

Offline Nemesis6

  • Members
  • *
Re: delete all units inside a trigger area
« Reply #7 on: 20 Nov 2007, 22:17:42 »
Sorry to butt in here, but if I only want to delete all units of a certain side within a trigger, how should I go about doing that?
I am actually flying into a star... this is incredible!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: delete all units inside a trigger area
« Reply #8 on: 20 Nov 2007, 22:21:59 »
jsut set da side dat activates da triger 2 da side ui wanna delete

if u wanna delete all OPFOR units have da activated by field as OPFOR

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: delete all units inside a trigger area
« Reply #9 on: 20 Nov 2007, 22:32:54 »
Although Mandoble's care about logics is wise, it only protects the "logic" found in vanilla Arma. Since many addons contain derived logics, I think you'd be better protecting all types of logics:
Code: [Select]
{if (not (_x isKindOf "logic")) then {{deleteVehicle _x} forEach crew _x;deleteVehicle _x};} forEach thisList;

[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: delete all units inside a trigger area
« Reply #10 on: 08 Jun 2008, 13:04:41 »
Hi everybody

sorry for digging up this old topic but I have still some issues with this. I did some extensive testing on the syntax. It will delete all units still alive when the trigger gets activated but dead units will remain. I need also the dead units to be removed but I really don't know how to implement this condition in the syntax of mandoble or spooner.
can anybody help me out?
thanks in advance
nettrucker :dunno:
« Last Edit: 08 Jun 2008, 13:07:27 by nettrucker »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: delete all units inside a trigger area
« Reply #11 on: 08 Jun 2008, 13:32:21 »
You will not detect dead units with a trigger. Look for dead body remover scripts in the depot.

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: delete all units inside a trigger area
« Reply #12 on: 08 Jun 2008, 13:43:33 »
Thanks Mandoble

I found a remover script by Taurus are you referring to that one or is there something else.
Thanks
nettrucker :D