Home   Help Search Login Register  

Author Topic: Syntax for deleting a whole group?  (Read 994 times)

0 Members and 1 Guest are viewing this topic.

Mr.BoDean

  • Guest
Syntax for deleting a whole group?
« on: 23 Oct 2003, 11:04:48 »
Sorry , couldn't find it .  :P And my trials didn't work .

I thought it would be something like :

"deletevehicle _x" foreach units groupname

but nothing happened and I think I got an error when I dropped the 'units' part.     :-\

i.e., I have a group with 12 units and I want them all to be deleted when all of the units in the group have died.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Syntax for deleting a whole group?
« Reply #1 on: 23 Oct 2003, 11:49:57 »
There are scripts for removing dead bodies in the Ed Depot.
Plenty of reviewed ArmA missions for you to play

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Syntax for deleting a whole group?
« Reply #2 on: 23 Oct 2003, 13:51:50 »
da prob is dat after unit dies it gets deleted of da group (wen its called down) - so in ur case only da last unit 2 die wil b deleted - 2 make complete delete wen dey all die u need 2 make array of da group (not usin da group array) nd delete em den :P

or u can just delete em 1 by 1 wen dey die

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

Komuna

  • Guest
Re:Syntax for deleting a whole group?
« Reply #3 on: 23 Oct 2003, 14:04:49 »
da prob is dat after unit dies it gets deleted of da group (wen its called down) - so in ur case only da last unit 2 die wil b deleted - 2 make complete delete wen dey all die u need 2 make array of da group (not usin da group array) nd delete em den :P

or u can just delete em 1 by 1 wen dey die

LCD OUT


In other words:

_group = units MyGroup

Code: [Select]
#check
{IF (!(alive _x)) THEN {deleteVehicle _x}} foreach _group
~5
? "Alive _x" count _group > 0 : Goto "Check"
(one by one deletion)

OR

Code: [Select]
@("alive _x" count _group == 0)
"deletevehicle _x" foreach _group
(whole group deletion)


#Edit
#Comment to the following LCD post

Sorry, m8! I won't disturb your posts anymore. ;)
« Last Edit: 23 Oct 2003, 14:43:52 by Komuna »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Syntax for deleting a whole group?
« Reply #4 on: 23 Oct 2003, 14:38:15 »
thx kom :P ;D

he didnt even got da opt 2 aks me wat did i meen :P  :o

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

Mr.BoDean

  • Guest
Re:Syntax for deleting a whole group?
« Reply #5 on: 26 Oct 2003, 05:27:21 »
thx kom :P ;D

he didnt even got da opt 2 aks me wat did i meen :P  :o

LCD OUT

 :beat: LOL guys ... Sorry took so long to get back to you LCD ...damn work keeping me from playing!  :-X    ;D  Thanks for the answers. I Will try that out.

Also, Mac I had previously tried to use  an old script by dreaming_adam which I never got to work, along with several others on this board. The only other script I saw in the ed depot was for each individual unit .   :-\      

Mr.BoDean

  • Guest
Re:Syntax for deleting a whole group?
« Reply #6 on: 26 Oct 2003, 06:59:22 »
hmm, okay guys ..getting error message with

"deletevehicle _x" foreach _group

error: ...foreach .. Type group ,expected array

So I tried :

"deletevehicle _x" foreach [units _group]

and got error: ...type array , expected object


since I have multiple AI groups that will be spawned from a script, I don't really want them to run a separate script to dlete them when dead. I want to place it at the end of their patrol script when all dead.

So I'm not clear on making the array, I guess. Nor would I know how to make one if the units of the group will be spawned into a present AI leader's group later.  ???

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Syntax for deleting a whole group?
« Reply #7 on: 26 Oct 2003, 10:23:57 »
did u put dat line ?

_group = units MyGroup

nd MyGroup is suposed 2 b da group name ;)

@ kom

Quote
Sorry, m8! I won't disturb your posts anymore.

kool ;D

i dont like em bein disturbed cuz den i get extra post explainin ma prev post (nd dats post count talkin ;)) ::)

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

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Syntax for deleting a whole group?
« Reply #8 on: 26 Oct 2003, 14:19:45 »
Quote
So I tried :

"deletevehicle _x" foreach [units _group]

and got error: ...type array , expected object


The error says:

There was an array, where an object (or more) were expected.

You know why?

units _group already is an array

Now if you put units _group into another array, you
got an array inside an array (= a subarray)

"deleteVehicle _x" requires an array, consisting of object/s

like: [unit1,unit2,unit3]
or: units _group
or: list triggername
or: arrayname
or: thislist (if it's the trigger itself where you execute the command).

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Mr.BoDean

  • Guest
Re:Syntax for deleting a whole group?
« Reply #9 on: 27 Oct 2003, 21:59:39 »
Ok guys ...thanx for the responses...but...
 
@LCD -  Yea, I'm using this at top of script

_curgroup = paragroupF


@Chris - Ok, so I understand how I could make an array of unit names to delete,but ....

I tried this out on a separate test mission, having a group first walk into a trigger which kills them. Then I activate a radio trigger which activates a script and deletes them using

"deletevehicle _x" foreach units _curgroup


Voila! This works fine. However, in the mission I want to use the deletion in, the units are spawned into a group using the createunit command. Using the same scenario as above, the units do not get deleted . No errors, but the bodies are still there.

   So I'm guessing it must have something to do with the spawning? There is an officer unit in the editor with

paragroupF = group this

in its init. line. The units are then created into that group.

Any ideas?  :-\   ???

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Syntax for deleting a whole group?
« Reply #10 on: 28 Oct 2003, 11:04:36 »
put da

_curgroup = paragroupF

after u create da units ;D - also put 1 sec delay after u create em nd b4 dat line

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

Mr.BoDean

  • Guest
Re:Syntax for deleting a whole group?
« Reply #11 on: 28 Oct 2003, 21:51:40 »
Hmm... still no worky.  :-\  I even changed the _curgroup variable to the _groupname variable used to call the script , which is paragroupF .

[Mi17,paragroupF] exec "Parascript.sqs"


Basically the script controls a helicopter movement, group spawn, heli drop, group move, heli delete then should be group deletion when done.

Again, I was able to use the

"deletevehicle _x" foreach units _group

on a group created in the editor, but so far not in script with spawned group.

Unnamed

  • Guest
Re:Syntax for deleting a whole group?
« Reply #12 on: 29 Oct 2003, 06:36:18 »
What about if you put this in the init string of your createunit commands:

Code: [Select]
Currunits=Currunits+[This]Will look something like this:

Code: [Select]

CurrUnits=[]

"soldierWB" createunit [ [_ax + (random 10),_ay + (random 10),_az],group Officer1,"CurrUnits=CurrUnits+[This]",0.5,"sergeant"]

"soldierWB" createunit [ [_ax + (random 10),_ay - (random 10),_az],group Officer1,"CurrUnits=CurrUnits+[This]",0.5,"corporal"]

I used a global array assuming the rule about not using local variables in a units init field still stands when creating units using a script. Plus it makes it easier to define and empty your array each time you want to create a new group.

Then call your delete vehicle script with Currunits:

Code: [Select]
{DeleteVehicle _x} ForEach Currunits
I hope to use createunits for the same purpose myself in the near future, so I'm interested in the solution to your problem.
« Last Edit: 29 Oct 2003, 06:51:58 by Unnamed »