Jump to content
Sign in to follow this  
Skippie

Deleting vehicle AND crew

Recommended Posts

I've been going through the commref and tried out some of the "delete" functions - ofcourse I've also searched the forums, but wasn't able to find what I needed..

So - what I want to do, is I want a chopper to drop off a team and then fly away - when out of sight, I want to delete the chopper AND crew..

At first, I used deleteVehicle x; in the waypoint - but then the crew would just fall to the ground.

I then tried to put in Squad = group this;, then afterwards type deletegroup squad; in the waypoint, but it did nothing..

Then I made an empty chopper, a BLUEFOR pilot and used moveindriver x; and then made a deleteVehicle x; on both of them - but now the Transport Unload doesn't work so, the chopper flies to the drop off point, then turns, gets deleted (with pilot) and I get smashed..

How the heck do I get it to delete the whole thing?

Edited by Skippie

Share this post


Link to post
Share on other sites

Hi.

In the trigger, for example put.

{deleteVehicle _x;}forEach crew MyChopper;deleteVehicle MyChopper;

Having MyChopper as the name of the chopper.

(there are other ways of doing this without a named chopper.

Share this post


Link to post
Share on other sites
{ deleteVehicle _x } forEach (crew heli); deleteVehicle heli;

  • Like 1

Share this post


Link to post
Share on other sites

Works perfectly, thank you very much! :)

Share this post


Link to post
Share on other sites

And here I come with the shorter version of that code...

{deleteVehicle _X} forEach (crew heli1)+[heli1]

We should have code-shortness competitions...:yay:

  • Like 1

Share this post


Link to post
Share on other sites

just tacking onto this post -as it's a similar question...

I'm trying to get rid of all the F16 wrecks that build up in evolution modded.

If i call this from my server init list will it work?

centerp is a marker in the centre of each map (sahrani, duala, panthera, chernarus etc)

// Deletes dead falcon wrecks

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
sleep 1.05;
_pos = getmarkerpos "centerp";
_wrecklist = [_pos select 0,_pos select 1] nearObjects ["GLT_Falcon_MRWreck",10000];
{deletevehicle _x} for each units _wrecklist;
};

is this likely to work i wonder?

Share this post


Link to post
Share on other sites

thx for reply

this won't likely work as i'm using a vehicle respawn script in the init line of all planes.

deleting the plane will mean it is gone forever.

what i want to do is delete the wreck which is created by the script embedded in the GLT F16 mod.

so the plane is killed

the mod runs a script to spawn a wreck which is permanent and virtually immoveable

i then need to check the area of the F16 or the airport and find all instances of the wreck and delete them...

I can add in a routine to the vehicle respawn script that says

if _type = "GLT_Falcon" then

and then run the cleanup routine...

but how should the cleanup routine look?

Share this post


Link to post
Share on other sites

got it - i put this in my mainthread

//adding a line to delete unwanted wrecks in base

_Objectsw = (getMarkerPos "Respawn_West") nearObjects 500;{if (_x isKindOf "GLT_Falcon_MRWreck") then {sleep 60;deletevehicle _x}} forEach _Objectsw;

Share this post


Link to post
Share on other sites
got it - i put this in my mainthread

Was able delete "GLT_Falcon_MRWreck" nicely, although in trying other

wrecks such as the "SU25Wreck" or RKSL FGR4 Wreck it does not work. I would like to use the same or similar to: _Objectsw = (getMarkerPos "Respawn_West") nearObjects 500;{if (_x isKindOf "GLT_Falcon_MRWreck") then {sleep 60;deletevehicle _x}} forEach _Objectsw; Can you help?

Share this post


Link to post
Share on other sites
Was able delete "GLT_Falcon_MRWreck" nicely, although in trying other

wrecks such as the "SU25Wreck" or RKSL FGR4 Wreck it does not work. I would like to use the same or similar to: _Objectsw = (getMarkerPos "Respawn_West") nearObjects 500;{if (_x isKindOf "GLT_Falcon_MRWreck") then {sleep 60;deletevehicle _x}} forEach _Objectsw; Can you help?

The RKSL Typhoon FGR4 public beta does not have a wreck model. You'll have to wait for the next release for that. :)

Share this post


Link to post
Share on other sites

I'm stuck! :(

airgrp = CreateGroup West;

airgrp = [[(getmarkerpos "airPoint" select 0), (getmarkerpos "airPoint" select 1), 500], side player, ["I44_Plane_A_P51D_250lb_AAF","I44_Plane_A_P51D_250lb_AAF"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

player hcSetGroup [airgrp];

_air_unit = units airgrp;

sleep 4;

{deleteVehicle _x} forEach units (airgrp); //<------------ this part does work

{

if (vehicle _x != _x) then {

deletevehicle vehicle _x;

}; //<------------- this part obviously doesnt work

deletevehicle _x;

} foreach units airgrp;

Im trying to call in this as air support through trigger. Now it deletes the pilots and planes crash, but I cant for the life of me get the planes to delete. I just want them to fly around for a bit and then delete after a minute or two making them availible again to recall when needed. Can anybody help me get unstuck?

P.S I know sleep 4 is not long at all. Its that short for testing purposes. ;) lol

Edited by Mikey74

Share this post


Link to post
Share on other sites

thanks for the reply :)

tried that but it doesnt work in my script. I think its not working becuase of the bis spawn group function. just wondering if anyone has figured a way around.

OMG I found the obvious!!!!!!! check it out!!!!

airgrp = CreateGroup West;

airgrp = [[(getmarkerpos "airPoint" select 0), (getmarkerpos "airPoint" select 1), 500], side player, ["I44_Plane_A_P51D_250lb_AAF","I44_Plane_A_P51D_250lb_AAF"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

player hcSetGroup [airgrp];

_air_unit = units airgrp;

sleep 7;

{deleteVehicle _x} forEach units (airgrp);

{deleteVehicle _x} forEach vehicles (airgrp);

I didnt know vehicles worked in there!!!!!! LOL but yeeehawwww it fixed it!!! :D

Edited by Mikey74

Share this post


Link to post
Share on other sites

hm, but this works

airgrp = [[(getmarkerpos "airPoint" select 0), (getmarkerpos "airPoint" select 1), 500], side player, ["A10_US_EP1","A10_US_EP1"],[],[],[],[],[],180] call BIS_fnc_spawnGroup; 

sleep 5;

nul = leader airgrp execVM "deletegroup.sqf"

Oh, you found it yourself. Good solution and easy

Share this post


Link to post
Share on other sites

thanks for the help.

Edited by Mikey74

Share this post


Link to post
Share on other sites

Can anyone help me with a small issue? I have a script that respawns preplaced units, and another script that removes all land, sea and air vehicles with 2 minute intervals if they are empty.  However it seems that if a vehicle has a dead crew member inside of it, the vehicle cleanup script ignores the vehicle and keeps it in the map, which gives a lot of clutter since I've noticed MRAP and snaller un-armored vehicles tend to have their crew die by gunfire while still in the vehicle, so I need a way for the script to either remove the dead bodies  in the vehicle before deleting it, or deleting the bodies with the vehicle. Keep in mind I cant just delete the group or vehicle permanently after its destroted because it won't  respawn, (at least I think, haven't  actually  gotten around to testing that) Heres the script: 

sleep 1260;

_vehicles = nearestObjects [player, ["landvehicle","Air","Ship",], 9999];

{

if (count crew vehicle _x == 0) then {deleteVehicle _x};

} forEach _vehicles;

[] execVM "empty.sqf"  

Edited by MitchyG117
Had to make it clear that "dynamically " spawned units was incorrect for this instance. Its respawning pre-placed units with the Jebus script

Share this post


Link to post
Share on other sites

Very much the same issue dealt with in this thread, though it dealt with vehicle cleanup in a Warfare mission.
 

The problem lies in object reference, prior to the leader realizing a unit is killed and after the leader realizes.  The object reference converts from a group ID to an empty object ID when the leader realizes they're killed.  Once the unit becomes an empty object reference they cannot be removed or deleted from inside the vehicle.

 

It's a matter of identifying early on when the unit is killed, before the leader can realize, whether the killed unit is in a vehicle and getting the vehicle's reference.  When killed in a vehicle, the vehicle has to be deleted rather than the unit.  The vehicle being deleted will also delete the dead crew. 

 

In a killed event handler for the units, get their vehicle, unit type and vehicle type, and passes those on to the script that will do the cleanup.  In the cleanup script, if unit type and vehicle type match, delete the unit.  If they don't match, delete the vehicle.

 

-- edit: --

Also, the Crew command returns dead units.  if (count crew vehicle _x == 0) then {deleteVehicle _x}; won't run when there's dead crew inside, because dead crew do count.  It has to be like: if ({!alive _x} count (crew _vehicle) == 0) then {deleteVehicle _vehicle};

 

Edited by opusfmspol

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  

×