How to delete attached vehicle after mission ends?

How to delete attached vehicle after mission ends?

« posted: Mar 01, 2021, 04:22 PM »
Hello guys,

I am trying to create mission where will be 3 spawned vehicles and one of them will have attached vehicle/static AA SAM behind it, everything is spawning proeprly and even attach is good.

Problem is:
If mission is not finished all the vehicles are deleted except for attached vehicle/object.

Code: [Select]
if (_type isKindOf "B_Truck_01_transport_F") then

{

                { _vehicle deleteVehicleCrew _x } forEach crew _vehicle;

                _obj  = createVehicle ["B_Radar_System_01_F", _position, [], 0, "None"];
                _obj attachTo [_vehicle, [0.02, 0, 1.9]];



                _soldier = [_aiGroup, _position] call createRandomSoldier;
                _soldier moveInDriver _vehicle;

                _soldier = [_aiGroup, _position] call createRandomSoldier;
                _soldier moveInCargo _vehicle;
;


anyone know how to edit it so the all the object from mission will despawn after mission fail?

Re: How to delete attached vehicle after mission ends?

« Reply #1 posted: Mar 02, 2021, 08:52 AM »
I'm not sure, but take a look in your missionProcessor.sqf. Only _vehicle/s are defined to be deleted.
Code: [Select]
if (_failed) then
{
// Mission failed

{ moveOut _x; deleteVehicle _x } forEach units _aiGroup;

if (!isNil "_failedExec") then { call _failedExec };

if (!isNil "_vehicle" && {typeName _vehicle == "OBJECT"}) then
{
deleteVehicle _vehicle;
};

if (!isNil "_vehicles" && {typeName _vehicles == "ARRAY"}) then
{
{
if (!isNil "_x" && {typeName _x == "OBJECT"}) then
{
deleteVehicle _x;
};
} forEach _vehicles;
};

Cannot see any _obj


Re: How to delete attached vehicle after mission ends?

« Reply #2 posted: Mar 02, 2021, 06:42 PM »
but how should i add it? bcz the mission is using
"   _vehicles =
   [
      [_veh1, _starts select 0, _startDirs select 0] call _createVehicle,
      [_veh2, _starts select 1, _startDirs select 1] call _createVehicle,
      [_veh3, _starts select 2, _startDirs select 2] call _createVehicle
   ];
"
and in one of those vehicles i am creating "sub" vehicle/object which is attached so the "_obj" is only part of one vehicle so it wont delete. I dont know how to write condition to add "_obj" which is part of vehicle :/
.

Re: How to delete attached vehicle after mission ends?

« Reply #3 posted: Mar 03, 2021, 08:59 AM »
no idea

Re: How to delete attached vehicle after mission ends?

« Reply #4 posted: Mar 03, 2021, 03:53 PM »
no idea

Me too mee too :D

well for now i reverted it, so the "vehicle" is left after mission fail and the attached object will be deleted. It's not optimal but better than nothing, maybe someone, someday will solve it
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2605

Re: How to delete attached vehicle after mission ends?

« Reply #5 posted: Mar 03, 2021, 10:16 PM »
After creating _obj, you have to do

Code: [Select]
_vehicles pushBack _obj;
The _vehicles variable tracks the objects that need to be removed on mission failure.

Also make sure that you have "_vehicles" in the private list at the top of your mission script, and _vehicles = []; inside _setupVars.

Re: How to delete attached vehicle after mission ends?

« Reply #6 posted: Mar 20, 2021, 12:19 AM »
Solved,
created next vehicle and then attached them together.