Advertisement
Eddlm

Realistic Nitro 1.1

Jan 9th, 2016
2,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.89 KB | None | 0 0
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Windows.Forms;
  7.  
  8.  
  9.  
  10. public class RealisticNitro : Script
  11. {
  12.  
  13.     List<string> Exhausts = new List<string>
  14.     {
  15.         "exhaust","exhaust_2","exhaust_3","exhaust_4","exhaust_5","exhaust_6","exhaust_7"
  16.     };
  17.     Keys NitroKey = Keys.ShiftKey;
  18.     GTA.Control PadNitroKey = GTA.Control.ScriptSelect;
  19.     GTA.Control SecondPadNitroKey = GTA.Control.ScriptSelect;
  20.  
  21.     bool NitroSound = false;
  22.     bool NitroScreenEffect = false;
  23.     bool OnlyWhileAccelerating = false;
  24.     bool OnlyLandVehicles = true;
  25.     public RealisticNitro()
  26.     {
  27.         Tick += OnTick;
  28.         KeyDown += OnKeyDown;
  29.         KeyUp += OnKeyUp;
  30.         LoadSettings();
  31.     }
  32.  
  33.     void LoadSettings()
  34.     {
  35.         ScriptSettings config = ScriptSettings.Load(@"scripts\RealisticNitro.ini");
  36.         NitroSound = config.GetValue<bool>("SETTINGS", "NitroSound", false);
  37.         NitroScreenEffect = config.GetValue<bool>("SETTINGS", "NitroScreenEffect", true);
  38.         OnlyWhileAccelerating = config.GetValue<bool>("SETTINGS", "OnlyWhileAccelerating", false);
  39.         OnlyLandVehicles = config.GetValue<bool>("SETTINGS", "OnlyLandVehicles", true);
  40.  
  41.         PadNitroKey = config.GetValue<GTA.Control>("SETTINGS", "PadNitroKey", GTA.Control.ScriptSelect);
  42.         SecondPadNitroKey = config.GetValue<GTA.Control>("SETTINGS", "SecondPadNitroKey", GTA.Control.ScriptSelect);
  43.  
  44.         NitroKey = config.GetValue<Keys>("SETTINGS", "NitroKey", Keys.ShiftKey);
  45.     }
  46.  
  47.     void OnTick(object sender, EventArgs e)
  48.     {
  49.         if (Game.Player.Character.IsSittingInVehicle())
  50.         {
  51.             if ((OnlyLandVehicles && !IsBoat(GetLastVehicle(Game.Player.Character)) && !IsPlane(GetLastVehicle(Game.Player.Character))) || !OnlyLandVehicles)
  52.             {
  53.                 if ((Game.IsKeyPressed(NitroKey) || (Function.Call<bool>(Hash._GET_LAST_INPUT_METHOD,2) ==false && Game.IsControlPressed(2, PadNitroKey) && Game.IsControlPressed(2, SecondPadNitroKey))) && ((OnlyWhileAccelerating && Game.IsControlPressed(2, GTA.Control.VehicleAccelerate)) || !OnlyWhileAccelerating))
  54.                 {
  55.                     if (NitroSound)
  56.                     {
  57.                         Function.Call(Hash.SET_VEHICLE_BOOST_ACTIVE, GetLastVehicle(Game.Player.Character), true);
  58.                         Function.Call(Hash.SET_VEHICLE_BOOST_ACTIVE, GetLastVehicle(Game.Player.Character), false);
  59.                     }
  60.                     if (NitroScreenEffect)
  61.                     {
  62.                         Function.Call(Hash._START_SCREEN_EFFECT, "RaceTurbo", 0, 0);
  63.                     }
  64.  
  65.                     Function.Call(Hash._SET_VEHICLE_ENGINE_TORQUE_MULTIPLIER, GetLastVehicle(Game.Player.Character), 10f);
  66.  
  67.                     if (Function.Call<bool>(Hash._0x8702416E512EC454, "scr_carsteal4"))
  68.                     {
  69.                         float direction = GetLastVehicle(Game.Player.Character).Heading;
  70.                         float pitch = Function.Call<float>(Hash.GET_ENTITY_PITCH, GetLastVehicle(Game.Player.Character));
  71.  
  72.                         foreach (string exhaust in Exhausts)
  73.                         {
  74.                             Vector3 offset = GetBoneCoords(GetLastVehicle(Game.Player.Character), GetBoneIndex(GetLastVehicle(Game.Player.Character), exhaust));
  75.                             Function.Call(Hash._0x6C38AF3693A69A91, "scr_carsteal4");
  76.                             Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_AT_COORD, "scr_carsteal5_car_muzzle_flash", offset.X, offset.Y, offset.Z, 0f, pitch, direction - 90f, 1.0f, false, false, false);
  77.                         }
  78.                     }
  79.                     else
  80.                     {
  81.                         Function.Call(Hash._0xB80D8756B4668AB6, "scr_carsteal4");
  82.                     }
  83.                 }
  84.             }
  85.         }
  86.     }
  87.  
  88.     bool IsPlane(Vehicle veh)
  89.     {
  90.         return Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_PLANE, veh.Model);
  91.     }
  92.  
  93.     bool IsBoat(Vehicle veh)
  94.     {
  95.         return Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BOAT, veh.Model);
  96.     }
  97.  
  98.  
  99.     bool IsSuperCar(Vehicle veh)
  100.     {
  101.         switch (Function.Call<int>(GTA.Native.Hash.GET_VEHICLE_CLASS, veh))
  102.         {
  103.             case 6:
  104.                 {
  105.                     return true;
  106.                 }
  107.             case 7:
  108.                 {
  109.                     return true;
  110.                 }
  111.  
  112.         }
  113.         return false;
  114.     }
  115.  
  116.     void OnKeyDown(object sender, KeyEventArgs e)
  117.     {
  118.  
  119.     }
  120.     void OnKeyUp(object sender, KeyEventArgs e)
  121.     {
  122.         if (e.KeyCode == Keys.Enter)
  123.         {
  124.             LoadSettings();
  125.         }
  126.     }
  127.  
  128.     int GetBoneIndex(Entity entity, string value)
  129.     {
  130.         return GTA.Native.Function.Call<int>(Hash._0xFB71170B7E76ACBA, entity, value);
  131.     }
  132.  
  133.     Vector3 GetBoneCoords(Entity entity, int boneIndex)
  134.     {
  135.         return GTA.Native.Function.Call<Vector3>(Hash._0x44A8FCB8ED227738, entity, boneIndex);
  136.     }
  137.  
  138.     Vehicle GetLastVehicle(Ped RecieveOrder)
  139.     {
  140.         Vehicle vehicle = null;
  141.         if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true) != null)
  142.         {
  143.             vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true);
  144.             if (vehicle.IsAlive)
  145.             {
  146.                 return vehicle;
  147.             }
  148.         }
  149.         else
  150.         {
  151.             if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false) != null)
  152.             {
  153.                 vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false);
  154.                 if (vehicle.IsAlive)
  155.                 {
  156.                     return vehicle;
  157.                 }
  158.             }
  159.         }
  160.         return vehicle;
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement