Jump to content
FredTche

Deleting Vehicle Crew

Recommended Posts

Im working on a mission that starts with an Opfor helo insertion. In order to delete the helo after the insertion, I placed a waypoint for it inside a trigger. The trigger activates the following: " deleteVehicle heli " (heli is the helicopter's name) once any opfor units (specifically heli itself) enter it. The helicopter gets deleted when it reaches the trigger but its crew just falls on the water. How can the trigger also activate the deletion of the helicopter's pilot and co-pilot?

Share this post


Link to post
Share on other sites

In the trigger on Act, put this:

 {deleteVehicle _x;}forEach crew heli;deleteVehicle heli;

By doing this you will take care of the helicopter but first you will remove the crew.

Share this post


Link to post
Share on other sites

Should "_x" be exchanged for the name of the vehicle?

Share this post


Link to post
Share on other sites
Should "_x" be exchanged for the name of the vehicle?
No. _x is the variable used to delete each crew member in the heli. i.e. Pilot. co-Pilot and door gunners etc.

Be aware any player in the heli will NOT be deleted. They will just end up in the air and fall to the ground.

Share this post


Link to post
Share on other sites
Should "_x" be exchanged for the name of the vehicle?

_x is the current element that is being looped when using foreach on a array

Share this post


Link to post
Share on other sites

Thanks for the help! The trigger worked perfectly!

Share this post


Link to post
Share on other sites

Hey guys,

 

It looks like I am running into a similar issue as the OP but it looks like the same solution is giving me different results.  Has deleteVehicle changed in the way it works since this post was written?  I have 2 triggers to spawn and delete a unit when I walk into it: spawnTrigger and deleteTrigger

 

spawnTrigger on activation calls myscript.sqf

squad1 = [getmarkerpos "squadSpawn", West, ["B_Heli_Transport_03_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

deleteTrigger on activation calls deleteScript.sqf

{deleteVehicle _x;}forEach units squad1;
deleteVehicle squad1;

The above delete script will delete the crew but not the helo.  The crew will get deleted and then the helo will just crash to the ground!  If I try:

{deleteVehicle _x;}forEach crew squad1;
deleteVehicle squad1;

Nothing happens at all.  Am I doing something incorrectly?  Or has deleteVehicle slightly changed in the way it works since this post was written? Thank you for your help!

Share this post


Link to post
Share on other sites

BIS_fnc_spawnGroup returns a group not the vehicle or any units.

 

Thefore:

{deleteVehicle _x;}forEach units squad1; //Will delete all units inside that group
deleteVehicle squad1; // Will delete nothing, since squad1 is a group not an object.

 

Solution:

deleteVehicle (vehicle ((units squad1) select 0)); // Looks complicated but it basically looks for the vehicle, the first unit of group squad1 has and deletes it
{ deleteVehicle _x} forEach units squad1;
  • Like 1

Share this post


Link to post
Share on other sites

 

BIS_fnc_spawnGroup returns a group not the vehicle or any units.

 

Thefore:

{deleteVehicle _x;}forEach units squad1; //Will delete all units inside that group

deleteVehicle squad1; // Will delete nothing, since squad1 is a group not an object.

 

Solution:

deleteVehicle (vehicle ((units squad1) select 0)); // Looks complicated but it basically looks for the vehicle, the first unit of group squad1 has and deletes it
{ deleteVehicle _x} forEach units squad1;

 

Not always is the vehicle (units squad1) select 0 can happen that the mod config defined different or even there can be more vehicles in one group.

 

I am always trying to define the vehicle right after spawn.

_vehicle = vehicle leader squad1;
{deleteVehicle _x} forEach crew _vehicle + [_vehicle];

Share this post


Link to post
Share on other sites

 

BIS_fnc_spawnGroup returns a group not the vehicle or any units.

 

Thefore:

{deleteVehicle _x;}forEach units squad1; //Will delete all units inside that group

deleteVehicle squad1; // Will delete nothing, since squad1 is a group not an object.

 

Solution:

deleteVehicle (vehicle ((units squad1) select 0)); // Looks complicated but it basically looks for the vehicle, the first unit of group squad1 has and deletes it
{ deleteVehicle _x} forEach units squad1;

Thank you very much for your help, this worked perfectly.

Share this post


Link to post
Share on other sites

Hello i have a Question, idk if im right here but i would like to delete a group of ground Units when i walk into the trigger is that even possible?
 

Share this post


Link to post
Share on other sites

Well, you kind of necroed an old thread with an off-topic question, but this would be the way to go. 

  • Haha 1

Share this post


Link to post
Share on other sites

I'm trying to use that code for any unit going in the trigger but if I use a generic variable _unitName instead of heli1, it won't work even if i have the same value returned by the hint...

unitName = vehicleVarName (thisList select 0);
hint _unitName; // return "heli1"
{deleteVehicle _x;}forEach crew heli1;
deleteVehicle heli1;

Any explanation of this ? range of variables issue ? Type of variable ?
Thanks 😢

Share this post


Link to post
Share on other sites

I doubt that this line

hint _unitName; // return "heli1"

gives you the hint of what this line did before

unitName = vehicleVarName (thisList select 0);

you mix global and local variables

 

also for deleting you use heli1 and not the object from thisList.

 

and

 it won't work

is not the thing one can work with. its just too specific...

 

maybe this works:

private dummy =
{
 deleteVehicleCrew _x;
 deleteVehicle _x;
} count ( thisList apply {vehicleVarName _x} );

 

Edited by sarogahtyp
potential solution added

Share this post


Link to post
Share on other sites

vehicleVarName returns a string! So what for?
 

7 hours ago, Skip McCormick said:

I'm trying to use that code for any unit going in the trigger

 

trigger anyBody present repeatable, but you must "rearm" it.

on condition field:

this && isNil "blahblah"

in on activation field:

blahblah = TRUE; {_veh = _x; {_veh deleteVehicleCrew _x} forEach crew _veh; deleteVehicle _veh} count thisList

in on deact. field:

0 = [] spawn {sleep 1; blahblah = nil};

 

Note: That doesn't matter if you are using the deleteVehicleCrew on infantry. NO error is returned. Don't waste code with filter for vehicles or infantry (except if you want to delete vehicles only...)

You can use BLUFOR present or else instead of anybody present.

Why rearming the trigger? because, even if you delete the unit/vehicle, the trigger fires on condition which is checked twice a second. that means the presence of units can be OK, so the trigger fires and delete it but a unit or more can penetrate the area after this deletion and before the next check. So the trigger's condition stays OK and the trigger doesn't fire again. You need to make it deactivated then reactivated. It's very sensible for the "anybody present" example, because there are so much possibilities (men, vehicles, crates, rabbits... you can't imagine what anybody means...) but you can have an idea:
in condition field:
hint str thisList; this

remove all on act. and on deact. field, just for keeping thisList as checked.

Share this post


Link to post
Share on other sites

In fact, i just used vehicle instead of vehicleVarName since the expected type is an object and not a string. And it seems to work in a repeatable trigger.
I made that clear with typeName https://community.bistudio.com/wiki/typeName

However, you'll probably tell me there is a reason for not doing this way:

_leavingUnit = vehicle (thisList select 0);  
{deleteVehicle _x;}forEach crew _leavingUnit;  
deleteVehicle _leavingUnit;

 

 

And this seems to work as well probably better with:

blahblah = TRUE; {_veh = _x; {_veh deleteVehicleCrew _x} forEach crew _veh; deleteVehicle _veh} count thisList

 

But i dont get this rearming code, why && isNil "blahblah" ? 😐

this && isNil "blahblah"
PS: Okay i just saw your edited notes !
Thank you very much for your implication 🙂 Keeps up the motivation to learn

Share this post


Link to post
Share on other sites
15 hours ago, sarogahtyp said:

 [...]

Thanks for your answer too but you missed my point:
"if I use a generic variable _unitName instead of heli1, it won't work "

I also found interesting materials with
 

FOR UNITS

UnitsEraser = allUnits inAreaArray tigre;
{deleteVehicle _x} forEach UnitsEraser;

FOR VEHICLES

VehiclesEraser = vehicles inAreaArray tigre;
{deleteVehicle _x} forEach VehiclesEraser;

FOR DEAD BODIES

CorpseEraser = allDead inAreaArray tigre;
{deleteVehicle _x} forEach CorpseEraser;



https://steamcommunity.com/app/107410/discussions/17/135510194253178544/

Share this post


Link to post
Share on other sites
15 minutes ago, Skip McCormick said:

Thanks for your answer too but you missed my point:
"if I use a generic variable _unitName instead of heli1, it won't work "

 

I did not miss that.

what I missed was that vehicleVarName is nonsense in this context and that the alternative syntax of deleteVehicleCrew will only work after the next arma update (2-06).

Share this post


Link to post
Share on other sites
1 minute ago, sarogahtyp said:

 

I did not miss that.

what I missed was that vehicleVarName is nonsense in this context and that the alternative syntax of deleteVehicleCrew will only work after the next arma update (2-06).

Yes indeed, vehicleVarName was the thing that I did not understood properly and that was the issue i was looking for. 🙂

Share this post


Link to post
Share on other sites

I spawn a radar and SAM site (MIM-145 Defender) and I want to delete the crew, the vehicle and the group after some time. 

radarA = [[13720.5,4176.29,0], 0, "B_Radar_System_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (radarA select 0); 
(radarA select 0) setVehicleRadar 1;
(radarA select 0) setVehicleReportRemoteTargets true;
samA = [[13469,4237.99,0], 0, "B_SAM_System_03_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (samA select 0);  
(samA select 0) setVehicleReceiveRemoteTargets true;

crossroad sideChat "We have intel enemy SAM site is deployed!";
sleep 600;
deleteVehicleCrew radarA;
deleteVehicleCrew samA;
deleteVehicle radarA;
deleteVehicle samA;
sleep 60;
//delete the group ??

 But how to delete the group? 
if 

deleteGroup (radarA select 2);

is the right way, do I need to delete the arrays radarA and samA, so I can spawn the same after some time? 

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

×