Jump to content
Sign in to follow this  
_qor

Delete group of vehicles and infantry

Recommended Posts

Hey,

I spawn a convoy with this script

FC1 = [getmarkerPos "FC_spawn1", 172, "HMMWV_M1151_M2_DES_EP1", West] call Bis_fnc_spawnvehicle;

FC1veh = FC1 select 0;
FC1crw = FC1 select 1;
FC1grp = FC1 select 2;



FC2 = [getmarkerPos "FC_spawn2", 172, "MtvrRefuel_DES_EP1", FC1grp] call Bis_fnc_spawnvehicle;

FC2veh = FC2 select 0;
FC2crw = FC2 select 1;
FC2grp = FC2 select 2;



convoyGuardFC = createGroup west;

FCg_l = convoyGuardFC createUnit ["US_Delta_Force_TL_EP1", getMarkerPos "cgFC", [], 0, "FORM"];
FCg_mg = convoyGuardFC createUnit ["US_Delta_Force_MG_EP1", getMarkerPos "cgFC", [], 0, "FORM"];
FCg_s = convoyGuardFC createUnit ["US_Delta_Force_Marksman_EP1", getMarkerPos "cgFC", [], 0, "FORM"];

{_x moveInCargo FC1veh} forEach units convoyGuardFC;

Is there a way to delete all of them (drivers, vehicles, cargo units, gunners...)?

It doesnt work with

{deleteVehicle _x} foreach units FC1grp; {deleteVehicle _x} foreach units convoyGuardFC;

If the convoy is destroyed, I want to spawn the same convoy again, so I think I need to delete the old one because otherway there would be a name-problem?!

It is possible that a driver of any vehicle has disembarked. So I cant refer to driver vehicle and need to refer to the whole group.

Edited by _qoR

Share this post


Link to post
Share on other sites

Delete FC2grp.

Then deleteVehicle FC1veh and FC2veh

Share this post


Link to post
Share on other sites

Why FC2grp?

EDIT:

Okay it works this way

{deleteVehicle _x} forEach crew FC1veh;
deleteVehicle FC1veh;


{deleteVehicle _x} forEach crew FC2veh;
deleteVehicle FC2veh;

{deleteVehicle _x} forEach crew FC3veh;
deleteVehicle FC3veh;

{deleteVehicle _x} forEach crew FC4veh;
deleteVehicle FC4veh;

But if a unit is not in the vehicle, it wont get deleted.

I would delete each unit of FC1grp, but curiously its just not working. Although I created all waypoints by referring to FC1grp (and this works!).

Is there a solution?

Edited by _qoR

Share this post


Link to post
Share on other sites

BIS_fnc_spawnvehicle returns an array containing:

[vehicleUnit, [unitOne, unitTwoIfPresent, unitThreeIfPresent], Group]

This will delete all:

deleteVehicle FC1veh;
deleteVehicle FC2veh;

{deleteVehicle _x} forEach units FC1grp;
{deleteVehicle _x} forEach units convoyGuardFC;

deleteGroup FC1grp;
deleteGroup FC2grp;
deleteGroup convoyGuardFC;

Deleting the vehicle first leaves dismounts, cleaned up using 'forEach Units'. Then the group is removed. The FC2 unit doesn't need to be deleted, because it's only the driver and deleting the vehicle deletes the driver as well.

Your issue with the driver has to do with the vehicle object reference. BIS_fnc_spawnvehicle does not return the vehicle's object reference, it returns the vehicle's unit reference - which is the driver. When the driver dismounts, the unit reference goes with him. To get the vehicle object reference, you might try running 'nearObjects' for the vehicle type (after the driver has dismounted):

FC1vehObj = FC1veh nearObjects ["HMMWV_M1151_M2_DES_EP1", 100];
FC2vehObj = FC1veh nearObjects ["MtvrRefuel_DES_EP1", 100];

Share this post


Link to post
Share on other sites

Works excellent! Thanks a lot ;D

But I dont really understand what you say.

So what I dont understand is why I cant just delete FC1grp (error), perhaps I will realise when this question gets answered.

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  

×