greentumbleweed Posted February 23, 2018 Share Posted February 23, 2018 function rotateCameraRight() if getKeyState( "mouse1" ) == false then removeEventHandler("onClientPreRender", root, rotateCameraRight) else setTimer (function() setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 0.08)) setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) - 0.08)) end, 50, 1 ) setCameraMatrix (x, y+0.8, z, lx, ly, lz) setCameraTarget ( localPlayer ) if not isTimer(timer_right) then timer_left = setTimer ( timer_l, 850, 1 ) end end end function timer_l() removeEventHandler("onClientPreRender", root, rotateCameraRight) addEventHandler("onClientPreRender", root, rotateCameraLeft) end function rotateCameraLeft() if getKeyState( "mouse1" ) == false then removeEventHandler("onClientPreRender", root, rotateCameraLeft) else setTimer ( function() setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) - 0.08)) setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 0.08)) end, 50, 1 ) setCameraMatrix (x, y-0.8, z, lx, ly, lz) setCameraTarget ( localPlayer ) if not isTimer(timer_left) then timer_right = setTimer ( timer_r, 900, 1 ) end end end function timer_r() removeEventHandler("onClientPreRender", root, rotateCameraLeft) addEventHandler("onClientPreRender", root, rotateCameraRight) end function addEvent() local weapon = getPedWeapon(localPlayer) if (weapon==34) or (weapon==31) or (weapon==30) or (weapon==6) then addEventHandler("onClientPreRender", root, rotateCameraRight) end end bindKey("mouse1", "down", addEvent) bind = true so i made this code trying to make something similar to h1z1 horizontal recoil, but it only goes left. I need it to go left or right randomly but never repeat left or repeat right. Link to comment
Moderators IIYAMA Posted February 23, 2018 Moderators Share Posted February 23, 2018 local rotationDirection = "right" -- function scope ... if rotationDirection == "right" then rotationDirection = "left" setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) + 0.08)) else rotationDirection = "right" setPedCameraRotation(localPlayer, -(getPedCameraRotation(localPlayer) - 0.08)) end -- end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now