Jump to content

Crashing when trying to end callout


SyeDog

Recommended Posts

Hello, following a suggestion from another member on the forums for my callout i have been trying to add more ways to end my callouts for example, when a ped dies or is cuffed ect.

 

My issue is that when i impliment the code, it keeps crashing my callout or LSPDFR itself. Below i have listed the common errors i get and the code where the error is taking place. Hopefully someone can help or guide me to a solution as looking a few pages back, someone else had a similar issue but is using the same code as me to end the call, just mine isnt working. Thanks in advance.

 

[4/9/2019 3:26:21 PM.450] LSPD First Response: OTB - Police Radio audio should have been played sucessfully
[4/9/2019 3:26:23 PM.630] LSPD First Response: Roll: 1
[4/9/2019 3:26:23 PM.631] LSPD First Response: [TRACE] Cleaning UI
[4/9/2019 3:26:23 PM.633] LSPD First Response: [TRACE] User accepted callout
[4/9/2019 3:26:23 PM.651] LSPD First Response: Error while processing callout: GraffitiCall: Object reference not set to an instance of an object.   at OTBCallouts.Callouts.GraffitiCall.Process() in On The Beat Callouts\Callouts\GraffitiCall.cs:line 466
[4/9/2019 3:26:23 PM.651] at ‪‮‫‌‪‮‎‮‮‮‫‍‪‮‏‌‪‎‪‌‮.‎‭‍‏‍‎‬‮‍‍‍‬‬‍‏‪‏‭‎‎‪‫‎‮() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:line 186
[4/9/2019 3:26:23 PM.652] LSPD First Response: EndCurrentCallout: Finishing...
[4/9/2019 3:26:23 PM.653] LSPD First Response: OTB - Call ending, computerPlus Updated
[4/9/2019 3:26:23 PM.653] LSPD First Response: OTB - Cleanup initiated, removing callout assests
[4/9/2019 3:26:23 PM.654] LSPD First Response: [TRACE] Cleaning UI
[4/9/2019 3:26:23 PM.656] LSPD First Response: [TRACE] Released 0 entities from  #1 Content Manager
[4/9/2019 3:26:23 PM.656] LSPD First Response: [TRACE] Instance cleaned ( #1)
[4/9/2019 3:26:23 PM.661] LSPD First Response: OTB - Search area init complete successfully
        public override void Process()
        {
            GameFiber.StartNew(delegate
            {
                while (hasArrived)
                    GameFiber.Yield();
            if (Suspect.IsCuffed || Suspect.IsDead || !Suspect.Exists())
                {
                    End();
                }

            });
            base.Process();
        }

If people need more information i can provide more logs or information about the callout process if needed. Thanks!

Officer Dog, Sye Dog.

Link to comment
Share on other sites

Use this:

            //If the player presses the end key, the callout will be ended
            if (Game.IsKeyDownRightNow(System.Windows.Forms.Keys.End))
            {
                Logger.DebugLog("User pressed end to end the callout");
                End();
            }

            //If the suspect is dead or is cuffed we call the end method
            if (Suspect.IsDead || Suspect.IsCuffed)
            {
                End();
            }

You also don't need to create a new gamefiber, with this ^ the player also has the ability to end the callout by pressing end.

Link to comment
Share on other sites

Just now, HazyTube said:

Use this:


            //If the player presses the end key, the callout will be ended
            if (Game.IsKeyDownRightNow(System.Windows.Forms.Keys.End))
            {
                Logger.DebugLog("User pressed end to end the callout");
                End();
            }

            //If the suspect is dead or is cuffed we call the end method
            if (Suspect.IsDead || Suspect.IsCuffed)
            {
                End();
            }

You also don't need to create a new gamefiber, with this ^ the player also has the ability to end the callout by pressing end.

Yeah i have a way to end with the end key later on, i added the game fiber to try and fix the issue but it persisted. 

 

The game still gives me the object reference error with just 

if (Suspect.IsDead || Suspect.IsCuffed)
            {
                End();
            }

 

The Suspect is created in a sub method of a callout handler which picks from 4 situations if thats any use to the solution

oncalloutaccepted()
{
callouthandler()
}

callouthandler()
{
	create random int
	if(roll = 1)
{ 
	situation1()
}
}

situation1()
{
	suspect = new Ped()
}

Hopefully use can understand the flow of things without me having to copy all the code, as i am away from my computer now.

Officer Dog, Sye Dog.

Link to comment
Share on other sites

4 hours ago, Syedogg said:

Yeah i have a way to end with the end key later on, i added the game fiber to try and fix the issue but it persisted. 

 

The game still gives me the object reference error with just 


if (Suspect.IsDead || Suspect.IsCuffed)
            {
                End();
            }

 

 

 

object reference error = null pointer exception

 

that means your suspect object is null. make sure to create the suspect instance properly

 

another tips to avoid crash, basically you need to check the entity (ped/vehicles) to make sure it is not null or invalid, like this:

if (Suspect != null && Suspect.IsValid() && (Suspect.IsDead || Suspect.IsCuffed))
{
	End();
}

 

 

 

Link to comment
Share on other sites

1 hour ago, Pazzi said:

 

object reference error = null pointer exception

 

that means your suspect object is null. make sure to create the suspect instance properly

 

another tips to avoid crash, basically you need to check the entity (ped/vehicles) to make sure it is not null or invalid, like this:


if (Suspect != null && Suspect.IsValid() && (Suspect.IsDead || Suspect.IsCuffed))
{
	End();
}

 

 

 

Hey, just wanted to say thank you. Adding the check to see if the Suspect was valid and not set to null has solved the issue, must have been trying to run that check before the Suspect was created which was throwing the error. Not only has it solved my issue but also taught me a lesson on errors and also how LSPDFR runs through a callout. Thanks again.

Officer Dog, Sye Dog.

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