Jump to content

How to arrest a attacking Ped


Recommended Posts

Hi Guys,

 

i have another problem. I did a simple switch case and in the last case, the Ped is attacking me. All works fine, but when i try to arrest the ped with STP (holding E in my case), the Ped glitches between the Attack and Arrest Animation, and if i stop aiming, the Ped runs away.

 

Here is my process code, what do i miss? Is this not possible?

 

        public override void Process()
        {
            if (Game.LocalPlayer.Character.DistanceTo(Suspect) <= 10f)
            {
                  
                if (!convoStarted)
                {
                    Game.DisplayHelp("Press 'Y' to advance converstation", false);
                    convoStarted = true;
                    Suspect.Tasks.AchieveHeading(Game.LocalPlayer.Character.Heading - 180);
                }

                if (Game.IsKeyDown(Keys.Y))
                    counter++;
                switch (counter)
                {
                    case 0:
                        Game.DisplaySubtitle("~y~ Approach the person and talk to it with y.");
                        break;
                    case 1:
                        Game.DisplaySubtitle("1/6 ~b~Player: ~w~ " + IntroAnswersCop[rnumber1]);
                        break;
                    case 2:
                        Game.DisplaySubtitle("2/6 ~r~Suspect: ~w~ " + IntroAnswersSuspect[rnumber2] + " " + ProcessAnswersSuspect[rnumberProcessSuspect]);
                        break;
                    case 3:
                        Game.DisplaySubtitle("3/6 ~b~Player: ~w~ " + ProcessAnswersCop[rnumberProcessCop]);
                        break;
                    case 4:
                        Game.DisplaySubtitle("4/6 ~r~Suspect: ~w~ " + ProcessAnswersSuspect[rnumberProcessSuspect2]);
                        break;
                    case 5:
                        Game.DisplaySubtitle("5/6 ~b~Player: ~w~ " + ProcessAnswersCop[rnumberProcessCop2]);
                        break;
                    case 6:
                        Game.DisplaySubtitle("6/6 ~y~ handle the situation as you like. Probably survive?");
                        //starts attacking Player, but cannot be arrested, as it glitches between attacking and arrest animation
                        Suspect.Tasks.FightAgainst(Game.LocalPlayer.Character);
                        hasAttacked = true;
                        break;
                }

        }

any help appreciated,

 

thanks,

totem

Link to comment
Share on other sites

1 hour ago, totemsteiner said:
Suspect.Tasks.FightAgainst(Game.LocalPlayer.Character);

What i thinking is that this task needs a timeout or an other way to stop.

public Task FightAgainst(
	Ped target,
	int timeout
)

-should give you that. You may also try to stun the fighting Ped. Peds from callouts will surrender after a stun with stungun, but there is a problem..
STP does not allow stungun. That is one of the absurdities in STP, and one to remember: Dont ever set limitations on what Player can do just because your plugin is loaded.
Dictator-ship through plugin is never popular by users

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

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

Link to comment
Share on other sites

I'm not quite sure what GTAbear is talking about, but the problem in your code is that you are continuously tasking the suspect to fight the player.

 

Remember what's happening in your code here. Your logic is that: Process() is looping -> so if the player is within 10f of the suspect -> and your counter is 6 -> fight the player. And because Process() happens several times a second, you are repeatedly telling the suspect to fight the player several times a second.

 

That's why the suspect is likely to be glitching between both. You should really put your switch statement within your if statement checking if the key is down. Because that's when you want your switch statement to run.

 

I hope this helps. Please let me know if you need further assistance getting to grips with it! 🙂 

Prefer support on Discord? Want your log automatically read? Join my server to receive live support!

https://discord.gg/gyw5rDHCfr

 

Developer of Callout Pack 686 Callouts & Discord Bot 686 Utilities.

 

Link to comment
Share on other sites

Posted (edited)

hi @GTAbear

hi @Charlie686

 

thank you very much to both of you, i have cut my teeth on this. I was aware that the process() calls this every second, but didnt know to handle this:/

But the switch statement in my if statement makes total sense! I overlooked that! Thanks again!!!💓

 

Its working like a charm now:)

 

best regards,

totem

Edited by totemsteiner
Link to comment
Share on other sites

22 hours ago, totemsteiner said:

hi @GTAbear

hi @Charlie686

 

thank you very much to both of you, i have cut my teeth on this. I was aware that the process() calls this every second, but didnt know to handle this:/

But the switch statement in my if statement makes total sense! I overlooked that! Thanks again!!!💓

 

Its working like a charm now:)

 

best regards,

totem

That's great news. Happy coding and let me know if you get stuck anywhere else!

Prefer support on Discord? Want your log automatically read? Join my server to receive live support!

https://discord.gg/gyw5rDHCfr

 

Developer of Callout Pack 686 Callouts & Discord Bot 686 Utilities.

 

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...