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.

API Shooting.cs crash

Featured Replies

Good Evening one and all,

Another one for y'all to ponder...

 

 if (this.IsPrankCall)
            {
                DelayedCaller.Call(
                    delegate
                    {
                        // Tell control it was a prank
                        Functions.PlaySound("EMERG_PRANK_CALL", true, false);
                        Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_SHOOTOUT_PRANK_END"), 5000);
                        Functions.AddTextToTextwall(Functions.GetStringFromLanguageFile("CALLOUT_SHOOTOUT_PRANK_END_TW"), Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL"));
                        this.End();
                    },
                    this,
                    10000);
 
                this.State = EShootoutState.Prank;
            }
            else
            {
                Log.Info("WAITING FOR SPOT", this);
                bool playerHasBeenSpotted = false;
                bool randomFight = Common.GetRandomBool(0, 300, 1);
 
                // Check whether player has been spotted
                foreach (LPed criminal in this.criminals)
                {
                    Log.Info("LOOP THROUGH CRIMINALSx", this);
                    if (criminal.Exists())
                    {
                        Log.Info("CRIMINAL EXISTS", this);
                        if (criminal.HasSpottedPed(LPlayer.LocalPlayer.Ped, false))
                        {
                            Log.Info("POLICE SPOTTED", this);
                            playerHasBeenSpotted = true;
                            break;
                        }
                    }
                }
                Log.Info("IF SPOTTED", this);
                // If player has been spotted
                if (playerHasBeenSpotted || randomFight)
                {
                    this.State = EShootoutState.Fighting;
                    this.Engage();
 
                    Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_SHOOTOUT_FIGHT_SUSPECTS"), 5000);
                }
            }
With regards to the above section of code, I've placed a number of Log.Info's to trace the crash, if the call turns out to be a prank, then it works fine and Ends however if not, and it ends up in the latter ELSE statement, the last log I get is "CRIMINAL EXISTS" which would leave me to believe that that the "HasSpottedPed" is causing a crash...any ideas why?!

Mainly aimed at LMS tbh, as you're the most likely to understand the function :)

Thanks!

J

Edited by LMS

  • Management Team

Hello,

 

you had the code tag wrong, I fixed that for better readability. As for your problem, it might be caused by a handle mismatch of the player, that's at least the only thing I can think of, since it passes through all existance checks before. Can you try adding this line before the spotted check?

 

                       

Log.Info("Handle: " + Game.LocalPlayer.Character.pHandle + " -- LCPDFR handle: " + LPlayer.LocalPlayer.Ped.GPed.pHandle, this);

 

You may need to reference the ScriptHookDotNet.asi (rename to dll) shipped with LCPDFR to access the pHandle field.

 

Edit: Also can you try putting the .PDB file where your script is (might have to compile it in debug mode)? That should give you the exact function name and line number of where the crash happened (note that the LCPDFR inner stracktrace will not be available/have scrambled names due to obfuscation).

 

LMS

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author

[iNFO - 7:09:03 PM] [script.Shooting] Handle: 1027 -- LCPDFR handle: 1027
[iNFO - 7:09:03 PM] [script.Shooting] CRIMINAL EXISTS

 

 

:(

 

I'll attempt the other potential solutions :)

 

EDIT: Copied the pdb into the plugins folder alongside my dll but it doesn't produce an output ;/

Edited by jordRiot

  • Author

Sharing is caring and all that jazz... so it appears to work perfectly fine using the GTA Native Function rather than the LCPDFR function. Which for those who are interested is:

if (GTA.Native.Function.Call<bool>("HAS_CHAR_SPOTTED_CHAR",criminal.GPed.Model.Handle,LPlayer.LocalPlayer.Ped.GPed.pHandle))

instead of the current:

if (criminal.HasSpottedPed(LPlayer.LocalPlayer.Ped, false))

To explain the parameters, argument 1 is the HANDLE (int) of the character doing the spotting and argument 2 is the HANDLE (int) of the character to be spotted and it returns true or false. It is however a 360degree detection on it's own!

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.