OK let's modify the script a little:
?!(local Server) : exit
_groups = [[gw1,[truck1,truck2]],[gw2,[tank1,tank2]],[gw3,[heli1,heli2]]]
_i = 0
_k = count _groups
#Loop
_tmp = leader ((_groups select _i) select 0)
deletevehicle _tmp
~0.2
? alive _tmp : goto "NoDelete"
{deletevehicle _x} foreach units ((_groups select _i) select 0)
~0.1
? (count (_groups select _i) > 1) : {deletevehicle _x} foreach ((_groups select _i) select 1)
~0.1
#NoDelete
_i = _i + 1
?(_i == _k) : exit
goto "Loop"
Now the
_groups variable contains also the vehicles of each group. In this example group
gw1 would have vehicles named
truck1 and
truck2 and so on, you get the idea.
If some group (in this example gw1) doesn't have any vehicles, write like this:
_groups = [[gw1],[gw2,[tank1,tank2]],[gw3,[heli1,heli2]]]
If there are soldiers inside vehicles:1. If the vehicle is not grouped with the group and there are soldiers inside the vehicle, the vehicle will be deleted but the soldiers will not be deleted.
2. But if the vehicle is grouped with the group, the soldiers inside the vehicle will also be deleted.
So this means: don't put soldiers inside ungrouped vehicles if you want to get rid of them.
EDIT #1:This version only takes care of soldiers and vehicles. I am working on a solution for the markers.
EDIT #2:I added more delays to the script, take a look. The delays are guessed values so they are maybe not optimal but I think they are good enough. If you encounter problems without any error messages in a multiplayer game, you could try and put some more delay.