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.

MY Callout pack causes my game to crash

Featured Replies

hi everyone 

I am currently developing a callout pack for my mod  Security+ REVAMPED 1.3.2 but I am getting the following after accepting the only callout which is a pursuit in progress 

my game spawns in a lot of backup and then crashes 

i have included RagePluginHook.logmy rage log  and have included the code from my callout 

Spoiler

 public override void Process()
        {
            base.Process();
            {
                //This states that if the player is less than or equal to 100 meters away from SpawnPoint, then it will do whatever is in the brackets.
                if (Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)
                {
                    //Create the pursuit.
                    this.pursuit = Functions.CreatePursuit();

                    //Add mySuspect to the pursuit.
                    Functions.AddPedToPursuit(this.pursuit, mySuspect);

                    //Request Backup for an air unit and one local unit to join into the pursuit.
                    Functions.RequestBackup(Game.LocalPlayer.Character.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit);
                    Functions.RequestBackup(Game.LocalPlayer.Character.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit);
                }
            }
        }

 

O.BUTLER

Hey @Owen.butler17,

Hoping I can lend some experience here!

 

First up, Process() is looping, so unlike OnCalloutAccepted() and End() which are only executed once, Process() keeps iterating over while your callout is running.

 

According to your logic, if the player is within 100f of the spawn point, you are continuously creating a pursuit & requesting backup. And that code keeps looping, and before you know it you've tried to request over a 100 backup units for your 100 pursuits & the game crashes!

 

What you can do here to fix this is add a simple boolean (true or false) to prevent this code from executing more than once.

 

At the top of your class, you can add: private bool IsPursuitRunning = false;

And when you create a pursuit, you can set IsPursuitRunning = true;

 

Then in your if statement, change it to include your boolean check:

if (!IsPursuitRunning && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)

 

I hope this helps you! 😄 Best of luck.

 

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.

 

21 hours ago, Owen.butler17 said:

if (Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)

You say that the pursuit should be created if PLC < 100f form a vector-point
That will be true as long as PLC is that, and that will make your plugin create pursuit over and over.
Make a boolean short-circuit shouldCreatePursuit
 

if (Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f && shouldCreatePursuit) {

shouldCreatePursuit=false //only create pursuit once

:

:
}

See my plugin here:
https://www.youtube.com/watch?v=peqSXuTfIyY

Let me know if you find it interesting.
Best Regards.

2 minutes ago, GTAbear said:
if (Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f && shouldCreatePursuit) {

I'm sidetracking a bit here 😅 but I would - as in my example - do the boolean check first.

 

Your if statement contains important order of operations, and your code will continue to check the distance even if a pursuit should not be created. If you check if a pursuit should be created first, that means you are only performing distance calculations if you actually need them.

 

Maybe that's not something you considered, but I would certainly recommend it nonetheless! 😄 

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
8 hours ago, Charlie686 said:

Hey @Owen.butler17,

Hoping I can lend some experience here!

 

First up, Process() is looping, so unlike OnCalloutAccepted() and End() which are only executed once, Process() keeps iterating over while your callout is running.

 

According to your logic, if the player is within 100f of the spawn point, you are continuously creating a pursuit & requesting backup. And that code keeps looping, and before you know it you've tried to request over a 100 backup units for your 100 pursuits & the game crashes!

 

What you can do here to fix this is add a simple boolean (true or false) to prevent this code from executing more than once.

 

At the top of your class, you can add: private bool IsPursuitRunning = false;

And when you create a pursuit, you can set IsPursuitRunning = true;

 

Then in your if statement, change it to include your boolean check:

if (!IsPursuitRunning && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)

 

I hope this helps you! 😄 Best of luck.

 

@Charlie686I just want to clarify when you say 

At the top of your class, you can add: private bool IsPursuitRunning = false;    where do put this as it caused errors in my code 

And when you create a pursuit, you can set IsPursuitRunning = true;

 

Then in your if statement, change it to include your boolean check:

if (!IsPursuitRunning && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)

O.BUTLER

  • Author
14 minutes ago, Owen.butler17 said:

@Charlie686I just want to clarify when you say 

At the top of your class, you can add: private bool IsPursuitRunning = false;    where do put this as it caused errors in my code 

And when you create a pursuit, you can set IsPursuitRunning = true;

 

Then in your if statement, change it to include your boolean check:

if (!IsPursuitRunning && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)

@Charlie686Never mind I figured it out hopefully it works 

O.BUTLER

8 hours ago, Owen.butler17 said:

@Charlie686Never mind I figured it out hopefully it works 

Let me know! If you need me to clarify / explain anything else, I'd be happy to. 😄

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.

 

22 hours ago, Charlie686 said:

do the boolean check first.

Absolutely!

if (shouldCreatePursuit && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f ) { shouldCreatePursuit=false //only create pursuit once
:
:

}



would be the correct way to do it
I btw did not see your post, i think we almost posted simultaneous though you were a tad faster 😛
 

See my plugin here:
https://www.youtube.com/watch?v=peqSXuTfIyY

Let me know if you find it interesting.
Best Regards.

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.