Nielsen 10 Posted January 8, 2011 (edited) I'm having a problem despawning a spawned group. Ive got no problem deleting units outside the group vehicle. The problem arises when all units are dead and some are in a vehicle, and I want to delete them and the group vehicle. {deleteVehicle _x;} forEach Units groupname; is not working. I'm using this bit of code to test it: //TESTSupportGrp = [getPos Player1, side player, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Motorized" >> "US_DeltaPatrolHMMWV")] call BIS_fnc_spawnGroup; private ["_grpVehicle"]; _grpVehicle = AssignedVehicle (units SupportGrp select 2); diag_log format ["Before sleep: unit is %1, vehicle is %2",units supportGrp select 2,_grpVehicle]; sleep 30; {deleteVehicle _x} forEach Units SupportGrp; deletevehicle _grpVehicle; DeleteGroup SupportGrp; diag_log format ["after sleep: unit is %1, vehicle is %2",units supportGrp select 2,_grpVehicle]; It works fine when the soldiers are alive, but if I kill them all before the despawn fires, then i get errors and it wont work proper. The problem suggested by my diag_log debug is, that the object names seem to change when they die. I get this error in the .rpt: "Before sleep: unit is R 1-1-C:3, vehicle is R 1-1-C:4""after sleep: unit is <null>, vehicle is 450fee00# 399979: m998a2_sov.p3d" Error in expression < is %1, vehicle is %2",units supportGrp select 2,_grpVehicle];> Error position: <select 2,_grpVehicle];> Error Zero divisor ..I've searched around but found nothing, very much to my surprise. Any ideas on how to handle this and deleting the group (and vehicle) when soldiers are dead inside the vehicle? Thanks in advance Edited January 8, 2011 by Nielsen Share this post Link to post Share on other sites
gossamersolid 155 Posted January 8, 2011 well your "after sleep" log file is logging a non-existent unit (you already deleted it before a couple lines up). As for the vehicle being listed as 450fee00# 399979: m998a2_sov.p3d. That's simply referencing an object instead of it's ID within a group. I assume it's doing this because the unit that it was assigned to is no longer in existance, changing the vehicle to not being in a group (only alive units may be in a group, empty vehicles do not count). I'll try to take a better look at it in the morning. I hope what I wrote can somewhat help you. Share this post Link to post Share on other sites
Nielsen 10 Posted January 8, 2011 Thanks for taking the time to answer. Oops yeah I see with the diag_log.. Silly me. However it was the other variable that really concerned me. Normally {DeleteVehicle _x} foreach units group; works, but when this is a vehicleGroup it does not seem to function. I'm not sure how to reference the vehicle other than how i did it above, and that wont work for me. Maybe I should just spawn the units and vehicles individually, that way I should be able to despawn just fine. It just pisses me off that I cant work it out, and I figure that there must be an easy way since I use the BIS_fnc_spawngrp, which should work I guess. I'm sure I'm not the first one to despawn a config group. Share this post Link to post Share on other sites
demonized 20 Posted January 8, 2011 _sv = [[getMarkerPos _spawn select 0, getMarkerPos _spawn select 1, _flyInHeight], random 360, _helitypeUsed, _side] call BIS_fnc_spawnVehicle; // Name the vehicle and group. _drophelo = _sv select 0; // vehicle spawned. _drophelogrp = _sv select 2; // group of vehicle so waypoints work. This is how i collected info on spawned group, also you need to delete the vehicle first before the crew, no matter what type spawn you use. deleteVehicle _drophelo; {deleteVehicle _ x} foreach units _drophelogrp; Share this post Link to post Share on other sites
shuko 59 Posted January 8, 2011 { if (vehicle _x != _x) then { deletevehicle vehicle _x; }; deletevehicle _x; } foreach units SupportGrp; Share this post Link to post Share on other sites
Nielsen 10 Posted January 8, 2011 @Shk: Thats the trick I'm looking for :) Working like a charm now. Thanks for the help all.. Share this post Link to post Share on other sites