remove_attached_objects.sqf 638 B

123456789101112131415161718192021222324252627282930
  1. params["_obj"];
  2. //if _obj null
  3. if (isNull _obj) exitWith {};
  4. //for each object attached to this obj, delete crew and delete the vic
  5. {
  6. _outer=_x;
  7. {_obj deleteVehicleCrew _x;} forEach (crew _x);
  8. detach _outer;
  9. deleteVehicle _outer;
  10. } forEach (attachedObjects _obj);
  11. //if _obj null
  12. if (isNull _obj) exitWith {};
  13. //delete watever this thing is attached to but crew first
  14. _obj_attached_to=attachedTo _obj;
  15. //if there is stuff attached to the parent,
  16. if(!(isNull _obj_attached_to)) then{
  17. {_obj_attached_to deleteVehicleCrew _x;} forEach (crew _obj_attached_to);
  18. deleteVehicle _obj_attached_to;
  19. };
  20. deleteVehicle attachedTo _obj;