Jump to content

Whenever I make a callout in Visual Studio, it passes intellisense but for some reason the callout never comes up in game


download500

Recommended Posts

I have noticed if I experiment with new options, sometimes it will cause the callout to NEVER load, despite setting it's frequency to "very high".

Does the game refuse to load the callout if it will crash or something? I wish it would tell me if/why it wasn't loading so I could fix it. 

I know I have it installed right (in the plugins/LSPDFR folder) because it works if I leave it as the example callout, but the moment I start spawing more vehicles, etc it stops being triggered in game.

Also, what script would I use to bind my callout to trigger on a hotkey, so I can test it?

Edited by download500
Link to comment
Share on other sites

Check the RPH log file for a line line this:

[10/10/2015 12:51:00.201] LSPD First Response: Registering callout CalloutsV.Callouts.StreetRace

But obviously it will have your mod name, namespace and callout file name.

If that never appears the callout is never registered. If it does appear it is registered and will be randomly selected.

You also can't force your own callout, just set the probability to "Always" and keep hitting X until it shows up.
If you've done this, and the line in the log file above shows but the callout still never appears, you've used or done something else which is blocking it, for example created an infinite loop in the wrong place. Double check your code.

Also as a best practice, comment and log a callout. So you can go through the log file to see if your code actually executes or if it gets cut off for whatever reason.

Live Streaming daily from 8pm GMT (UK) at https://twitch.tv/OfficialLukeD - I play a variety of things 😄

Join my official discord server for support, general chat and my stream schedule! https://discord.gg/Mddj7PQ

Link to comment
Share on other sites

9 hours ago, LukeD said:

Check the RPH log file for a line line this:


[10/10/2015 12:51:00.201] LSPD First Response: Registering callout CalloutsV.Callouts.StreetRace

But obviously it will have your mod name, namespace and callout file name.

If that never appears the callout is never registered. If it does appear it is registered and will be randomly selected.

You also can't force your own callout, just set the probability to "Always" and keep hitting X until it shows up.
If you've done this, and the line in the log file above shows but the callout still never appears, you've used or done something else which is blocking it, for example created an infinite loop in the wrong place. Double check your code.

Also as a best practice, comment and log a callout. So you can go through the log file to see if your code actually executes or if it gets cut off for whatever reason.

[11/23/2015 11:37:12 PM.676] LSPD First Response: Registering callout CalloutsV.Callouts.TrafficCollision

 

My callout is called MVA, I have these littered throughout the log:

 

[11/21/2015 11:05:26 PM.753] LSPD First Response: GetAudioFileForAction: No file found for: MVA
[11/21/2015 11:05:26 PM.761] LSPD First Response: GetAudioFileForAction: No file found for: MVA
[11/21/2015 11:05:26 PM.762] LSPD First Response: PlayAction: Failed to find MVA

 

 

This is my code, what did I do wrong?

using LSPD_First_Response.Engine.Scripting.Entities;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using Rage;

//Our namespace (aka folder) where we keep our callout classes.
namespace APIExample.Callouts
{
    //Give your callout a string name and a probability of spawning. We also inherit from the Callout class, as this is a callout
    [CalloutInfo("ExampleCallout", CalloutProbability.VeryHigh)]
    public class ExampleCallout : Callout
    {
        //Here we declare our variables, things we need or our callout
        private Vehicle myVehicle; // a rage vehicle
        private Ped myPed; // a rage ped
        private Vector3 SpawnPoint; // a Vector3
        private Blip myBlip; // a rage blip
        private LHandle pursuit; // an API pursuit handle
        private Ped ped2;
        private Vehicle veh2;
        private Vehicle ems;
        private Ped ambdriver1;
        private Ped ambdriver2;
        private object get;
        private object set;

        /// <summary>
        /// OnBeforeCalloutDisplayed is where we create a blip for the user to see where the pursuit is happening, we initiliaize any variables above and set
        /// the callout message and position for the API to display
        /// </summary>
        /// <returns></returns>
        public override bool OnBeforeCalloutDisplayed()
        {
            //Set our spawn point to be on a street around 300f (distance) away from the player.
            SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));

            //Create our ped in the world
            myPed = new Ped("a_m_y_mexthug_01", SpawnPoint, 0f);
            ped2 = new Ped("A_F_M_BodyBuild_01", SpawnPoint, 0f);
            ambdriver1 = new Ped("S_M_M_Paramedic_01", SpawnPoint, 5f);
            ambdriver2 = new Ped("S_M_M_Paramedic_01", SpawnPoint, 6f);
            ambdriver1.Tasks.StandStill(-1);
            ambdriver2.Tasks.StandStill(-1);

         


            //Create the vehicle for our ped
            myVehicle = new Vehicle("INTRUDER", SpawnPoint);
            veh2 = new Vehicle("GRANGER", SpawnPoint);
            ems = new Vehicle("AMBULANCE", SpawnPoint, 10f);

            ems.IsSirenOn = true;
           ems.IsSirenSilent = true;
            veh2.EngineHealth = 0.0f;
            myVehicle.EngineHealth = 0.0f;

           





      


            //If we made it this far both exist so let's warp the ped into the driver seat
            myPed.WarpIntoVehicle(myVehicle, -1);
            ped2.WarpIntoVehicle(veh2, -1);


            // Show the user where the pursuit is about to happen and block very close peds.
            this.ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 15f);
            this.AddMinimumDistanceCheck(5f, myPed.Position);

            // Set up our callout message and location
            this.CalloutMessage = "Motor Vehicle Accident";
            this.CalloutPosition = SpawnPoint;

            //Play the police scanner audio for this callout (available as of the 0.2a API)
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_RESIST_ARREST IN_OR_ON_POSITION", SpawnPoint);

            return base.OnBeforeCalloutDisplayed();
        }


        /// <summary>
        /// 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
        /// </summary>
        /// <returns></returns>
        public override bool OnCalloutAccepted()
        {
            //We accepted the callout, so lets initilize our blip from before and attach it to our ped so we know where he is.
            myBlip = myPed.AttachBlip();
            this.pursuit = Functions.CreatePursuit();
            Functions.AddPedToPursuit(this.pursuit, this.myPed);

            return base.OnCalloutAccepted();
        }

        /// <summary>
        /// If you don't accept the callout this will be called, we clear anything we spawned here to prevent it staying in the game
        /// </summary>
        public override void OnCalloutNotAccepted()
        {
            base.OnCalloutNotAccepted();
            if (myPed.Exists()) myPed.Delete();
            if (myVehicle.Exists()) myVehicle.Delete();
            if (myBlip.Exists()) myBlip.Delete();
        }

        //This is where it all happens, run all of your callouts logic here
        public override void Process()
        {
            base.Process();

            //A simple check, if our pursuit has ended we end the callout
            if (!Functions.IsPursuitStillRunning(pursuit))
            {
                this.End();
            }
        }

        /// <summary>
        /// More cleanup, when we call end you clean away anything left over
        /// This is also important as this will be called if a callout gets aborted (for example if you force a new callout)
        /// </summary>
        public override void End()
        {
            base.End();
            if (myBlip.Exists()) myBlip.Delete();
            if (myPed.Exists()) myPed.Delete();
            if (myVehicle.Exists()) myVehicle.Delete();

        }
    }
}

 

Edited by download500
Link to comment
Share on other sites

Have you registered the callout with LSPDFR?

Functions.RegisterCallout(typeof(Callouts.ExampleCallout));

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...