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] Ped runs away from police when Task is set to fight him?

Featured Replies

I'm having some issues regarding tasks in my callout. 

Whenever I set the task to do anything, it is always interrupted when I come to close and the Ped/Suspect starts running away in panic.

In this case I'm trying to make the suspect flee the player, and if he gets too close, start shooting at him instead. But, when the player gets close, the ped starts running away.

I have set the Suspects "BlockPermanentEvents" to true, but it doesn't fix my issue.

 

My current code looks like this: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using LSPD_First_Response;
using LSPD_First_Response.Engine.Scripting.Entities;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using Rage;

namespace Shroom.Callouts
{
    [CalloutInfo("Panic Button", CalloutProbability.Always)]
    public class PanicButton : Callout
    {
        private Ped attacker;
        private Blip attackerBlip;
        private Vector3 calloutSpawn;
        private LHandle pursuit;

        enum AttackerStatus
        {
            None, Attacking, Running
        }

        private AttackerStatus attackerStatus;

        public override bool OnBeforeCalloutDisplayed()
        {
            calloutSpawn = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(250f));
            ShowCalloutAreaBlipBeforeAccepting(calloutSpawn, 30f);
            AddMinimumDistanceCheck(20f, calloutSpawn);

            CalloutMessage = "Panic Button";
            CalloutPosition = calloutSpawn;

            Functions.PlayScannerAudioUsingPosition("UNITS_RESPOND_CODE_99_01", CalloutPosition);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            attacker = new Ped(calloutSpawn, 0f);
            attackerBlip = new Blip(attacker);
            attackerBlip.IsFriendly = false;
            attacker.IsPersistent = true;
            attacker.KeepTasks = true;
            attacker.BlockPermanentEvents = true;
            attacker.CanAttackFriendlies = true;

            pursuit = Functions.CreatePursuit();
            Functions.AddPedToPursuit(pursuit, attacker);
            Functions.SetPursuitCopsCanJoin(pursuit, true);
            Functions.SetPursuitIsActiveForPlayer(pursuit, true);

            attacker.Inventory.GiveNewWeapon(WeaponHash.Pistol, 100, true);

            return base.OnCalloutAccepted();
        }

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

            if (attacker.Exists())
            {
                if (Functions.IsPedArrested(attacker) || Functions.IsPedInPrison(attacker))
                {
                    End();
                }
            }

            if (!Functions.IsPursuitStillRunning(pursuit))
            {
                End();
            }

            if (attackerStatus == AttackerStatus.None)
            {
                attackerStatus = AttackerStatus.Running;
                attacker.Tasks.Flee(Game.LocalPlayer.Character, int.MaxValue, int.MaxValue);
            }
            else if(attackerStatus == AttackerStatus.Running && Game.LocalPlayer.Character.Position.DistanceTo(attacker.Position) < 20f)
            {
                Vector3 firingPosition = new Vector3(Game.LocalPlayer.Character.Position.X, Game.LocalPlayer.Character.Position.Y - 10f, Game.LocalPlayer.Character.Position.Z);
                attackerStatus = AttackerStatus.Attacking;
                attacker.Tasks.FireWeaponAt(firingPosition, int.MaxValue, FiringPattern.SingleShot);
            }
        }

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

            if (attacker.Exists())
            {
                attacker.Dismiss();

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

 

You attached the ped to the Pursuit, therefore LSPDFR will be controlling the ped as well.

Try doing ped.Tasks.Clear() and then set the shoot/fight task.

  • 4 weeks later...

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.