Advertisement
Guest User

StolenVehicleLCGSD.cs

a guest
Oct 15th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.42 KB | None | 0 0
  1. using Rage;
  2. using System;
  3. using System.Drawing;
  4. using LSPD_First_Response.Mod.API;
  5. using LSPD_First_Response.Mod.Callouts;
  6.  
  7. namespace BlaineCountyCallouts.Callouts
  8. {
  9.     [CalloutInfo("LS Customs - Stolen Vehicle", CalloutProbability.Medium)] // Sets the callout's info.
  10.     class StolenVehicleLCGSD : Callout
  11.     {
  12.         private Ped p_Suspect; // The suspect who stole the vehicle.
  13.         private Vehicle SuspectVehicle; // The stolen vehicle.
  14.         private Vector3 SVLCGSDSpawnPoint; // The spawnpoint of the callout.
  15.         private LHandle Pursuit; // The Pursuit's LHandle.
  16.         private Blip SearchArea; // The area blip for where the player should search to find the suspect.
  17.         private bool PursuitCreated = false; // References if pursuit has been created.
  18.         private readonly Model[] GroundVehiclesToSelectFrom = new Model[] { "bison", "burrito3", "emperor", "emperor2", "fq2", "fugitive",
  19.             "gresley", "habanero", "landstalker", "mesa", "patriot", "picador", "rebel", "rebel2", "regina", "sadler", "sanchez", "sandking",
  20.             "sandking2", "seminole", "surfer", "surfer2", "tornado", "tornado2", "tornado3" }; // A list of all possible vehicles that can be spawned in as a suspect vehicle.
  21.         private readonly string[] ResponseCodes = new string[] { "UNITS_RESPOND_CODE_03_01", "UNITS_RESPOND_CODE_03_02" }; // A list of possible "said" response codes.
  22.         private string ChosenResponseCode; // Assigned later.
  23.         private readonly Random rnd = new Random(); // A new random (used later).
  24.         private readonly static Random rndSpeed = new Random(); // For random car speed.
  25.         private readonly static Random rndEDamage = new Random(); // For random engine damage.
  26.         private readonly float carSpeed = rndSpeed.Next(60, 150); // Sets the car speed.
  27.         private readonly float eDamage = rndEDamage.Next(400, 1000); // Sets the car engine's damage.
  28.  
  29.         public override bool OnBeforeCalloutDisplayed()
  30.         {
  31.             Game.IsFullMapRevealForced = true; // Should enlarge the minimap a bit.
  32.             SVLCGSDSpawnPoint = new Vector3(1163.482f, 2642.028f, 37.63506f); // The Spawn Point Coords.
  33.  
  34.             ShowCalloutAreaBlipBeforeAccepting(SVLCGSDSpawnPoint, 80f); // Displays the blip area before the call is accepted.
  35.             AddMinimumDistanceCheck(20f, SVLCGSDSpawnPoint); // Creates a minimum distance check to see if the player has entered the area.
  36.  
  37.             CalloutMessage = "LS Customs Reports Stolen Vehicle"; // Should be self-explanatory. BCLSC = Blaine County Los Santos Customs.
  38.             CalloutPosition = SVLCGSDSpawnPoint; // This two.
  39.  
  40.             ChosenResponseCode = ResponseCodes[rnd.Next(ResponseCodes.Length)]; // Chooses response code from array.
  41.             Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_GRAND_THEFT_AUTO IN_OR_ON_POSITION" + " " + ChosenResponseCode, SVLCGSDSpawnPoint); // Plays the scanner audio.
  42.             return base.OnBeforeCalloutDisplayed(); // Section completed.
  43.         }
  44.  
  45.         public override bool OnCalloutAccepted()
  46.         {
  47.             // Vehicle Info.
  48.             var modelName = SuspectVehicle.Model.Name;
  49.             var vColor = SuspectVehicle.PrimaryColor.ToKnownColor();
  50.             var licensePlateNum = SuspectVehicle.LicensePlate;
  51.  
  52.             Game.DisplayNotification("Respond Code 3! The vehicle is a " + vColor + " " + modelName + " with license plate number " + licensePlateNum);
  53.  
  54.             SearchArea = new Blip(SVLCGSDSpawnPoint, 500.0f)
  55.             {
  56.                 Alpha = 0.5f,
  57.                 Color = Color.Yellow
  58.             }; // Initialize the Search Area's Blip
  59.  
  60.             SearchArea.EnableRoute(Color.Yellow);
  61.  
  62.             Game.IsFullMapRevealForced = false; // Should minimize the map back to normal.
  63.  
  64.             SuspectVehicle = new Vehicle(GroundVehiclesToSelectFrom[rnd.Next(GroundVehiclesToSelectFrom.Length)], SVLCGSDSpawnPoint) // Sets the vehicle to be a random vehicle from the "GroundVehiclesToSelectFrom" array.
  65.             {
  66.                 IsPersistent = true, // Makes the vehicle Persistent.
  67.                 EngineHealth = eDamage, // Set's the engine health.
  68.                 IsStolen = true, // Marks the vehicle as stolen.
  69.                 Heading = 352.9712f // Sets the vehicles heading.
  70.             };
  71.  
  72.             p_Suspect = SuspectVehicle.CreateRandomDriver(); // Adds a random driver to the Suspect Vehicle.
  73.             p_Suspect.IsPersistent = true; // Makes him/her persistent.
  74.             p_Suspect.BlockPermanentEvents = true; // Prevents them from being distracted by world events.
  75.  
  76.             p_Suspect.Tasks.CruiseWithVehicle(carSpeed, VehicleDrivingFlags.Emergency); // Makes suspect drive eradically.
  77.  
  78.             return base.OnCalloutAccepted(); // Section completed.
  79.         }
  80.  
  81.         public override void Process()
  82.         {
  83.             base.Process(); // Starts this section.
  84.  
  85.             if (Game.LocalPlayer.Character.DistanceTo(SearchArea.Position) < 250f)
  86.             {
  87.                 SearchArea.DisableRoute(); // Disable the route.
  88.             }
  89.  
  90.             if (!PursuitCreated && Game.LocalPlayer.Character.DistanceTo(p_Suspect.Position) < 250f) // If the pursuit is not created, and the players is 100 meters from the suspects position.
  91.             {
  92.                 SearchArea.Delete(); // Delete the search area.
  93.                 Pursuit = Functions.CreatePursuit(); // Create a pursuit.
  94.                 Functions.AddPedToPursuit(Pursuit, p_Suspect); // Adds the suspect to the pursuit.
  95.                 Functions.SetPursuitIsActiveForPlayer(Pursuit, true); // Sets the pursuit active for the player.
  96.                 PursuitCreated = true; // Sets the bool "PursuitCreated" to true.
  97.             }
  98.  
  99.             if (PursuitCreated && !Functions.IsPursuitStillRunning(Pursuit)) // If the pursuit has been created, and the pursuit is not still running, then:
  100.             {
  101.                 End(); // Goto the "End()" method.
  102.             }
  103.         }
  104.         public override void End()
  105.         {
  106.             base.End(); // Start the end base process.
  107.             if (p_Suspect.Exists()) { p_Suspect.Dismiss(); } // If the suspect still exists, then dismiss them.
  108.             if (SuspectVehicle.Exists()) { SuspectVehicle.Dismiss(); } // If the suspect vehicle still exists, then dismiss it.
  109.             if (SearchArea.Exists()) { SearchArea.Delete(); } // If the search area blip still exist, then delete it.
  110.         }
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement