SHARE
TWEET

(Initial D intensifies) v1.1

Eddlm Dec 29th, 2015 (edited) 1,013 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using System;
  5. using System.Windows.Forms;
  6.  
  7.  
  8.  
  9. public class InitialDIntensifies : Script
  10. {
  11.     int ExtraNoGripInterval = 10;
  12.     int interval = 10;
  13.     int intervalmilisec;
  14.     bool Tractionhack = false;
  15.     bool hackstatus = false;
  16.     bool CanIntensify=true;
  17.     Keys Key1 =Keys.A;
  18.     Keys Key2 =Keys.D;
  19.     public InitialDIntensifies()
  20.     {
  21.         ScriptSettings config = ScriptSettings.Load(@"scripts\DriftOnDemand.ini");
  22.         if (config != null)
  23.         {
  24.             CanIntensify = config.GetValue<bool>("SETTINGS", "SubtitleWhileDrifting", true);
  25.             Key1 = config.GetValue<Keys>("SETTINGS", "Key1", Keys.A);
  26.             Key2 = config.GetValue<Keys>("SETTINGS", "Key2", Keys.D);
  27.  
  28.         }
  29.  
  30.         Tick += OnTick;
  31.         KeyDown += OnKeyDown;
  32.         KeyUp += OnKeyUp;
  33.     }
  34.  
  35.     void OnKeyUp(object sender, KeyEventArgs e)
  36.     {
  37.  
  38.     }
  39.     void OnKeyDown(object sender, KeyEventArgs e)
  40.     {
  41.         if((e.KeyCode==Key1 && Game.IsKeyPressed(Key2)) || (e.KeyCode == Key2 && Game.IsKeyPressed(Key1)))
  42.         {
  43.             if (CanWeUse(GetLastVehicle(Game.Player.Character)) && CanWeUse((Game.Player.Character.CurrentVehicle)))
  44.             {
  45.                 Tractionhack = !Tractionhack;
  46.                 Function.Call(Hash.SET_VEHICLE_REDUCE_GRIP, GetLastVehicle(Game.Player.Character), false);
  47.             }
  48.         }
  49.     }
  50.  
  51.     void OnTick(object sender, EventArgs e)
  52.     {
  53.         if (Tractionhack && CanWeUse(GetLastVehicle(Game.Player.Character)) && CanWeUse((Game.Player.Character.CurrentVehicle)) && !GetLastVehicle(Game.Player.Character).IsInAir)
  54.         {
  55.             if (Game.IsControlPressed(2, GTA.Control.VehicleAccelerate) && (GetLastVehicle(Game.Player.Character).Speed < 10f || Math.Abs(Function.Call<Vector3>(Hash.GET_ENTITY_SPEED_VECTOR, GetLastVehicle(Game.Player.Character), true).X) > 2f))
  56.             {
  57.                 Function.Call(Hash.APPLY_FORCE_TO_ENTITY, GetLastVehicle(Game.Player.Character), 3, 0f, 0.2f, 0f, 0f, 0f, 0f, 0, true, true, true, true, true);
  58.             }
  59.             if (Game.IsControlPressed(2, GTA.Control.VehicleBrake) && (GetLastVehicle(Game.Player.Character).Speed > 2f))
  60.             {
  61.                 Function.Call(Hash.APPLY_FORCE_TO_ENTITY, GetLastVehicle(Game.Player.Character), 3, 0f, -0.2f, 0f, 0f, 0f, 0f, 0, true, true, true, true, true);
  62.             }
  63.             if (Game.IsControlPressed(2, GTA.Control.VehicleHandbrake) && !Game.IsControlPressed(2, GTA.Control.VehicleAccelerate))
  64.             {
  65.                 Vector3 veh = Function.Call<Vector3>(Hash.GET_ENTITY_SPEED_VECTOR, GetLastVehicle(Game.Player.Character), true) * -0.05f;
  66.                 Function.Call(Hash.APPLY_FORCE_TO_ENTITY, GetLastVehicle(Game.Player.Character), 3, veh.X, veh.Y / 4, 0f, 0f, 0f, 0f, 0, true, true, true, true, true);
  67.             }
  68.             if (GetLastVehicle(Game.Player.Character).Speed > 5f && Function.Call<Vector3>(Hash.GET_ENTITY_SPEED_VECTOR, GetLastVehicle(Game.Player.Character), true).Y > 0f)
  69.             {
  70.                 if (Game.IsControlPressed(2, GTA.Control.VehicleMoveLeftOnly) && Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, GetLastVehicle(Game.Player.Character)).Z < 0.8f)
  71.                 {
  72.                     Function.Call(Hash.APPLY_FORCE_TO_ENTITY, GetLastVehicle(Game.Player.Character), 3, -0.2f, 0f, 0f, 0f, 2f, -0.2f, 0, true, true, true, true, true);
  73.                 }
  74.                 if (Game.IsControlPressed(2, GTA.Control.VehicleMoveRightOnly) && Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, GetLastVehicle(Game.Player.Character)).Z > -0.8f)
  75.                 {
  76.                     Function.Call(Hash.APPLY_FORCE_TO_ENTITY, GetLastVehicle(Game.Player.Character), 3, 0.2f, 0f, 0f, 0f, 2f, -0.2f, 0, true, true, true, true, true);
  77.                 }
  78.             }
  79.             if (Game.IsKeyPressed(Keys.ShiftKey))
  80.             {
  81.                 ExtraNoGripInterval = ExtraNoGripInterval + 10;
  82.                 DisplayHelpTextThisFrame("NoGrip interval set to "+ExtraNoGripInterval);
  83.             }
  84.             if (Game.IsKeyPressed(Keys.ControlKey) && ExtraNoGripInterval>0)
  85.             {
  86.                 ExtraNoGripInterval = ExtraNoGripInterval - 10;
  87.                 DisplayHelpTextThisFrame("NoGrip interval set to " + ExtraNoGripInterval);
  88.             }
  89.         }
  90.  
  91.  
  92.  
  93.         if (Game.GameTime > intervalmilisec + interval)
  94.         {
  95.  
  96.             intervalmilisec = Game.GameTime;
  97.             if (Tractionhack && (CanWeUse(GetLastVehicle(Game.Player.Character)) && (Function.Call<bool>(Hash.IS_THIS_MODEL_A_CAR, GetLastVehicle(Game.Player.Character).Model)) || Function.Call<bool>(Hash.IS_THIS_MODEL_A_QUADBIKE, GetLastVehicle(Game.Player.Character).Model)))
  98.             {
  99.                 if (CanIntensify)
  100.                 {
  101.                     UI.ShowSubtitle("~g~(Initial D intensifies)", 100+ ExtraNoGripInterval);
  102.                 }
  103.  
  104.                 if (hackstatus)
  105.                 {
  106.                     Function.Call(Hash.SET_VEHICLE_REDUCE_GRIP, GetLastVehicle(Game.Player.Character), false);
  107.                 }
  108.                 else
  109.                 {
  110.                     intervalmilisec = intervalmilisec + ExtraNoGripInterval;
  111.                     Function.Call(Hash.SET_VEHICLE_REDUCE_GRIP, GetLastVehicle(Game.Player.Character), true);
  112.                 }
  113.                 hackstatus = !hackstatus;
  114.             }
  115.  
  116.         }
  117.     }
  118.  
  119.     bool CanWeUse(Entity entity)
  120.     {
  121.         return entity != null && entity.Exists();
  122.     }
  123.  
  124.     int RandomInt(int min, int max)
  125.     {
  126.         max++;
  127.         return Function.Call<int>(GTA.Native.Hash.GET_RANDOM_INT_IN_RANGE, min, max);
  128.     }
  129.  
  130.     void DisplayHelpTextThisFrame(string text)
  131.     {
  132.         Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
  133.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
  134.         Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);
  135.     }
  136.  
  137.     Vehicle GetLastVehicle(Ped RecieveOrder)
  138.     {
  139.         Vehicle vehicle = null;
  140.         if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true) != null)
  141.         {
  142.             vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true);
  143.             if (vehicle.IsAlive)
  144.             {
  145.                 return vehicle;
  146.             }
  147.         }
  148.         else
  149.         {
  150.             if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false) != null)
  151.             {
  152.                 vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false);
  153.                 if (vehicle.IsAlive)
  154.                 {
  155.                     return vehicle;
  156.                 }
  157.             }
  158.         }
  159.         return vehicle;
  160.     }
  161.  
  162. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top