Advertisement
Guest User

NoAutoCenterCam(KeyboardOnly)

a guest
Jan 22nd, 2017
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.45 KB | None | 0 0
  1. using GTA; // This is a reference that is needed! do not edit this
  2. using GTA.Native; // This is a reference that is needed! do not edit this
  3. using GTA.Math;
  4. using System; // This is a reference that is needed! do not edit this
  5. using System.Windows.Forms; // This is a reference that is needed! do not edit this
  6.  
  7. namespace NeverAutoCenterCamera
  8. {
  9.     public class NeverAutoCenterCamera : Script // declare Modname as a script
  10.     {
  11.  
  12.         bool ModEnabled = true;
  13.        
  14.         int SendInputTimer;
  15.         static int WaitTimer = 100;
  16.         bool SlightLeft;
  17.  
  18.         public NeverAutoCenterCamera() // main function
  19.         {
  20.             Tick += OnTick;
  21.             KeyDown += OnKeyDown;
  22.             KeyUp += OnKeyUp;
  23.  
  24.             Interval = 0;
  25.         }
  26.  
  27.         void OnTick(object sender, EventArgs e) // This is where most of your script goes
  28.         {
  29.             if (ModEnabled)
  30.             {
  31.                 if (!IsMouseMoving() && !Game.IsPaused)
  32.                 {
  33.                     if (SendInputTimer < Game.GameTime)
  34.                     {
  35.                         if (SlightLeft)
  36.                         {
  37.                             MoveCamSlightly(true);
  38.                             SendInputTimer = Game.GameTime + WaitTimer;
  39.                             SlightLeft = false;
  40.                         }
  41.                         else
  42.                         {
  43.                             MoveCamSlightly(false);
  44.                             SendInputTimer = Game.GameTime + WaitTimer;
  45.                             SlightLeft = true;
  46.                         }
  47.                     }
  48.                 }
  49.             }
  50.         }
  51.  
  52.         bool IsMouseMoving()
  53.         {
  54.             if (Game.GetControlNormal(2, GTA.Control.LookUpDown) == 0 && Game.GetControlNormal(2, GTA.Control.LookLeftRight) == 0)
  55.             {
  56.                 return false;
  57.             }
  58.             return true;
  59.         }
  60.  
  61.         bool IsKeyboard()
  62.         {
  63.             return Game.CurrentInputMode == InputMode.MouseAndKeyboard;
  64.         }
  65.  
  66.         void MoveCamSlightly(bool left)
  67.         {
  68.             if (IsKeyboard())
  69.             {
  70.                 float input = (left ? 0.2501f : -0.2501f);
  71.                 Game.SetControlNormal(2, GTA.Control.LookLeftRight, input);
  72.             }
  73.         }
  74.  
  75.         void OnKeyDown(object sender, KeyEventArgs e)
  76.         {
  77.         }
  78.  
  79.         void OnKeyUp(object sender, KeyEventArgs e)
  80.         {
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement