Advertisement
Guest User

Suppressor On / Off Source Code

a guest
Jan 7th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using GTA;
  2. using System;
  3. using System.Windows.Forms;
  4. using GTA.Math;
  5. using GTA.Native;
  6.  
  7. public class sprsr_onOff : Script
  8. {
  9.     ScriptSettings config;
  10.     string text;
  11.  
  12.     private bool supp;
  13.     private Keys SuppressorOn;
  14.  
  15.     private bool supp2;
  16.     private Keys SuppressorOff;
  17.  
  18.     public sprsr_onOff()
  19.     {
  20.         KeyUp += OnKeyUp;
  21.  
  22.         Interval = 10;
  23.  
  24.         config = ScriptSettings.Load("scripts\\SupressorOn_Off.ini"); //For the config
  25.         SuppressorOn = config.GetValue<Keys>("Options", "SuppressorOn", Keys.O); //For the config
  26.  
  27.         config = ScriptSettings.Load("scripts\\SupressorOn_Off.ini"); //For the config
  28.         SuppressorOff = config.GetValue<Keys>("Options", "SuppressorOff", Keys.I); //For the config
  29.     }
  30.  
  31.     void OnKeyUp(object sender, KeyEventArgs e)
  32.     {
  33.         Ped p = Game.Player.Character; //Define variable for the player's character
  34.         if (e.KeyCode == SuppressorOn) //To turn suppressor on
  35.         {
  36.             p.Weapons.Current.SetComponent(WeaponComponent.AtArSupp, true);
  37.             p.Weapons.Current.SetComponent(WeaponComponent.AtArSupp02, true);
  38.             p.Weapons.Current.SetComponent(WeaponComponent.AtPiSupp, true);
  39.             p.Weapons.Current.SetComponent(WeaponComponent.AtPiSupp02, true);
  40.             p.Weapons.Current.SetComponent(WeaponComponent.AtSrSupp, true);
  41.         }
  42.         if (e.KeyCode == SuppressorOff) //To turn suppressor off
  43.         {
  44.             p.Weapons.Current.SetComponent(WeaponComponent.AtArSupp, false);
  45.             p.Weapons.Current.SetComponent(WeaponComponent.AtArSupp02, false);
  46.             p.Weapons.Current.SetComponent(WeaponComponent.AtPiSupp, false);
  47.             p.Weapons.Current.SetComponent(WeaponComponent.AtPiSupp02, false);
  48.             p.Weapons.Current.SetComponent(WeaponComponent.AtSrSupp, false);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement