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.

Ped not moving during callout

Featured Replies

Working on my first plugin, and having a lot of trouble getting a callout to work. I have a couple of callouts based on the API examples on github that are working fine, but no matter what I try, when I accept the third callout the suspect spawns but never ever moves or does anything. My aim was to make the ped find a nearby vehicle and steal it triggering a pursuit (and wandering the streets looking for one if it cant find a vehicle). Can anyone offer any pointers on where I'm going wrong? (This is my first dabbling with C#, so well aware I'm probably making some really stupid error)

Spoiler

            Suspect suspect = (Suspect)GetPed("Suspect1");
            if (suspect.Exists()) { suspect.Tasks.Wander(); }

            if (pursuitInitiated && !Functions.IsPursuitStillRunning(pursuit))
            {
                End();
            }
            else if (!pursuitInitiated)
            {
                if (suspect == null || !suspect.Exists() || suspect.IsDead)
                {
                    Game.DisplaySubtitle("Suspect has fled the scene.", 5000);
                    End();
                }
                else if (car == null)
                {
                    suspect.Tasks.Wander();
                    Game.DisplayNotification("Checking for cars...");
                    Vehicle[] stolen = suspect.GetNearbyVehicles(16);
                    if (stolen != null && stolen.GetLength(0) > 0)
                    {
                        car = stolen[0];
                        Game.DisplayNotification(car.Model.Name);
                    } else
                    {
                        Game.DisplayNotification("No cars!");
                    }
                } else if (suspect.IsInAnyVehicle(false))
                {
                    Game.DisplayNotification("Entered vehicle");
                    base.DeleteBlip();
                    pursuit = Functions.CreatePursuit();
                    Functions.AddPedToPursuit(this.pursuit, suspect);
                 } else
                {
                    Game.DisplayNotification("Move to entity");
                    Game.DisplayNotification(car.Model.Name);
                    NativeFunction.CallByName<uint>("TASK_GO_TO_ENTITY", suspect, car, 10, 5, 150, 1073741824, 0);
                    if (car.Exists())
                    {
                        Game.DisplayNotification("Attempt to enter");
                        suspect.Tasks.EnterVehicle(car, -1);
                    }
                }
            }

 

 

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

  • Author

Hmm, this is pretty much the entirety of my Process() function, I'm not really sure what else would be relevant? (The only thing I havent included is the call to base.Process(); as I used the Inheritance api example as a starting point). I read in a couple of other topics the point about EnterVehicle(), and so had tried adding the call to TASK_GO_TO_ENTITY... but even the earlier call to suspect.Tasks.Wander() isn't doing anything, the suspect ped just stands there like a statue for the whole callout. I tried wrapping it all in a GameFiber and sleeping for 5-10 seconds after each task which didnt achieve anything. All the sections of the code are triggering correctly, as I'm seeing the notifications pop up for each step as expected, the tasks just aren't being triggered. Which leads me to believe either I've messed something up and am somehow accessing a different / invalid ped (I'd think that'd trigger some kind of fatal error though?), or I've totally misunderstood something basic about how the whole ped tasks work. Do I need to add something to make the ped execute the tasks once assigned? Should I be calling Tasks.Clear() before setting a new task?

I've even tried adding a call to Tasks.Wander when I first spawn the ped which also has him stand around doing nothing:

Spoiler

        public override bool OnBeforeCalloutDisplayed()
        {
            // first we check for agency
            if (Common.myAgency != "LSPD" && Common.myAgency != "County Sheriff" && Common.myAgency != "Highway Patrol") return false;
            base.OnBeforeCalloutDisplayed();

            //Create our ped in the world
            Suspect myPed = new Suspect("Suspect1", "a_m_y_mexthug_01", SpawnPoint, 0, true);

            //Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it)
            if (!myPed.Exists()) return false;

            Peds.Add(myPed);

            //If we made it this far both exist so let's warp the ped into the driver seat
            myPed.GiveNewWeapon("WEAPON_PISTOL", 500, true);
            myPed.Tasks.Wander();

            // Show the user where the pursuit is about to happen and block very close peds.
            this.ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 50f);
            this.AddMinimumDistanceCheck(5f, myPed.Position);

            // Set up our callout message and location
            this.CalloutMessage = "GTA In Progress";
            this.CalloutPosition = SpawnPoint;

            //Play the police scanner audio for this callout (available as of the 0.2a API)
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_GRAND_THEFT_AUTO_03 IN_OR_ON_POSITION", SpawnPoint);
            return true;

        }

 

 

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

  • Author

Hmm, I'm definitely doing something wrong with the tasks. I tried tweaking it so none of the moving to entity / entering vehicle code triggers unless the player is on the scene, and set it to spawn a sentinel 10f away from the ped at the start. Now when I get to the scene, the ped starts moving over and reaches for the car, /then/ becomes immobile.

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

On 11/28/2015, 8:08:52, Darkmyre said:

Hmm, I'm definitely doing something wrong with the tasks. I tried tweaking it so none of the moving to entity / entering vehicle code triggers unless the player is on the scene, and set it to spawn a sentinel 10f away from the ped at the start. Now when I get to the scene, the ped starts moving over and reaches for the car, /then/ becomes immobile.

Try this:

suspect.Tasks.EnterVehicle(car, 10000, -1).WaitForCompletion();

This will ensure no other code executes in that Game Fiber before the suspect is in the car. I think you may be overriding tasks, but I can't be sure because I only have a snippet of your code.

Other relevant code would be your (inherited?) Suspect class, as you may be overriding basic Ped behaviour.

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.

  • Author

Hmm, that didn't seem to help either. I've even tried changing it to use the default Ped class which didnt change anything. Debating between starting over and just plain giving up at this point as I've clearly screwed something up at a pretty fundamental level lol.... thanks heaps for trying to help out

Edited by Darkmyre

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

public override bool OnBeforeCalloutDisplayed()
        {
            // first we check for agency
            if (Common.myAgency != "LSPD" && Common.myAgency != "County Sheriff" && Common.myAgency != "Highway Patrol") return false;
            

            //Create our ped in the world
            Suspect myPed = new Suspect("Suspect1", "a_m_y_mexthug_01", SpawnPoint, 0, true);

            //Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it)
            if (!myPed.Exists()) return false;

            Peds.Add(myPed);

            //If we made it this far both exist so let's warp the ped into the driver seat
            myPed.GiveNewWeapon("WEAPON_PISTOL", 500, true);
            myPed.Tasks.Wander();

            // Show the user where the pursuit is about to happen and block very close peds.
            this.ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 50f);
            this.AddMinimumDistanceCheck(5f, myPed.Position);

            // Set up our callout message and location
            this.CalloutMessage = "GTA In Progress";
            this.CalloutPosition = SpawnPoint;

            //Play the police scanner audio for this callout (available as of the 0.2a API)
            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_GRAND_THEFT_AUTO_03 IN_OR_ON_POSITION", SpawnPoint);
            return base.OnBeforeCalloutDisplayed();

        }

Try that with returning the base.

Also, can you post your End() method? You need to be aware of the fact that calling your End method doesn't necessarily stop all your other methods: I recommend  adding some kind of boolean e.g. CalloutRunning that you set to false in your End method and make your logic loops break when it's set to false.

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.

  • 3 weeks later...
  • Author

Oddly, that just makes the callout basically do nothing - theres no ped or vehicle spawned when I get to the callout. My plugin is so messed up at the moment from trying random things, I think I'm going to just start over with a totally fresh VS solution... and probably ditch this particular callout because of all the frustration its caused me. I think some of my problems are probably coming from the fact I was just building on top of the inheritance api example, and some of the code in there I don't quite fully understand.

Thanks again for all your help Albo :)

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

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.