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 doesnt attack player

Featured Replies

The attacker ped does not attack me, I want the attacker ped to attack me when I get in range (20f)

 

Could contain: pc game, screenshot, outdoor, video game software, digital compositing, strategy video game, adventure game

        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(300f, 3000f));
                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();
                _Victim = new Ped();

                _Attacker.Position = _Spawnpoint;
                _Attacker.IsPersistent = 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.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();
            }

            private bool checker = true;

            public override void Process()
            {
                if (!_Victim || !_Attacker)
                {
                    Game.DisplaySubtitle("~b~~bold~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();
                }*/

                if (checker == true && Game.LocalPlayer.Character.DistanceTo(_Attacker) < 20f)
                {
                    _Attacker.Tasks.Wander();
                    _Attacker.RelationshipGroup = RelationshipGroup.HatesPlayer;
                    _Attacker.Tasks.FightAgainstClosestHatedTarget(25f);
                    Game.DisplaySubtitle("~r~~bold~I'm going to kill you!", 2);
                    checker = false;
                }

                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();
            }
        }

 

  • Author
8 hours ago, GTAbear said:

FightAgainstClosestHatedTarget is buggy as h...
FightAgainst(Game.LocalPlayer.Character) instead

 

When using that before the attacker seems to continue chasing the victim ped until I do something to knock them over by shooting their leg, tapping them with the car etc

                if (checker == true && Game.LocalPlayer.Character.DistanceTo(_Attacker) < 20f)
                {
                    _Attacker.Tasks.Wander();
                    _Attacker.Tasks.FightAgainst(Game.LocalPlayer.Character);
                    Game.DisplaySubtitle("~r~~bold~I'm going to kill you!", 2);
                    checker = false;
                }

 

  • Author
8 hours ago, GTAbear said:

Then you need to stop and clear that chase task before you start a task for fighting with Game.LocalPlayer.Character

I have tried both of the following code snippets and neither have worked, 2 things happen with this;

1. the attacker continues to chase the victim

2. the attacker becomes glitched and stands still in a T pose position

 

                    _Attacker.Tasks.ClearImmediately();
                    _Attacker.Tasks.FightAgainst(Game.LocalPlayer.Character);

 

                    _Attacker.Tasks.Clear();
                    _Attacker.Tasks.FightAgainst(Game.LocalPlayer.Character);

 

Edited by CodeRepo

13 hours ago, CodeRepo said:

I have tried both of the following code snippets

 I get weirdness with Tasks.ClearImmediately, but you already also tried Attacker.Tasks.Clear, and that also failed..
Hmm..

Perhaps setting victim to the same relationship-group as Attacker or just changing the relation to mutual respect would stop Attacker chasing the Victim, but that does not explain the T-position after Attacker.Tasks.Clear
Letme try something and come back to you

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

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

Try this
I have changed weapon-usage added a debug in process and used the default relationshipgroup instead of the one you used, witch was never mutual, and removed the STP meh from the file. Dont add that before the base works

Spoiler

        public class Assault : Callout
        {
            // vehicles peds declare here for callout
            private Ped _Attacker, _Victim;
            private Vector3 _Spawnpoint;
            private Blip _AttackerBlip, _VictimBlip;
            private bool checker = true;//odd usage and place -moved


            public override bool OnBeforeCalloutDisplayed()
            {
                _Spawnpoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f, 3000f));
                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();
                _Victim = new Ped();

                _Attacker.Position = _Spawnpoint;
                _Attacker.IsPersistent = true;
                _AttackerBlip = new Blip(_Attacker)
                {
                    Name = "Attacker",
                    Color = Color.Red,
                    Scale = 0.8f
                };

                _Attacker.Inventory.GiveNewWeapon("WEAPON_KNIFE", -1, true);//no end as -1 && should be true
                //NO! we dont want this now!
                //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.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("~b~~bold~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();
                }*/

                if (checker == true && Game.LocalPlayer.Character.DistanceTo(_Attacker) < 20f)
                {
                    
                    //_Attacker.Tasks.Wander(); //Why?

_Attacker.Tasks.Clear();
                    _Attacker.RelationshipGroup = RelationshipGroup.HATES_PLAYER;//wrong default group
                    _Attacker.Tasks.FightAgainst(Game.LocalPlayer.Character);//not closest
                    Game.DisplaySubtitle("~r~~bold~I'm going to kill you!", 2);
                    checker = false;
                    Game.LogTrivial("?????????????? Inside  DistanceTo(_Attacker) < 20f ");
                }

                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();
            }
        }

 

Edited by GTAbear

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

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

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.