Jump to content
Sign in to follow this  
Grey Wolf

Counting Missing guys...

Recommended Posts

I am making a script to see if a vehicle is empty so that it can be deleted if it is disabled or the units in it are deleted via a menu. The problem i have ran into is that when i delete the squad via a menu the group is deleted but the vehicles remain. I checked to see what units and how many are still in the vehicle it shows that the whole crew is there and the units are for example [5A70400# 17573: USMC_SOLDIER_CREW.p3d] instead of 1-1-B:1. However, the vehicles are empty...

isEmpty.sqf

_veh = _this select 0;
_units = crew _veh;
while {alive _veh} do{
_count = count crew _veh;
//player sidechat format["Count: %1",_count]; // after deleted via menu it still says there are crew in it.  [@2341234 USMC_SOLDIER_CREW.p3d] something in the array
//player sidechat format["Crew: %1",_units]; //after the guys eject they are still in the menu after being deleted via this script
if(_count < 2) then{
	sleep 120;
	_veh setvehicleammo 0;
	_veh setfuel 0;
	_veh setdamage 1;
	{			
		_x setdamage 1;
		sleep 2;
		deletevehicle _x;
	}foreach _units;		
};
sleep 120;
};
if(true) exitwith {
sleep 600;
deletevehicle _veh;
};

Menu.sqf (delete section)

_grp = lbCurSel LOC3_IDC_ListDBox;
_t = array2 select _grp;//selects the selected item's actual group
//removes empty squads from the list
_i = array2 find _t;
array2 set [_i, "a"];
array2 = array2 - ["a"];
{
	deleteVehicle _x;	
}foreach units _t;	
deleteGroup _t;

Share this post


Link to post
Share on other sites

Merry Christmas. I would try the "unassignVehicle xyz" command in your loop before deleting the unit members.

Secondly, I am not sure in how far the exitWith{} statements are always executed properly. I seem to remember I had problems with that. Anyway, in your code you won't even need it. Just replace it with an "IF THEN" control structure and after that the script ends anyway...

Cheers,

VictorFarbau

Share this post


Link to post
Share on other sites

Well... it didnt seem to work. I did notice that once i click the button to delete the unit it ignores any sleep statement i have in there and runs through it very quickly.

{
       unassignvehicle _x;
       dogetout _x;
       player sidechat "out";
       sleep 2;
deleteVehicle _x;	
}foreach units _t;

---------- Post added at 07:05 PM ---------- Previous post was at 07:00 PM ----------

ok i fixed it, i had to take my delete and make a new script then have the button call it and it works great. Thanks for the help VictorFarbau.

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
Sign in to follow this  

×