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.

Callout ends on arrival

Featured Replies

Hey,

 

As a little hobby/side-ish project I'm looking into plugin development again. I'm trying to make a pretty basic callout, but I'm struggling with the follwing:

 

At this point, all I'm doing is just spawning a ped on a location and drawing a route to that ped. The problem that I get, though, is that the callout just ends whenever I arrive on "scene".

 

My code:

 

public class TestCallout : Callout
    {
        private Vector3 _spawnPoint;
        private Ped _victim;
        private Blip _areaBlip;

        public override bool OnBeforeCalloutDisplayed()
        {
            _spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));

            _victim = new Ped(_spawnPoint) {IsPersistent = true, BlockPermanentEvents = true};

            if (!_victim.Exists())
                return false;

            ShowCalloutAreaBlipBeforeAccepting(_spawnPoint, 15f);
            AddMinimumDistanceCheck(20f, _spawnPoint);

            CalloutMessage = "Test Callout";
            CalloutPosition = _spawnPoint;

            Functions.PlayScannerAudioUsingPosition("WE_HAVE IN_OR_ON_POSITION", _spawnPoint);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            _areaBlip = new Blip(_spawnPoint) {Alpha = 0.5f, Sprite = BlipSprite.Objective};
            _areaBlip.EnableRoute(Color.Purple);

            return base.OnBeforeCalloutDisplayed();
        }

        public override void OnCalloutNotAccepted()
        {
            base.OnCalloutNotAccepted();

            if (_victim.Exists())
                _victim.Delete();
        }

        public override void Process()
        {
            base.Process();
            {
                if (Game.LocalPlayer.Character.Position.DistanceTo(_spawnPoint) < 10f)
                {
                    _areaBlip.DisableRoute();
                    _areaBlip.Delete();
                }
            }
        }

        public override void End()
        {
            if (_victim.Exists())
            {
                _victim.Kill();
                _victim.Dismiss();
            }

            if (_areaBlip.Exists())
            {
                _areaBlip.DisableRoute();
                _areaBlip.Delete();
            }

            base.End();
        }
    }

 

It doesn't log anything other than LSPDFR telling me the plugin was loaded and the callout was accepted. 

 

Am I doing something wrong here, or is this expected behavior?

 

Thanks in advance. 

  • Author
17 minutes ago, LMS said:

What happens when you say the callout ends? Also in OnCalloutAccepted you are calling the wrong base method.

Thanks for your reply. As I was placing log lines in my code to verify my End function was called, I stumbled upon some stack traces in the console. 

Apparently something was wrong with my blip, causing it to crash when I attempted to delete that blip. Solving this issue also solved the plugin to stop. I probably triggered the "End" function in my code because my callout crashed.

 

I also fixed the wrong base method call, that was a mistake that got into the code when refactoring to another method. 

 

Conclusion: My plugin crashed when I arrived, causing the callout to end. 

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.