Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Domestic Violence Callout, WarpIntoVehicle not working correctly

Featured Replies

Hi there, I am trying to make a callout for my Pack, but i can't seem to get the ped to drive away. I have used this line before (e.g Suspect.WarpIntoVehicle(SuspectVehicle, -1) and it makes the ped into the drivers seat, which its doing. But this time its not allowing the AI to drive away from the scene. I want it to drive away so I can make the player "Search" for the vehicle.

 

All code is written by me, and may not be optimised yet, but im trying top get it to work first. Any help much appreciated 🙂

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rage;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Engine.Scripting.Entities;

namespace AmazingCallouts.Callouts
{

    [CalloutInfo("[AC] Domestic Violence", CalloutProbability.Medium)]

    class DomesticViolence : Callout
    {
        private Ped Woman;
        private Ped Man;
        private Blip MaleBlip;
        private Blip FemaleBlip;
        private Vector3 Spawnpoint;
        private int counter;
        private LHandle Pursuit;
        private Vehicle SuspectVhicle;
        private Vector3 SuspectSpawnPoint;
        private bool Scene1 = false;
        private bool Scene2 = false;

        public override bool OnBeforeCalloutDisplayed()
        {

            Spawnpoint = new Vector3(2339.33f, 2640.771f, 46.36499f);
            ShowCalloutAreaBlipBeforeAccepting(Spawnpoint, 30f);
            AddMinimumDistanceCheck(30f, Spawnpoint);
            CalloutMessage = "Domestic Violence";
            CalloutPosition = Spawnpoint;
            Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_DISTURBING_THE_PEACE_01 IN_OR_ON_POSITION", Spawnpoint);

            

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            Game.LogTrivial("AmazingCallouts Log: Domestic Violence callout accepted.");

            counter = 0;

            switch (new Random().Next(1, 3))
            {
                case 1:
                    Scene1 = true;
                    break;
                case 2:
                    Scene2 = true;
                    break;
            }

            if (Scene1 == true && Scene2 == false)
            {
                Woman = new Ped("a_f_o_salton_01", Spawnpoint, 0); ///"a_f_o_salton_01"  ///Woman Is Innocent
                Woman.IsPersistent = true;
                Woman.BlockPermanentEvents = true;

                FemaleBlip = Woman.AttachBlip();
                FemaleBlip.Color = System.Drawing.Color.Yellow;
                FemaleBlip.IsRouteEnabled = true;

                
            }

            if (Scene2 == true && Scene1 == false)
            {
                Man = new Ped("a_m_o_acult_02", Spawnpoint, 0); ///"a_m_o_acult_02"  ///Man Is Innocent
                Man.IsPersistent = true;
                Man.BlockPermanentEvents = true;

                MaleBlip = Man.AttachBlip();
                MaleBlip.Color = System.Drawing.Color.Yellow;
                MaleBlip.IsRouteEnabled = true;

                
            }

            return base.OnCalloutAccepted();
        }

        public override void Process()
        {
            base.Process();

            if (Scene1 == true && Scene2 == false && Game.LocalPlayer.Character.DistanceTo(Spawnpoint) <= 10f)  ///Woman Is Innocent
            {
                Game.DisplayHelp("Press '" + Settings.Dialog + "' To Talk to the suspect");

                if (Game.IsKeyDown(Settings.Dialog))
                {
                    counter++;
                    if (counter == 1)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": Hello Ma'am, there has been a report of Domestic Violence. Are you in any trouble?");
                    }
                    if (counter == 2)
                    {
                        Game.DisplaySubtitle("Lady: Hi there officer, yes that is correct. My Husband hit me and then took off.");
                    }
                    if (counter == 3)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": Ok, Do you know what he was wearing? Which way he went? and what make and color the car is?");
                    }
                    if (counter == 4)
                    {
                        Game.DisplaySubtitle("Lady: Im sorry, I can't remember what he was wearing. It was all a bit blurry afterwards. But he went 'That way'.");
                    }
                    if (counter == 5)
                    {
                        Game.DisplaySubtitle("Lady: The car is a 'Sadler' if that is any help");
                    }
                    if (counter == 6)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": Thank you ma'am, that is pleanty of help, Myself and some other officers will be on the lookout him.");
                    }
                    if (counter == 7)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": For the meantime, do you need any Medical Assintance?");
                    }
                    if (counter == 8)
                    {
                        Game.DisplaySubtitle("Lady: Yes please, that would be much appreciated");
                    }
                    if (counter == 9)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": No worries, I will call for EMS to come check you out ma'am");
                    }
                    if (counter == 10)
                    {
                        Game.DisplaySubtitle("NO MORE DIALOUGE. CALL FOR EMS AND PROCED TO LOOK FOR SUSPECT.");
                        SuspectSpawnPoint = new Vector3(2551.485f, 2495.719f, 32.02878f);
                        SuspectVhicle = new Vehicle("SADLER", SuspectSpawnPoint);
                        SuspectVhicle.IsPersistent = true;
                        Man = new Ped("a_m_o_acult_02", SuspectVhicle.GetOffsetPositionFront(5f), 0);
                        Man.IsPersistent = true;
                        Man.BlockPermanentEvents = true;
                        
                        MaleBlip = Man.AttachBlip();
                        MaleBlip.Color = System.Drawing.Color.Red;
                        MaleBlip.IsRouteEnabled = true;
                        FemaleBlip.Delete();
                        Woman.Dismiss();

                        Man.WarpIntoVehicle(SuspectVhicle, -1);

                        if (Game.LocalPlayer.Character.DistanceTo(SuspectVhicle.Position) <= 20f)
                        {
                            Pursuit = Functions.CreatePursuit();
                            Functions.AddPedToPursuit(Pursuit, Man);
                            Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                        }
                        if (Man.IsCuffed || Man.IsDead) End();
                    }

                    

                }
            }

            if (Scene2 == true && Scene1 == false && Game.LocalPlayer.Character.DistanceTo(Spawnpoint) <= 10f)  ///Man Is Innocent
            {
                Game.DisplayHelp("Press '" + Settings.Dialog + "' To Talk to the suspect");
                if (Game.IsKeyDown(Settings.Dialog))
                {
                    counter++;
                    if (counter == 1)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": Hello Sir, there has been a report of Domestic Violence. Are you in any trouble?");
                    }
                    if (counter == 2)
                    {
                        Game.DisplaySubtitle("Man: Hi there officer, yes that is correct. My Wife hit me and then took off.");
                    }
                    if (counter == 3)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": Ok, Do you know what she was wearing? Which way she went? and what make and color the car is?");
                    }
                    if (counter == 4)
                    {
                        Game.DisplaySubtitle("Man: Im sorry, I can't remember what she was wearing. It was all a bit blurry afterwards. But she went 'That way'.");
                    }
                    if (counter == 5)
                    {
                        Game.DisplaySubtitle("Man: The car is a 'Sadler' if that is any help");
                    }
                    if (counter == 6)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": Thank you Sir, that is pleanty of help, Myself and some other officers will be on the lookout her.");
                    }
                    if (counter == 7)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": For the meantime, do you need any Medical Assintance?");
                    }
                    if (counter == 8)
                    {
                        Game.DisplaySubtitle("Man: Yes please, that would be much appreciated");
                    }
                    if (counter == 9)
                    {
                        Game.DisplaySubtitle(Settings.PlayerName + ": No worries, I will call for EMS to come check you out Sir");
                    }
                    if (counter == 10)
                    {
                        Game.DisplaySubtitle("NO MORE DIALOUGE. CALL FOR EMS AND PROCED TO LOOK FOR SUSPECT.");
                        SuspectSpawnPoint = new Vector3(2551.485f, 2495.719f, 32.02878f);
                        SuspectVhicle = new Vehicle("SADLER", SuspectSpawnPoint);
                        SuspectVhicle.IsPersistent = true;

                        Woman = new Ped("a_f_o_salton_01", SuspectVhicle.GetOffsetPositionFront(5f), 0);
                        Woman.IsPersistent = true;
                        Woman.BlockPermanentEvents = true;
                        
                        FemaleBlip = Woman.AttachBlip();
                        FemaleBlip.Color = System.Drawing.Color.Red;
                        FemaleBlip.IsRouteEnabled = true;
                        MaleBlip.Delete();
                        Man.Dismiss();

                        Woman.WarpIntoVehicle(SuspectVhicle, -1);

                        if (Game.LocalPlayer.Character.DistanceTo(SuspectVhicle.Position) <= 20f)
                        {
                            Pursuit = Functions.CreatePursuit();
                            Functions.AddPedToPursuit(Pursuit, Woman);
                            Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                        }
                        if (Woman.IsCuffed || Woman.IsDead) End();
                    } 
                }
            }

            if (Game.LocalPlayer.Character.IsDead) End();
            if (Game.IsKeyDown(Settings.EndCall)) End();

        }


        public override void End()
        {

            if (Man.Exists()) Man.Dismiss();
            if (Woman.Exists()) Woman.Dismiss();
            if (FemaleBlip.Exists()) FemaleBlip.Delete();
            if (MaleBlip.Exists()) MaleBlip.Delete();
            if (SuspectVhicle.Exists()) SuspectVhicle.Dismiss();
            Game.LogTrivial("Amazing Callouts - Domestic Violence has been cleaned up");
            base.End();
        }

    }
}

Heya,

If I'm understanding correctly, WarpIntoVehicle is functioning as intended. But you then need to instruct the ped to do something once you've warped them.

The task CruiseWithVehicle might be of interest. 🙂

Prefer support on Discord? Want your log automatically read? Join my server to receive live support!

https://discord.gg/SJfxcAhjCF

 

Developer of Callout Pack 686 Callouts & Discord Bot 686 Utilities.

 

  • Author

Oh yeah I tried doing that, but it still won't register when I'm close to the vehicle and create a pursuit... I tried using Suspect.Tasks.CruiseWithVehicle(20f, VehicleFlags.Emergency) but the stage 3 ligting didn't affect him and would initiate a pursuit based on the distance I am to thr suspect ... if you understand sorry

I'm a little confused. 😄 

At first, I thought our problem was that the ped didn't drive away.

But now you are saying the problem is that it won't register when you are close to the vehicle & create a pursuit?

Could you please clarify?

Prefer support on Discord? Want your log automatically read? Join my server to receive live support!

https://discord.gg/SJfxcAhjCF

 

Developer of Callout Pack 686 Callouts & Discord Bot 686 Utilities.

 

  • Author

Sorry I know it is confusing haha, but yes both are the issue, I had already tried that "Fix" to get the peds to drive away. But if i do it that way. For some reason it won't register that I am close to the vehicle.. I'm sorry if i have confused you. But I do really appreciate your help.. 

 

Let me try another way. 

 

After I spawn the "Ped" in and I warp it into the "SusVehicle".. I want them to drive away. You then "Follow" the car to find where they are and upon reaching "15f" Away from the "SusVehicle" i want it to initiate a pursuit. if that is possible.

First, you will need to add that task to get the peds to drive away. The problem really lies with why a pursuit isn't being initiated.

 

I suspect that the code is not being repeatedly checked / something is preventing Process() from looping.

I would add some logging to:

A) Check Process() is looping - where you are checking whether a pursuit should occur.

B) Add some logging to check the status of your parameters put forth in your if statement - and ensure they are being met. This could explain why a pursuit isn't being created.

 

This should help troubleshoot your problem. 😄 

 

EDIT: After a more thorough review of your code, I've found a problem.

You are checking if (Game.LocalPlayer.Character.DistanceTo(SuspectVhicle.Position) <= 20f) but you are only checking this if the player is within 10f of the SpawnPoint.

 

That means - it will stop looping. Because as soon as the player leaves the original spawnpoint to find the vehicle, your code for checking a pursuit stops! And therefore, no pursuit will be created because your code stops checking for it!

Edited by Charlie686

Prefer support on Discord? Want your log automatically read? Join my server to receive live support!

https://discord.gg/SJfxcAhjCF

 

Developer of Callout Pack 686 Callouts & Discord Bot 686 Utilities.

 

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...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.