Heavensrevenger 1 Posted January 7 Hello i want to run a code on every member of a vehicle (Turrets, cars, tanks, planes, helos, boats and basically everything that can be entered). I have the following code for this: _vehicle = nearestObjects [player, ["AllVehicles"], 200]; { if (damage _x < 0.5 ) then { _x setdammage (damage _x + 0.1); }; } forEach crew _vehicle; But the code always tells me that in the forEach crew _vehicle; it expects an object not an array. I'm unsure how to do this. Do I have to do this: _vehicle = nearestObjects [player, ["AllVehicles"], 200]; { { if (damage _x < 0.5 ) then { _x setdammage (damage _x + 0.1); }; } forEach crew _x; } forEach _vehicle; or is there a better way? Also is the "AllVehicles" class the correct one or should I use a different one? Share this post Link to post Share on other sites
pierremgi 4889 Posted January 7 _vehicle = nearestObjects [player, ["AllVehicles"], 200]; is confusing because it's an array of vehicles. Say _vehicles is more appropriate but you can do what you want. Anyway, you can also use a single : {... } forEach flatten crew _vehicles That's for answering your question. Now, for the aim I guess, you should probably use the EH "handleDamage". (to be confirmed by your goal). 2 Share this post Link to post Share on other sites
Heavensrevenger 1 Posted January 12 I've run into a problem I'm not sure how to fix _vehicles = nearestObjects [player, ["Ship", "LandVehicle", "Helicopter", "Plane"], 200]; This returns the "crew" AI of drones, so running the code will kill the drones "crew" so they are basically useless. Is there a way to exclude classes? i tried !"B_UAV_AI" but that doesnt work Share this post Link to post Share on other sites
pierremgi 4889 Posted January 13 private _vehicles = nearestObjects [player, ["Ship", "LandVehicle", "Helicopter", "Plane"], 200]; _vehicles = _vehicles select {getText (configOf _x / "vehicleClass") != "Autonomous"}; 1 Share this post Link to post Share on other sites
Heavensrevenger 1 Posted January 13 Thank you! This works great Share this post Link to post Share on other sites