Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Native;
- using System;
- using System.Windows.Forms;
- namespace LooseAimingToggle
- {
- public class LooseAimingToggle : Script
- {
- enum AimState
- {
- NoAim = 0,
- LooseAim,
- FullAim
- }
- AimState state = AimState.NoAim;
- public LooseAimingToggle()
- {
- Tick += OnTick;
- KeyUp += OnKeyUp;
- Interval = 10;
- }
- void OnTick(object sender, EventArgs e)
- {
- if (!Game.Player.Character.IsDead && Game.Player.Character.IsOnFoot && Function.Call<bool>(Hash.IS_PED_ARMED, Game.Player.Character, 4))
- {
- if (state == AimState.LooseAim)
- {
- Game.SetControlNormal(2, GTA.Control.Attack, 0.5f);
- }
- else if (state == AimState.FullAim)
- {
- Game.SetControlNormal(2, GTA.Control.Aim, 1.0f);
- }
- HandleToggleControls();
- }
- else
- {
- state = AimState.NoAim;
- }
- //UI.ShowSubtitle(state.ToString());
- }
- void HandleToggleControls()
- {
- if (IsKeyboard())
- {
- if (Game.IsControlJustPressed(2, GTA.Control.VehicleAim))
- {
- if (state == AimState.NoAim)
- {
- state = AimState.LooseAim;
- }
- else if (state == AimState.LooseAim)
- {
- state = AimState.FullAim;
- }
- else if (state == AimState.FullAim)
- {
- state = AimState.NoAim;
- }
- }
- }
- }
- bool IsKeyboard()
- {
- return Game.CurrentInputMode == InputMode.MouseAndKeyboard;
- }
- void OnKeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.ShiftKey)
- {
- state = AimState.NoAim;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement