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.

LSPDFR crashes when spawned cop added to pursuit with AddCopToPursuit approaches suspect

Featured Replies

I am working on a plugin which adds pursuit units to the game. I spawn the units as follows:

LHandle pursuit;
pursuit = GetPursuit();

Vehicle ResponseVehicle;
Model rVehicleModel;
Ped CopPed;
Model CopModel;
Vector3 SpawnLocation = World.GetNextPositionOnStreet(PlayerPosition.Around(250));

rVehicleModel = new Model("policeold1");
CopModel = new Model("s_m_y_cop_01");

if (!rVehicleModel.IsValid)
{
	Game.DisplayNotification("~R~Unable to create model "   rVehicleModel.Name);
	return;
}
ResponseVehicle = new Vehicle(rVehicleModel, SpawnLocation);
ResponseVehicle.MakePersistent();
ResponseVehicle.IsSirenOn = true;
ResponseVehicle.ShouldVehiclesYieldToThisVehicle = true;

CopPed = new Ped(CopModel, SpawnLocation, 3f);
Functions.AddCopToPursuit(pursuit, CopPed);
CopPed.WarpIntoVehicle(ResponseVehicle, ResponseVehicle.GetFreeSeatIndex().GetValueOrDefault(0));

Now, if I comment out the line with "AddCopToPursuit", the unit still joins the pursuit due to LSPDFR 0.3's auto-pursuit feature. That said, I want to explicitly add the cop to the pursuit so that it won't be affected by plugins like @Albo1125's auto pursuit disabler. When I have Albo's plugin installed, then if I just spawn the cops without adding them to the pursuit, they just sit there (as expected). 

The problem is, if I call AddCopToPursuit, then when the cops I spawned and added myself approach the suspect, LSPDFR crashes with the errors shown below. Note this happens consistently, even when I have no other RPH or LSPDFR plugins enabled other than the one I'm developing. The crash doesn't happen immediately on spawning the units, it only happens when the units get close to the suspects. All of my game fibers are named, so the crash appears to be originating in LSPDFR; additionally the crash refers to specific lines in the LSPDFR code. 

[1/24/2016 10:50:29 PM.069] LSPD First Response: 
[1/24/2016 10:50:29 PM.070] LSPD First Response: ==============================
[1/24/2016 10:50:29 PM.070] LSPD First Response: UNHANDLED EXCEPTION DURING GAME THREAD TICK
[1/24/2016 10:50:29 PM.070] LSPD First Response: ------------------------------
[1/24/2016 10:50:29 PM.070] LSPD First Response: Origin: Game fiber "<UNNAMED THREAD>".
[1/24/2016 10:50:29 PM.070] LSPD First Response: ------------------------------
[1/24/2016 10:50:29 PM.071] LSPD First Response: Exception type: System.NullReferenceException
[1/24/2016 10:50:29 PM.071] LSPD First Response: Exception message: Object reference not set to an instance of an object.
[1/24/2016 10:50:29 PM.071] LSPD First Response: ------------------------------
[1/24/2016 10:50:29 PM.071] LSPD First Response: Inner exceptions:
[1/24/2016 10:50:29 PM.071] LSPD First Response: ------------------------------
[1/24/2016 10:50:29 PM.072] LSPD First Response: Stack trace:
[1/24/2016 10:50:29 PM.072] LSPD First Response: at ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Engine\Scripting\Chase.cs:line 413
[1/24/2016 10:50:29 PM.072] at ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Engine\Main.cs:line 52
[1/24/2016 10:50:29 PM.072] at LSPD_First_Response.Mod.LSPDFR.MainLoop() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\LSPDFR.cs:line 607
[1/24/2016 10:50:29 PM.073] at Rage.GameFiber.Main()
[1/24/2016 10:50:29 PM.073] LSPD First Response: ==============================
[1/24/2016 10:50:29 PM.073] LSPD First Response: 

Am I using AddCopToPursuit wrong, or is there some bug in LSPDFR? 

 

Edited by PNWParksFan

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Author

Update: It appears that calling "Functions.SetPedAsCop(CopPed);" first before adding the cop to the pursuit stops the crash, although I need to do some more testing to be sure. If that's the case, I would suggest that the AddCopToPursuit function either raise an exception if the ped is not a cop, or automatically set the cop as a ped. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

2 hours ago, PNWParksFan said:

Update: It appears that calling "Functions.SetPedAsCop(CopPed);" first before adding the cop to the pursuit stops the crash, although I need to do some more testing to be sure. If that's the case, I would suggest that the AddCopToPursuit function either raise an exception if the ped is not a cop, or automatically set the cop as a ped. 

Yea. Set the ped as a cop first before adding the ped as a cop. 

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.

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.