Fr3eMan 16 Posted June 7, 2018 I usually delete vehicle by trigger with a below script, but I recognise this script cancel only the vehicle and not the crew, I have to run twice for let delete first the vehicle than the crew, and the problem is not the deletion of the trigger, is happen anyway, any suggestion? _trigger = createTrigger ["EmptyDetector",[4000,4000,0]]; _trigger setTriggerArea [1,1,0,false,-1]; _trigger setTriggerActivation ["ANYPLAYER","NOT PRESENT",true]; _trigger setTriggerStatements ["this","{deleteVehicle _x} forEach nearestObjects [thisTrigger, ['O_MBT_02_cannon_F','O_crew_F'], 10000];deleteVehicle thisTrigger;",""]; Share this post Link to post Share on other sites
KC Grimes 79 Posted June 7, 2018 Something to note is that "vehicle player == player" is true when on foot, but false when in a vehicle. nearestObjects, and similar commands, does not detect crew members of a vehicle. You will have to crew the vehicle for a list of units inside. Also note that "(crew player) select 0 == player" is true. Also consider using nearEntities instead of nearestObjects. Depending on what you are doing, it may be much faster. Ex. Obtain an array of all living men within a given radius from a given center point, including those within certain kinds of vehicles. G_fnc_menWithinRadius = { params ["_centerObj", "_radius"]; //Get array of all alive men and appropriate vehicles within defined radius of center object private _arrayAll = _centerObj nearEntities [["Man", "Car", "Tank", "Helicopter", "Plane", "Ship"], _radius]; //Cycle through all objects and find the men to add to array of men to be returned private _arrayReturn = []; { //_x is object //Determine how to handle alive object if (_x isKindOf "Man") then { //Object is man, add to array _arrayReturn pushBack _x; } else { //Object is vehicle //Cycle through crew to pick out man { //_x is crew member //Make sure crew member is alive if (alive _x) then { //Crew member is alive, add to array _arrayReturn pushBack _x; }; } forEach crew _x; }; } forEach _arrayAll; _arrayReturn; }; 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted June 7, 2018 {deleteVehicle _x} foreach crew _x; deletevehicle _x; If there is no crew, crew _x is an empty array but forEach doesn't return an error. So keep it simple. 1 Share this post Link to post Share on other sites
Fr3eMan 16 Posted June 7, 2018 Thanks @KC Grimes and @pierremgi both answer are very useful, I solved and optimize the script. 1 Share this post Link to post Share on other sites