local state = {} local currentAngleX, currentAngleY, currentAngleZ = {},{},{} local rotationToApply = {} local direction, flipSpeed, rollAngle, resetRotation = {},{},{},{} fpsTimer = 0 fpsCounter = 0 fps = 0 fpsEnt = nil function flight_init(e) state[e] = "fly straight" CollisionOff(e) fpsTimer = g_Time + 999 fpsCounter = 0 end function flight_main(e) FreezePlayer() if fpsEnt == nil then fpsEnt = e elseif fpsEnt == e then if g_Time > fpsTimer then fpsTimer = g_Time + 999 fps = fpsCounter fpsCounter = 0 else fpsCounter = fpsCounter + 1 end end if state[e] == "fly straight" then if fps > 0 then _, _, _, currentAngleX[e], currentAngleY[e], currentAngleZ[e] = GetEntityPosAng(e) if g_KeyPressE == 1 or g_KeyPressQ == 1 then rotationToApply[e] = 360 resetRotation[e] = 1 if g_KeyPressE == 1 then direction[e] = -1 else direction[e] = 1 end flipSpeed[e] = 3 rollAngle[e] = "x" state[e] = "roll" elseif g_KeyPressF == 1 or g_KeyPressC == 1 then rotationToApply[e] = 360 resetRotation[e] = 1 if g_KeyPressF == 1 then direction[e] = -1 else direction[e] = 1 end flipSpeed[e] = 3 rollAngle[e] = "z" state[e] = "roll" elseif g_KeyPressA == 1 then RotateY(e,-fps) elseif g_KeyPressD == 1 then RotateY(e, fps) end end elseif state[e] == "roll" then if rotationToApply[e] > 0 then if rollAngle[e] == "z" then RotateZ(e, fps * direction[e] * flipSpeed[e]) elseif rollAngle[e] == "x" then RotateX(e, fps * direction[e] * flipSpeed[e]) end rotationToApply[e] = rotationToApply[e] - flipSpeed[e] else if resetRotation[e] == 1 then SetRotation(e, currentAngleX[e], currentAngleY[e], currentAngleZ[e]) end state[e] = "fly straight" end end PromptLocal(e,state[e].." ; "..fps) end