_Plane = _this select 0

_up = 0

#MainLoop
?(not alive _Plane): exit


; Get the speed and height
_z = (GetPos _Plane) select 2
_spd = speed _Plane
?((_spd >= 40) && (_z >= 40) && (_up == 0)): goto "RaiseGear"
?((_spd <= 200) && (_z <= 40) && (_up == 1)): goto "LowerGear"

goto "MainLoop"

#RaiseGear
_up = 1
[_Plane] exec "\BWC_MIII\scr\Gearup.sqs"
~2
goto "MainLoop"

#LowerGear
_up = 0
[_Plane] exec "\BWC_MIII\scr\Geardown.sqs"
~2
goto "MainLoop"
