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 when Victim is attacked

Featured Replies

So right now im making a simple assault callout, attacker is chasing after the victim after being attacked, but when I make the attacker actually attack the callout ends

 

        public class Assault : Callout
        {
            // vehicles peds declare here for callout
            private Ped _Attacker, _Victim;
            private Vector3 _Spawnpoint;
            private Blip _AttackerBlip, _VictimBlip;

            public override bool OnBeforeCalloutDisplayed()
            {
                _Spawnpoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(100f, 200f));
                ShowCalloutAreaBlipBeforeAccepting(_Spawnpoint, 30f);
                AddMinimumDistanceCheck(30f, _Spawnpoint);
                CalloutMessage = "Simple Assault";
                CalloutPosition = _Spawnpoint;

                Functions.PlayScannerAudioUsingPosition("ATTENTION_ALL_UNITS_01 WE_HAVE_01 CITIZENS_REPORT_02 CRIME_DISTURBING_THE_PEACE_01 IN_OR_ON_POSITION", CalloutPosition);

                return base.OnBeforeCalloutDisplayed();
            }

            public override bool OnCalloutAccepted()
            {
                Game.DisplayNotification("~bold~~r~DISPATCH REPORT\n~w~Multiple witnesses report a citizen has been assaulted.");
                _Attacker = new Ped();
                _Attacker.Position = _Spawnpoint;
                _Attacker.IsPersistent = true;
                _Attacker.BlockPermanentEvents = true;
                _Attacker.KeepTasks = true;
                _AttackerBlip = new Blip(_Attacker)
                {
                    Name = "Attacker",
                    Color = Color.Red,
                    Scale = 0.8f
                };

                _Attacker.Inventory.GiveNewWeapon("WEAPON_KNIFE", 1, false);
                //StopThePed.API.Functions.setPedAlcoholOverLimit(_Attacker, true);
                StopThePed.API.Functions.setPedUnderDrugsInfluence(_Attacker, true);
                StopThePed.API.Functions.injectPedSearchItems(_Attacker);
                //_Attacker.Tasks.FightAgainst(_Victim); // Make the attacker fight the victim


                _Victim = new Ped();
                _Victim.Position = _Spawnpoint;
                _Victim.IsPersistent = true;
                _Victim.BlockPermanentEvents = true;
                _Victim.Tasks.ReactAndFlee(_Attacker); // Make the victim run away from the attacker
                _Victim.KeepTasks = true;
                _Victim.Health = 300;
                _VictimBlip = new Blip(_Victim)
                {
                    Name = "Victim",
                    Color = Color.Green,
                    Scale = 0.8f,
                    IsRouteEnabled = true
                };
                _VictimBlip.EnableRoute(Color.Yellow);

                return base.OnCalloutAccepted();
            }

            public override void Process()
            {
                if (!_Victim || !_Attacker)
                {
                    Game.DisplaySubtitle("VFC - Required peds do not exist, Ending.");
                    End();
                }

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

                // the victim stops running when youre close
                /*if (_Victim.IsFleeing && Game.LocalPlayer.Character.DistanceTo(_Victim) < 20f)
                {
                    _Victim.Tasks.ClearImmediately();
                }*/

                base.Process();
            }

            public override void End()
            {
                if (_Victim) _Victim.Dismiss();
                if (_Attacker) _Attacker.Dismiss();
                if (_AttackerBlip) _AttackerBlip.Delete();
                if (_VictimBlip) _VictimBlip.Delete();
                Game.DisplaySubtitle("VFC - Simple Assault ended and cleaned.");

                base.End();
            }
        }

 

Uncommenting the code below makes the callout instantly end

_Attacker.Tasks.FightAgainst(_Victim);
12 hours ago, CodeRepo said:
 if (!_Victim || !_Attacker)
                {
                    Game.DisplaySubtitle("VFC - Required peds do not exist, Ending.");
                    End();
                }

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

One of either becomes true
Insert debug message in both and test witch one it is that calls End
Instead of IsDead i often use Health<20. IsDead has some oddness to it so my guess is that the issue is there, but simple LogTrivial debug will show you witch is failing

See my plugin here:
https://www.youtube.com/watch?v=peqSXuTfIyY

Let me know if you find it interesting.
Best Regards.

  • Author
8 hours ago, GTAbear said:

One of either becomes true
Insert debug message in both and test witch one it is that calls End
Instead of IsDead i often use Health<20. IsDead has some oddness to it so my guess is that the issue is there, but simple LogTrivial debug will show you witch is failing

The issue was I was creating a ped after making the attacker fight the ped (which didnt exist except for the variable)

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.