Advertisement
Guest User

LooseAimingToggle

a guest
Mar 22nd, 2018
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using GTA;
  2. using GTA.Native;
  3. using System;
  4. using System.Windows.Forms;
  5.  
  6. namespace LooseAimingToggle
  7. {
  8.     public class LooseAimingToggle : Script
  9.     {
  10.         enum AimState
  11.         {
  12.             NoAim = 0,
  13.             LooseAim,
  14.             FullAim
  15.         }
  16.  
  17.         AimState state = AimState.NoAim;
  18.  
  19.         public LooseAimingToggle()
  20.         {
  21.             Tick += OnTick;
  22.             KeyUp += OnKeyUp;
  23.  
  24.             Interval = 10;
  25.         }
  26.  
  27.         void OnTick(object sender, EventArgs e)
  28.         {
  29.             if (!Game.Player.Character.IsDead && Game.Player.Character.IsOnFoot && Function.Call<bool>(Hash.IS_PED_ARMED, Game.Player.Character, 4))
  30.             {
  31.                 if (state == AimState.LooseAim)
  32.                 {
  33.                     Game.SetControlNormal(2, GTA.Control.Attack, 0.5f);
  34.                 }
  35.                 else if (state == AimState.FullAim)
  36.                 {
  37.                     Game.SetControlNormal(2, GTA.Control.Aim, 1.0f);
  38.                 }
  39.  
  40.                 HandleToggleControls();
  41.             }
  42.             else
  43.             {
  44.                 state = AimState.NoAim;
  45.             }
  46.  
  47.             //UI.ShowSubtitle(state.ToString());
  48.         }
  49.  
  50.         void HandleToggleControls()
  51.         {
  52.             if (IsKeyboard())
  53.             {
  54.                 if (Game.IsControlJustPressed(2, GTA.Control.VehicleAim))
  55.                 {
  56.                     if (state == AimState.NoAim)
  57.                     {
  58.                         state = AimState.LooseAim;
  59.                     }
  60.                     else if (state == AimState.LooseAim)
  61.                     {
  62.                         state = AimState.FullAim;
  63.                     }
  64.                     else if (state == AimState.FullAim)
  65.                     {
  66.                         state = AimState.NoAim;
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.  
  72.         bool IsKeyboard()
  73.         {
  74.             return Game.CurrentInputMode == InputMode.MouseAndKeyboard;
  75.         }
  76.  
  77.         void OnKeyUp(object sender, KeyEventArgs e)
  78.         {
  79.             if (e.KeyCode == Keys.ShiftKey)
  80.             {
  81.                 state = AimState.NoAim;
  82.             }
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement