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.

[SOLVED] Arrest a ped is bugged (in my callout)

Featured Replies

  • Replies 21
  • Views 899
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • Hi! This should help:   //Suspect - Ped if (Functions.IsPedGettingArrested(Suspect))                 {                     //Clears task (Tasks.FightAgainst();)                     Suspect.Task

  • Mytical49
    Mytical49

    But the "fight against" that is in the process will be repeated after Task is cleared right?  Edit: what i mean is: Is the Task.Clear(); permanent or if a function is executed after the Task.Clea

  • Than the only thing I can recommend now, is adding if (Lock && Functions.IsPedGettingArrested(Suspect)) To every ped

Hi!
This should help:
 

//Suspect - Ped
if (Functions.IsPedGettingArrested(Suspect))
                {
                    //Clears task (Tasks.FightAgainst();)
                    Suspect.Tasks.Clear();
                    //Or for animation Suspect.Tasks.PlayAnimation();
                    Suspect.Tasks.ClearSecondary();
                }

 

Edited by Fentered

-Fentered

  • Author
35 minutes ago, Fentered said:

Hi!
This should help:
 

//Suspect - Ped
if (Functions.IsPedGettingArrested(Suspect))
                {
                    //Clears task (Tasks.FightAgainst();)
                    Suspect.Tasks.Clear();
                    //Or for animation Suspect.Tasks.PlayAnimation();
                    Suspect.Tasks.ClearSecondary();
                }

 

Thanks for helping me @Fentered it worked but now the ped just stays still and I can't arrest him.

by Mytical.

  • Author
10 minutes ago, Fentered said:

Can you send rph log?

Infact there is nothing in the logs because i believe it is a code error, here is the part of code where there is the function, i may have done something wrong:

Spoiler
foreach (Ped element in familiesPed)
                {
                   
                    for (; hf < 10; hf++)
                    {
                        Game.LogTrivial("w");
                        if (ballasPed[hf].IsAlive)
                        {
                            Game.LogTrivial("x");
                            if (!Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.FightAgainst(ballasPed[hf]);
                            }
                            if (Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.Clear();
                            }

                        }

                    }
                    
                    hf = 0;
                    h++;
                }

                foreach (Ped element in ballasPed)
                {

                  
                    for (; gb < 10; gb++)
                    {
                      
                        if (familiesPed[gb].IsAlive)
                        {
                            
                            if (!Functions.IsPedGettingArrested(ballasPed[g]))
                            {
                                ballasPed[g].Tasks.FightAgainst(familiesPed[gb]);
                            }
                            if (Functions.IsPedGettingArrested(ballasPed[g]))
                            {
                                ballasPed[g].Tasks.Clear();
                            }
                        }
                        
                    }
                    gb = 0;
                   g++;
                }

                h = 0;
                g = 0;

 

 

by Mytical.

@Mytical49

In

                            if (!Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.FightAgainst(ballasPed[hf]);
                            }
                            if (Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.Clear();
                            }

Try removing 
 

if (!Functions.IsPedGettingArrested(familiesPed[h]))

And Adding "Lock" to 

 if (Functions.IsPedGettingArrested(ballasPed[g]))

Example:

//Adding lock
private bool Lock = true;

//Same function but with a lock
 if (Lock && Functions.IsPedGettingArrested(Suspect))
 {
    //Setting lock to false, to make task exucude only 1 time
    Lock = false;
    Suspect.Tasks.Clear();
 }

 

Edited by Fentered

-Fentered

  • Author
4 minutes ago, Fentered said:
 if (!Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.FightAgainst(ballasPed[hf]);
                            }
                            if (Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.Clear();
                            }

Try removing 
 

if (!Functions.IsPedGettingArrested(familiesPed[h]))

And Adding "Lock" to 

 if (Functions.IsPedGettingArrested(ballasPed[g]))

Example:

//Adding lock
private bool Lock = true;

//Same function but with a lock
 if (Lock && Functions.IsPedGettingArrested(Suspect))
 {
    //Setting lock to false, to make task exucude only 1 time
    Lock = false;
    Suspect.Tasks.Clear();
 }

 

But the "fight against" that is in the process will be repeated after Task is cleared right? 

Edit: what i mean is: Is the Task.Clear(); permanent or if a function is executed after the Task.Clear();  it will be still executed ?

Edited by Mytical49

by Mytical.

1 minute ago, Mytical49 said:

But the "fight against" that is in the process will be repeated after Task is cleared right? 

It shouldn't

3 minutes ago, Mytical49 said:

But the "fight against" that is in the process will be repeated after Task is cleared right? 

Edit: what i mean is: Is the Task.Clear(); permanent or if a function is executed after the Task.Clear();  it will be still executed ?

Permanent, but as I see in your code, it will try to execute FightAgaints task, again, because of 
 

if (ballasPed[hf].IsAlive)


So I would recommend changing it to something else, or adding "Lock" as I showed in previous message, so that it will execute "FightAgaints" only once

-Fentered

  • Author
9 minutes ago, Fentered said:

It shouldn't

Permanent, but as I see in your code, it will try to execute FightAgaints task, again, because of 
 

if (ballasPed[hf].IsAlive)


So I would recommend changing it to something else, or adding "Lock" as I showed in previous message, so that it will execute "FightAgaints" only once

It won't work because I need the fightagainst to repeat because the target changes (the callout is about 2 gangs fighting each other)

by Mytical.

Just now, Mytical49 said:

It won't work because I need the fightagainst to repeat because the target changes (the callout is about 2 gangs fighting each other)

So 

ballasPed[hf]

Is not just 1 ped, but a group of them?

-Fentered

  • Author
2 minutes ago, Fentered said:

So 

ballasPed[hf]

Is not just 1 ped, but a group of them?

Here is all of the code, sorry i know it's cluttered but maybe it will help you

 

 

Spoiler
using LSPD_First_Response.Mod.Callouts;
using Rage;
using Rage.Native;
using System;
using LSPD_First_Response.Mod.API;




namespace Mytical_Callout.Callouts
{
    [CalloutInfo("GangFight", CalloutProbability.Medium)]
    class Gang : Callout
    {




        private Vector3 areaFamillies;
        private Vector3 areaBallas;
        private Vector3 middle;
        private Ped[] ballasPed;
        private Ped[] familiesPed;
        private bool[] familliesDead;
        private bool[] ballasDead;
        private Blip middleBlip;
        private Ped middlePed;
        private LHandle endPursuit;
        private bool[] ftask = { false, false, false, false, false, false, false, false, false, false };
        private bool[] btask = { false, false,false, false, false, false, false, false, false,false };
        private bool onePursuit = false;

        private int ballasDeadCounter = 0;
        private int familliesDeadCounter = 0;
        private int fblip = 0;
        private int bblip = 0;
        private int player100f = 0;
        private int more = 0;
        private int g = 0;
        private int h = 0;
        private int gb = 0;
        private int hf = 0;
        private int y = 0;
        private int i = 0;
        private int z = 0;
        private int f = 0;
        private int yx = 0;
        private int ix = 0;
        private int zx = 0;
        private int fx = 0;
        private int v = 0;
        private int b = 0;
        private int belement = 0;
        private int felement = 0;
        private int fbelement = 0;
        private int bfelement = 0;
        private uint topSpeed;

        bool[] familliesAlive;
        bool[] ballasAlive;
        string[] weapon = { "WEAPON_SNSPISTOL", "WEAPON_MACHETE", "WEAPON_KNIFE", "WEAPON_KNUCKLE" };
        string[] familiesDress = { "g_m_y_famca_01", "g_m_y_famdnf_01", "g_m_y_famfor_01", "g_f_y_families_01", "mp_m_famdd_01" };
        string[] ballasDress = { "ig_ballasog", "g_f_y_ballas_01", "g_m_y_ballaeast_01", "g_m_y_ballaorig_01", "g_m_y_ballasout_01" };


        public override bool OnBeforeCalloutDisplayed()
        {

            Game.LogTrivial("a");
            Random rdm = new Random();

            ballasPed = new Ped[10];
            familiesPed = new Ped[10];
            areaFamillies = new Vector3(-159, -1709, 30);
            middle = new Vector3(-128, -1741, 30);
            areaBallas = new Vector3(-95, -1770, 30);
            familliesDead = new bool[10];
            ballasDead = new bool[10];
            middlePed = new Ped(middle, 0f);
            Game.LogTrivial("b");




            foreach (Ped element in familiesPed)
            {
                Game.LogTrivial("d");
                familiesPed[y] = new Ped(familiesDress[i], areaFamillies, 0f);
                familiesPed[y].RelationshipGroup = "FAMILLIES";
                familiesPed[y].CanAttackFriendlies = false;
                familiesPed[y].IsPersistent = true;
                familiesPed[y].Accuracy = 25;
                familiesPed[y].BlockPermanentEvents = true;
                familiesPed[y].Inventory.GiveNewWeapon(weapon[rdm.Next(0, 4)], -1, true);
                NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[y], false);//CREATE AI BLIP FOR PED
                NativeFunction.CallByHash<ulong>(0x0C4BBF625CA98C4E, familiesPed[y], false);// SET BLIP TO ALWAYS SHOWN
                NativeFunction.CallByHash<ulong>(0x3EED80DFF7325CAA, familiesPed[y], false);// SET TO NEVER SHOW THE CONE
                NativeFunction.CallByHash<ulong>(0xE52B8E7F85D39A08, familiesPed[y], 0);//MAKE THE COLOR OF THE BLIP RED
                i++;
                y++;
                if (i == 5)
                {
                    i = 0;
                }
            }



            foreach (Ped element in ballasPed)
            {
                ballasPed[z] = new Ped(ballasDress[f], areaBallas, 0f);
                ballasPed[z].RelationshipGroup = "BALLAS";
                ballasPed[z].CanAttackFriendlies = false;
                ballasPed[z].StaysInGroups = true;
                ballasPed[z].Accuracy = 25;
                ballasPed[z].IsPersistent = true;
                ballasPed[z].BlockPermanentEvents = true;
                ballasPed[z].Inventory.GiveNewWeapon(weapon[rdm.Next(0, 4)], -1, true);
                NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, ballasPed[z], false);//CREATE AI BLIP FOR PED
                NativeFunction.CallByHash<ulong>(0x0C4BBF625CA98C4E, ballasPed[z], false);// SET BLIP TO ALWAYS SHOWN
                NativeFunction.CallByHash<ulong>(0x3EED80DFF7325CAA, ballasPed[z], false);// SET TO NEVER SHOW THE CONE
                NativeFunction.CallByHash<ulong>(0xE52B8E7F85D39A08, ballasPed[z], 0);//MAKE THE COLOR OF THE BLIP RED

                f++;
                z++;
                if (f == 5)
                {
                    f = 0;
                }
            }


            foreach (bool element in ballasDead)
            {
                ballasDead[zx] = false;
                zx++;
            }

            foreach (bool element in familliesDead)
            {

                familliesDead[yx] = false;
                yx++;

            }

            topSpeed = World.AddSpeedZone(middle, 50f, 5f);
            middleBlip = middlePed.AttachBlip();

            ShowCalloutAreaBlipBeforeAccepting(middle, 30f);
            this.AddMinimumDistanceCheck(5f, middle);
            CalloutMessage = "GANG FIGHT";
            CalloutPosition = middle;
            CalloutAdvisory = "two gang attack each other";
            Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_ASSAULT_WITH_A_DEADLY_WEAPON_01 IN_OR_ON_POSITION", middle);

            return base.OnBeforeCalloutDisplayed();
        }
        public override bool OnCalloutAccepted()
        {
            middleBlip.IsRouteEnabled = true;
            return base.OnCalloutAccepted();
        }
        public override void OnCalloutNotAccepted()
        {
            End();
            base.OnCalloutNotAccepted();
        }
        public override void Process()
        {

            if (player100f == 1 && more == 0)
            {
                Game.SetRelationshipBetweenRelationshipGroups("FAMILLIES", "BALLAS", Relationship.Hate);
                Game.SetRelationshipBetweenRelationshipGroups("BALLAS", "FAMILLIES", Relationship.Hate);
                more = 10;

            }

            ix = 0;
            foreach (Ped element in ballasPed)
            {
                if (ballasPed[fx].DistanceTo(middle) > 100)
                {
                    NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[fx], false);
                    ballasPed[fx].Dismiss();
                    ballasDeadCounter++;
                }
                fx++;
            }
            fx = 0;





            Game.LogTrivial("p4");

            if (player100f == 0)
            {
                if (Game.LocalPlayer.Character.DistanceTo(middle) < 150f)
                {
                    foreach (Ped element in familiesPed)
                    {
                        NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[fbelement], true);
                        NativeFunction.CallByHash<ulong>(0x0C4BBF625CA98C4E, familiesPed[fbelement], true);// SET BLIP TO ALWAYS SHOWN
                        NativeFunction.CallByHash<ulong>(0x3EED80DFF7325CAA, familiesPed[fbelement], false);// SET TO NEVER SHOW THE CONE
                        fbelement++;
                    }
                    foreach (Ped element in ballasPed)
                    {
                        NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, ballasPed[bfelement], true);
                        NativeFunction.CallByHash<ulong>(0x0C4BBF625CA98C4E, ballasPed[bfelement], true);// SET BLIP TO ALWAYS SHOWN
                        NativeFunction.CallByHash<ulong>(0x3EED80DFF7325CAA, ballasPed[bfelement], false);// SET TO NEVER SHOW THE CONE
                        bfelement++;
                    }
                    middleBlip.IsRouteEnabled = false;
                    middlePed.Delete();
                    Game.DisplayNotification("100f");
                    player100f = 1;
                }
            }
            Game.LogTrivial("p5");
            if (player100f == 1)
            {
                Game.LogTrivial("p6");
                foreach (Ped element in familiesPed)
                {
                   
                    for (; hf < 10; hf++)
                    {
                        Game.LogTrivial("w");
                        if (ballasPed[hf].IsAlive)
                        {
                            Game.LogTrivial("x");
                            if (!Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.FightAgainst(ballasPed[hf]);
                            }
                            

                        }

                    }
                    
                        if (Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.Clear();
                            }

                    hf = 0;
                    h++;
                }

                foreach (Ped element in ballasPed)
                {

                  
                    for (; gb < 10; gb++)
                    {
                      
                        if (familiesPed[gb].IsAlive)
                        {
                            
                            if (!Functions.IsPedGettingArrested(ballasPed[g]))
                            {
                                ballasPed[g].Tasks.FightAgainst(familiesPed[gb]);
                            }
                            
                        }
                        
                    }
                     if (Functions.IsPedGettingArrested(ballasPed[g]))
                      {
                      ballasPed[g].Tasks.Clear();
                       }
                    gb = 0;
                   g++;
                }

                h = 0;
                g = 0;
            }
            string ballasDeadCounterstring = Convert.ToString(ballasDeadCounter);
            string familliesDeadCounterstring = Convert.ToString(familliesDeadCounter);

            Game.LogTrivial(ballasDeadCounterstring);
            Game.LogTrivial(familliesDeadCounterstring);
            Game.LogTrivial("p8");
            foreach(Ped element in familiesPed)
            {
                if(!familiesPed[ix].Exists())
                {
                    Game.LogTrivial("familliesnotexist");
                    familliesDeadCounter++;
                }
                if (familiesPed[ix].IsAlive)
                {
                    if (Functions.HasPedSurrendered(familiesPed[ix]))
                    {
                        Game.LogTrivial("familiessurrender");
                        NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[ix], false);
                        familliesDeadCounter++;
                    }
                   /* if (familiesPed[ix].DistanceTo(middle) > 250)
                    {
                        NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[ix], false);
                        familiesPed[ix].Dismiss();
                        familliesDeadCounter++;
                    }*/
                }
               ix++;
            }
            ix = 0;
            foreach (Ped element in ballasPed)
            {
                if(!ballasPed[fx].Exists())
                {
                    Game.LogTrivial("ballasnot exist");
                    ballasDeadCounter++;
                }
                if (ballasPed[fx].IsAlive)
                {
                    if(Functions.HasPedSurrendered(ballasPed[fx]))
                     {
                        Game.LogTrivial("ballassurrender");
                        NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, ballasPed[fx], false);
                        ballasDeadCounter++;
                    }
                    /*if (ballasPed[fx].DistanceTo(middle) > 250)
                    {
                        NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[fx], false);
                        ballasPed[fx].Dismiss();
                        ballasDeadCounter++;
                    }*/
                }
                fx++;
            }
            fx = 0;


            foreach (bool element in ballasDead)
            {
                Game.LogTrivial("p7");
                if(ballasPed[v].IsDead && ballasDead[v] == false)
                {
                    Game.LogTrivial("ballasdead");
                    ballasDead[v] = true;
                    ballasDeadCounter++;
                }
                    
                
                v++;
            }
            v = 0;
           foreach (bool element in familliesDead)
            {
                if (familiesPed[b].IsDead && familliesDead[b] == false)
                {
                    Game.LogTrivial("familiesdead");
                    familliesDead[b] = true;
                    familliesDeadCounter++;
                }
                b++;
               
            }
            b = 0;

            

           if(!Functions.IsCalloutRunning())
            {
                End();
            }

           if(ballasDeadCounter == 10 && familliesDeadCounter == 10)
            {
                End();
            }
            if(familliesDeadCounter == 10 && ballasDeadCounter < 10)
            {
                if (onePursuit == false)
                {
                    this.endPursuit = Functions.CreatePursuit();
                    

                    foreach (Ped element in ballasPed)
                    {
                        Game.LogTrivial("p10");
                        if (ballasPed[belement].IsAlive)
                        {
                            Functions.SetPursuitIsActiveForPlayer(endPursuit, true);
                            Functions.AddPedToPursuit(endPursuit, ballasPed[belement]);
                            Game.LogTrivial("p11");

                        }
                        belement++;
                    }
                  onePursuit = true;
                }
            }
            belement = 0;
            if (ballasDeadCounter == 10 && familliesDeadCounter < 10)
            {
                if (onePursuit == false)
                {
                    this.endPursuit = Functions.CreatePursuit();
                    foreach (Ped element in familiesPed)
                    {
                        Game.LogTrivial("p10");
                        if (familiesPed[felement].IsAlive)
                        {
                            Functions.AddPedToPursuit(endPursuit, familiesPed[felement]);
                            Functions.SetPursuitIsActiveForPlayer(endPursuit, true);
                            Game.LogTrivial("p11");

                        }
                        felement++;
                    }
                    onePursuit = true;
                }
            }
            felement = 0;

            base.Process();
        }

        public override void End()
        {
            World.RemoveSpeedZone(topSpeed);

            foreach (Ped element in familiesPed)
            {
                if (familiesPed[fblip].IsAlive)
                {
                  
                    NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, familiesPed[fblip], false);
                      familiesPed[fblip].Dismiss();
                }
                fblip++;

            }
            foreach (Ped element in ballasPed)
            {
                if (ballasPed[bblip].IsAlive)
                {
                   NativeFunction.CallByHash<ulong>(0xD30C50DF888D58B5, ballasPed[bblip], false);
                    ballasPed[bblip].Dismiss();
                    
                }
                bblip++;

            }


            LSPD_First_Response.Mod.API.Functions.StopCurrentCallout();

            base.End();
        }









    }
}

 

 

8 minutes ago, Fentered said:

Than the only thing I can recommend now, is adding

if (Lock && Functions.IsPedGettingArrested(Suspect))

To every ped

Thanks, the Lock thing work ! I still have a minor error but i will fix that easily .

by Mytical.

@Mytical49
When 

if (Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.Clear();
                            }

Task clears for all peds in familiesPed
So, only thing I can think of, is creating "Ped" for every ped in familiesPed/ballasPed

//creating new ped
pivate Ped familiesPed_1;

familiesPed_1 = new Ped("g_m_y_famca_01",SpawnPoint, 50f);
familiesPed_1.IsPersistent = true;
familiesPed_1.BlockPermanentEvents = true;
//And then do 
if (Functions.IsPedGettingArrested(familiesPed_1))
   {
     familiesPed_1.Tasks.Clear();
   }

 

Edited by Fentered

-Fentered

  • Author
2 minutes ago, Fentered said:

When 

if (Functions.IsPedGettingArrested(familiesPed[h]))
                            {
                                familiesPed[h].Tasks.Clear();
                            }

Task clears for all peds in familiesPed
So, only thing I can think of, is adding Ped for every ped in familiesPed/ballasPed

//creating new ped
pivate Ped familiesPed_1;

familiesPed_1 = new Ped("g_m_y_famca_01",SpawnPoint, 50f);
familiesPed_1.IsPersistent = true;
familiesPed_1.BlockPermanentEvents = true;
//And then do 
if (Functions.IsPedGettingArrested(familiesPed_1))
   {
     familiesPed_1.Tasks.Clear();
   }

 

No, the "h" which is a variable takes 1 each time a foreach loop happens, which in the end makes h go through all the peds

by Mytical.

  • Author
4 minutes ago, Fentered said:

So you can mark specific ped with "h"?

Yes, in fact in an array the content of [] after the name of the array determines the element selected in the array so if I do the array :

alphabet[] = { a, b, c , d , f}

and then

ConsolePrint(alphabet[0]);
the console will show

"a"

so ConsolePrint(alphabet[4]); returns

"f"

(the first element is always numbered 0)

@Fentered the Task.Clear(); can can avoid a ped from being arrested ?

by Mytical.

Just now, Mytical49 said:

Yes, in fact in an array the content of [] after the name of the array determines the element selected in the array so if I do the array :

alphabet[] = { a, b, c , d , f}

and then

ConsolePrint(alphabet[0]);
the console will show

"a"

so ConsolePrint(alphabet[4]); returns

"f"

(the first element is always numbered 0)

then do 

if (Functions.IsPedGettingArrested(familiesPed[h]))
   {
        familiesPed[h].Tasks.Clear();
   }

for every ped

-Fentered

  • Author
Just now, Fentered said:

then do 

if (Functions.IsPedGettingArrested(familiesPed[h]))
   {
        familiesPed[h].Tasks.Clear();
   }

for every ped

did you see the loop foreach on the top ? It mean it will execute everythings below

by Mytical.

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.