U = U or require "scriptbank\\utillib" Q = Q or require "scriptbank\\quatlib" local rotating = 0 local rotSpeed = 3 local spacePressed = false function rotationcontroller_init(e) end function rotationcontroller_main(e) if U.PlayerLookingNear(e, 200, 40) == true then if g_KeyPressSPACE == 1 then if spacePressed == false then spacePressed = true if rotating ~= e then rotating = e SetFreezePosition(g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ) SetFreezeAngle(g_PlayerAngX,g_PlayerAngY,g_PlayerAngZ) else rotating = 0 end else spacePressed = false end end if rotating == e then local xrot,yrot,zrot = GetEntityAngleX(e),GetEntityAngleY(e),GetEntityAngleZ(e) local nxrot = math.rad(xrot) local nyrot = math.rad(yrot) local nzrot = math.rad(zrot) local q1 = Q.FromEuler(nxrot,nyrot,nzrot) if g_KeyPressW == 1 then xrot = -rotSpeed elseif g_KeyPressS == 1 then xrot = rotSpeed else xrot = 0 end if g_KeyPressA == 1 then yrot = -rotSpeed elseif g_KeyPressD == 1 then yrot = rotSpeed else yrot = 0 end if g_KeyPressQ == 1 then zrot = rotSpeed elseif g_KeyPressE == 1 then zrot = -rotSpeed else zrot = 0 end local nxrot2 = math.rad(xrot) local nyrot2 = math.rad(yrot) local nzrot2 = math.rad(zrot) local q2 = Q.FromEuler(nxrot2,nyrot2,nzrot2) local q3 = Q.Mul( q1, q2 ) local rotx,roty,rotz = QuatToEuler( q3.x, q3.y, q3.z, q3.w ) rotx = math.deg(rotx) roty = math.deg(roty) rotz = math.deg(rotz) CollisionOff(e) SetRotation(e,rotx,roty,rotz) TransportToFreezePosition() PromptLocal(e,"x = "..rotx.." , y = "..roty.." , z = "..rotz) else PromptLocal(e,"Press SPACE to start rotating") end end end