Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.17 KB | None | 0 0
  1. using GTA;
  2. using GTA.Native;
  3. using System.Windows.Forms;
  4.  
  5. namespace Stance
  6. {
  7.     public class Main : Script
  8.     {
  9.         private Main.Stance currentStance;
  10.  
  11.         public Main()
  12.         {
  13.             this.KeyUp += new KeyEventHandler(this.OnKeyUp);
  14.         }
  15.  
  16.  
  17.         private void OnKeyUp(object sender, KeyEventArgs e)
  18.         {
  19.             if (this.currentStance == Main.Stance.Standing)
  20.             {
  21.                 if (e.KeyCode != StanceSettings.stanceKey)
  22.                     return;
  23.                     this.SetStance(Main.Stance.Crouching);
  24.             }
  25.             else if (this.currentStance == Main.Stance.Crouching)
  26.             {
  27.                 if (e.KeyCode != StanceSettings.stanceKey)
  28.                     return;
  29.                     this.SetStance(Main.Stance.Standing);
  30.             }
  31.         }
  32.  
  33.  
  34.         private void Requests()
  35.         {
  36.             Function.Call(Hash._0x6EA47DAE7FAD0EED, (InputArgument)"move_ped_crouched");
  37.             Function.Call(Hash._0x6EA47DAE7FAD0EED, (InputArgument)"move_ped_crouched_strafing");
  38.         }
  39.  
  40.  
  41.         private void StanceChanger()
  42.         {
  43.             if (this.currentStance == Main.Stance.Standing)
  44.             {
  45.                 if (Game.IsControlPressed(0, GTA.Control.Duck))
  46.                 {
  47.                         this.SetStance(Main.Stance.Crouching);
  48.                 }
  49.             }
  50.             else if (this.currentStance == Main.Stance.Crouching)
  51.             {
  52.                 if (Game.IsControlPressed(0, GTA.Control.Duck))
  53.                 {
  54.                         this.SetStance(Main.Stance.Standing);
  55.                 }
  56.             }
  57.         }
  58.  
  59.         private void SetStance(Main.Stance stance)
  60.         {
  61.             switch (stance)
  62.             {
  63.                 case Main.Stance.Standing:
  64.                     Function.Call(Hash._0xAA74EC0CB0AAEA2C, (InputArgument)Game.Player.Character, (InputArgument)1048576000);
  65.                     Function.Call(Hash._0x20510814175EA477, (InputArgument)Game.Player.Character);
  66.                     Game.Player.Character.Task.ClearAll();
  67.                     this.currentStance = Main.Stance.Standing;
  68.                     break;
  69.                 case Main.Stance.Crouching:
  70.                     Function.Call(Hash._0xAF8A94EDE7712BEF, (InputArgument)Game.Player.Character, (InputArgument)"move_ped_crouched", (InputArgument)1048576000);
  71.                     Function.Call(Hash._0x29A28F3F8CF6D854, (InputArgument)Game.Player.Character, (InputArgument)"move_ped_crouched_strafing");
  72.                     Game.Player.Character.Task.ClearAll();
  73.                     this.currentStance = Main.Stance.Crouching;
  74.                     break;
  75.             }
  76.         }
  77.  
  78.         private enum Stance
  79.         {
  80.             Standing,
  81.             Crouching,
  82.  
  83.         }
  84.     }
  85. }
  86.  
  87. namespace Stance
  88. {
  89.     public class StanceSettings : Script
  90.     {
  91.         private ScriptSettings iniFile;
  92.         public static Keys stanceKey;
  93.  
  94.         public StanceSettings()
  95.         {
  96.             this.iniFile = ScriptSettings.Load("scripts//Stance.ini");
  97.             StanceSettings.stanceKey = this.iniFile.GetValue<Keys>("Keys", nameof(stanceKey), Keys.J);
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement