SHARE
TWEET

Bait Car

Eddlm Mar 31st, 2016 501 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.IO;
  6. using System.Windows.Forms;
  7.  
  8.  
  9.  
  10. public class ScriptTest : Script
  11. {
  12.     string ScriptName = "Bait Car";
  13.     string ScriptVer = "1.0";
  14.  
  15.     Vehicle StolenVeh;
  16.     Vector3 StolenPos;
  17.     public ScriptTest()
  18.     {
  19.         Tick += OnTick;
  20.         Interval = 500;
  21.     }
  22.  
  23.     void OnTick(object sender, EventArgs e)
  24.     {
  25.         Vehicle veh = Game.Player.Character.GetVehicleIsTryingToEnter();
  26.         if (CanWeUse(StolenVeh) && Game.Player.WantedLevel > 0) StolenVeh = null;
  27.         if (IsPlayerInThecity() && !CanWeUse(StolenVeh))
  28.         {
  29.             if (Game.Player.WantedLevel == 0 && CanWeUse(veh)  && veh.NeedsToBeHotwired && !veh.EngineRunning && !CanWeUse(veh.GetPedOnSeat(VehicleSeat.Driver)))
  30.             {
  31.                 Ped propietary = Function.Call<Ped>(GTA.Native.Hash.GET_LAST_PED_IN_VEHICLE_SEAT, veh, -1);
  32.                 if(propietary != Game.Player.Character)
  33.                 {
  34.                     StolenVeh = veh;
  35.                     StolenPos = veh.Position;
  36.                 }
  37.             }
  38.         }
  39.         else if (!Game.Player.Character.IsInRangeOf(StolenPos, 100f))
  40.         {
  41.             if (Game.Player.Character.IsInVehicle(StolenVeh))
  42.             {
  43.                 int baseprob = 10;
  44.  
  45.                 if (IsNightTime()) baseprob += 20;
  46.                 if (StolenVeh.ClassType == VehicleClass.Super) baseprob += 30;
  47.                 if (StolenVeh.ClassType == VehicleClass.SportsClassics) baseprob += 20;
  48.                 if (StolenVeh.ClassType == VehicleClass.Sports) baseprob += 10;
  49.                
  50.                 if (RandomInt(0,100) < baseprob)
  51.                 {
  52.                     Function.Call(Hash.SET_MAX_WANTED_LEVEL, 5);
  53.                     Game.Player.WantedLevel = 1;
  54.                     Vehicle police = World.CreateVehicle("police4", World.GetNextPositionOnStreet(Game.Player.Character.Position + (Game.Player.Character.ForwardVector * -50)));
  55.                     Ped cop = police.CreatePedOnSeat(VehicleSeat.Driver, "s_m_y_cop_01");
  56.                     police.IsPersistent = false;
  57.                     cop.IsPersistent = false;
  58.                     police.Heading = Game.Player.Character.Heading;
  59.  
  60.                     if (RandomInt(0, 100) > 60) Function.Call(Hash.SET_VEHICLE_UNDRIVEABLE, StolenVeh, true);
  61.                 }
  62.             }
  63.             StolenVeh = null;
  64.             StolenPos = Vector3.Zero;
  65.         }
  66.     }
  67.     public static int RandomInt(int min, int max)
  68.     {
  69.         max++;
  70.         return Function.Call<int>(Hash.GET_RANDOM_INT_IN_RANGE, min, max);
  71.     }
  72.     bool CanWeUse(Entity entity)
  73.     {
  74.         return entity != null && entity.Exists();
  75.     }
  76.  
  77.     bool IsPlayerInThecity()
  78.     {
  79.         return Game.Player.Character.IsInRangeOf(new Vector3(-217, -1285, 40), 3000);
  80.     }
  81.     public static bool IsNightTime()
  82.     {
  83.         int hour = Function.Call<int>(Hash.GET_CLOCK_HOURS);
  84.         return (hour > 20 || hour < 7);
  85.     }
  86. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top