Guest User

Untitled

a guest
Apr 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. looking_up = 0
  2. looking_down = 0
  3. looking_left = 0
  4. looking_right = 0
  5.  
  6. ysens = CreateConVar("y_sens", "0.5")
  7. xsens = CreateConVar("x_sens", "0.5")
  8.  
  9. function upStart(player,command,args)
  10.     if looking_up == 0 then
  11.         hook.Add("CreateMove", "ViewFix", ViewFix)
  12.         looking_up = 1
  13.     end
  14. end
  15.  
  16. function upStop(player,command,args)
  17.     looking_up = 0
  18.     if looking_up == 0 & looking_down == 0 & looking_left == 0 & looking_right ==0 then
  19.         hook.Remove("CreateMove", "ViewFix")
  20.     end
  21. end
  22.  
  23. function downStart(player,command,args)
  24.     if looking_down == 0 then
  25.         hook.Add("CreateMove", "ViewFix", ViewFix)
  26.         looking_down = 1
  27.     end
  28. end
  29.  
  30. function downStop(player,command,args)
  31.     looking_down = 0
  32.     if looking_up == 0 & looking_down == 0 & looking_left == 0 & looking_right ==0 then
  33.         hook.Remove("CreateMove", "ViewFix")
  34.     end
  35. end
  36.  
  37.  
  38.  
  39.  
  40. function leftStart(player,command,args)
  41.     if looking_left == 0 then
  42.         hook.Add("CreateMove", "ViewFix", ViewFix)
  43.         looking_left = 1
  44.     end
  45. end
  46.  
  47. function leftStop(player,command,args)
  48.     looking_left = 0
  49.     if looking_up == 0 & looking_down == 0 & looking_left == 0 & looking_right ==0 then
  50.         hook.Remove("CreateMove", "ViewFix")
  51.     end
  52. end
  53.  
  54. function rightStart(player,command,args)
  55.     if looking_right == 0 then
  56.         hook.Add("CreateMove", "ViewFix", ViewFix)
  57.         looking_right = 1
  58.     end
  59. end
  60.  
  61. function rightStop(player,command,args)
  62.     looking_right = 0
  63.     if looking_up == 0 & looking_down == 0 & looking_left == 0 & looking_right ==0 then
  64.         hook.Remove("CreateMove", "ViewFix")
  65.     end
  66. end
  67.  
  68. function ViewFix(cmd)
  69.     local pitch = LocalPlayer():EyeAngles().p
  70.     local yaw = LocalPlayer():EyeAngles().y
  71.     local roll = LocalPlayer():EyeAngles().r
  72.     local y = ysens:GetFloat()
  73.     local x = xsens:GetFloat()
  74.    
  75.     if looking_up==1 then
  76.         pitch = pitch-y
  77.     elseif looking_down==1 then
  78.         pitch = pitch+y
  79.     end
  80.    
  81.     if looking_left==1 then
  82.         yaw = yaw+x
  83.     elseif looking_right==1 then
  84.         yaw = yaw-x
  85.     end
  86.    
  87.     local fPitch = math.Clamp(pitch, -180, 180)
  88.     local fAng = Angle(fPitch, yaw, roll)
  89.     cmd:SetViewAngles(fAng)
  90. end
  91.  
  92.  
  93. -- Console commands
  94. concommand.Add("+up",upStart)
  95. concommand.Add("-up",upStop)
  96. concommand.Add("+down",downStart)
  97. concommand.Add("-down",downStop)
  98. concommand.Add("+right2",rightStart)
  99. concommand.Add("-right2",rightStop)
  100. concommand.Add("+left2",leftStart)
  101. concommand.Add("-left2",leftStop)
Add Comment
Please, Sign In to add comment