Advertisement
Guest User

MinipunchCallOut1

a guest
Apr 5th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.58 KB | None | 0 0
  1. using LSPD_First_Response.Engine.Scripting.Entities;
  2. using LSPD_First_Response.Mod.API;
  3. using LSPD_First_Response.Mod.Callouts;
  4. using Rage;
  5.  
  6. //Our namespace (aka folder) where we keep our callout classes.
  7. namespace DemoProject.Callouts
  8. {
  9.     //Give your callout a string name and a probability of spawning. We also inherit from the Callout class, as this is a callout
  10.     [CalloutInfo("ExampleCallout69", CalloutProbability.VeryHigh)]
  11.     public class ChaseCallout : Callout
  12.     {
  13.         //Here we declare our variables, things we need or our callout
  14.         private Vehicle myVehicle; // a rage vehicle
  15.         private Ped myPed; // a rage ped
  16.         private Vector3 SpawnPoint; // a Vector3
  17.         private Blip myBlip; // a rage blip
  18.         private LHandle pursuit; // an API pursuit handle
  19.  
  20.         /// <summary>
  21.         /// OnBeforeCalloutDisplayed is where we create a blip for the user to see where the pursuit is happening, we initiliaize any variables above and set
  22.         /// the callout message and position for the API to display
  23.         /// </summary>
  24.         /// <returns></returns>
  25.         public override bool OnBeforeCalloutDisplayed()
  26.         {
  27.             //Set our spawn point to be on a street around 300f (distance) away from the player.
  28.             SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));
  29.  
  30.             //Create our ped in the world
  31.             myPed = new Ped("a_m_y_mexthug_01", SpawnPoint, 0f);
  32.  
  33.             //Create the vehicle for our ped
  34.             myVehicle = new Vehicle("DUKES2", SpawnPoint);
  35.  
  36.             //Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it)
  37.             if (!myPed.Exists()) return false;
  38.             if (!myVehicle.Exists()) return false;
  39.  
  40.             //If we made it this far both exist so let's warp the ped into the driver seat
  41.             myPed.WarpIntoVehicle(myVehicle, -1);
  42.  
  43.             // Show the user where the pursuit is about to happen and block very close peds.
  44.             this.ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 15f);
  45.             this.AddMinimumDistanceCheck(5f, myPed.Position);
  46.  
  47.             // Set up our callout message and location
  48.             this.CalloutMessage = "MINIPUNCH'S CALLOUT IS WORKING BORO";
  49.             this.CalloutPosition = SpawnPoint;
  50.  
  51.             //Play the police scanner audio for this callout (available as of the 0.2a API)
  52.             Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_RESIST_ARREST IN_OR_ON_POSITION", SpawnPoint);
  53.  
  54.             return base.OnBeforeCalloutDisplayed();
  55.         }
  56.  
  57.  
  58.         /// <summary>
  59.         /// OnCalloutAccepted is where we begin our callout's logic. In this instance we create our pursuit and add our ped from eariler to the pursuit as well
  60.         /// </summary>
  61.         /// <returns></returns>
  62.         public override bool OnCalloutAccepted()
  63.         {
  64.             //We accepted the callout, so lets initilize our blip from before and attach it to our ped so we know where he is.
  65.             myBlip = myPed.AttachBlip();
  66.             this.pursuit = Functions.CreatePursuit();
  67.             Functions.AddPedToPursuit(this.pursuit, this.myPed);
  68.  
  69.             return base.OnCalloutAccepted();
  70.         }
  71.  
  72.         /// <summary>
  73.         /// If you don't accept the callout this will be called, we clear anything we spawned here to prevent it staying in the game
  74.         /// </summary>
  75.         public override void OnCalloutNotAccepted()
  76.         {
  77.             base.OnCalloutNotAccepted();
  78.             if (myPed.Exists()) myPed.Delete();
  79.             if (myVehicle.Exists()) myVehicle.Delete();
  80.             if (myBlip.Exists()) myBlip.Delete();
  81.         }
  82.  
  83.         //This is where it all happens, run all of your callouts logic here
  84.         public override void Process()
  85.         {
  86.             base.Process();
  87.  
  88.             //A simple check, if our pursuit has ended we end the callout
  89.             if (!Functions.IsPursuitStillRunning(pursuit))
  90.             {
  91.                 this.End();
  92.             }
  93.         }
  94.  
  95.         /// <summary>
  96.         /// More cleanup, when we call end you clean away anything left over
  97.         /// This is also important as this will be called if a callout gets aborted (for example if you force a new callout)
  98.         /// </summary>
  99.         public override void End()
  100.         {
  101.             base.End();
  102.             if (myBlip.Exists()) myBlip.Delete();
  103.             if (myPed.Exists()) myPed.Delete();
  104.             if (myVehicle.Exists()) myVehicle.Delete();
  105.  
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement