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.

[Solved] Air Units Endlessly Spawning?

Featured Replies

Hello folks, I almost finished my first callout plugin when all of a sudden, while testing it. I show up on scene and the largest frame drop ever in my entire history of playing the game happens. The game won't stop spawning backup units. I only told it to spawn two. Here is my code:

 

        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 one air unit and one local patrol unit to join 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);
                }
            }
        }

 

 

Edited by OfficerJohnnyShumway
Question has been solved

You keep creating a new pursuit instance and requesting backup on every tick/frame while your on scene. Easiest solution is to use a boolean variable.

bool bSomeGenericBool = false;

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 (!bSomeGenericBool && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)
	{
		bSomeGenericBool = true;
		
		//Create the pursuit.
		this.pursuit = Functions.CreatePursuit();

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

		//Request backup for one air unit and one local patrol unit to join 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);
	}
}

 

  • Author
1 hour ago, OJdoesIt said:

You keep creating a new pursuit instance and requesting backup on every tick/frame while your on scene. Easiest solution is to use a boolean variable.


bool bSomeGenericBool = false;

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 (!bSomeGenericBool && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)
	{
		bSomeGenericBool = true;
		
		//Create the pursuit.
		this.pursuit = Functions.CreatePursuit();

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

		//Request backup for one air unit and one local patrol unit to join 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);
	}
}

 

Thanks m8, I will try it in a little bit.

  • Author
2 hours ago, OJdoesIt said:

You keep creating a new pursuit instance and requesting backup on every tick/frame while your on scene. Easiest solution is to use a boolean variable.


bool bSomeGenericBool = false;

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 (!bSomeGenericBool && Game.LocalPlayer.Character.Position.DistanceTo(SpawnPoint) <= 100f)
	{
		bSomeGenericBool = true;
		
		//Create the pursuit.
		this.pursuit = Functions.CreatePursuit();

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

		//Request backup for one air unit and one local patrol unit to join 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);
	}
}

 

It worked m8, thank you so much! 

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.