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.

HOW TO DISPLAY TEXT WHEN NEAR A PED

Featured Replies

So I've finished my Hit And Run Suspect callout, I'm trying to do a Broken Down Vehicle callout, and I want a text to appear when I get near the ped, and I want to be able to cycle through different texts. Like (press Y to talk to ped) and then the subtitle comes up, I press Y again, and it goes to the next subtitle. That's what I want

  • Replies 25
  • Views 1.5k
  • Created
  • Last Reply

Top Posters In This Topic

Posted Images

basically:

 

private Ped player => Game.LocalPlayer.Character;

private ECalloutState calloutState;

private List<string> dialogWithCop = new List<string>
        {
            "~b~You~w~: Bla bla bla. (1/3)",
            "~b~Officer~w~: Bla bla bla. (2/3)",
            "~b~You~w~: Bla bla bla. (3/3)"
        };

        private int dialogWithCopIndex;


private void Main()
        {
            switch (calloutState)
            {
                case ECalloutState.EnRoute:
                    if (Cop)
                    {
                        if (Cop.IsAlive)
                        {
                            if (player.DistanceTo2D(Cop) <= 15)
                            {
                                Game.DisplayHelp(
                                    player.IsInAnyVehicle(false)
                                        ? "Leave your vehicle and speak with the ~b~Officer"
                                        : "Speak with the ~b~Officer", 5000);
                                Cop.TurnToFaceEntity(player);
                                calloutState = ECalloutState.OnScene;
                            }
                        }
                    }
                    break;
                case ECalloutState.OnScene:
                    if (Cop)
                    {
                        if (Cop.IsAlive)
                        {
                            if (player.IsOnFoot)
                            {
                                if (player.DistanceTo2D(Cop) <= 2)
                                {
                                    Game.DisplayHelp("Press ~b~Y~w~ to speak with the ~b~Officer", 5000);
                                    Cop.PlayAmbientSpeech(Utils.Utils.Random.Next(1, 3) == 2 ? "GENERIC_HI" : "GENERIC_HOWS_IT_GOING");
                                    calloutState = ECalloutState.NearCop;
                                }
                            }
                        }
                    }
                    break;
                case ECalloutState.NearCop:
                    if (Cop)
                    {
                        if (Cop.IsAlive)
                        {
                            if (player.IsOnFoot)
                            {
                                if (player.DistanceTo2D(Cop) <= 2)
                                {
                                    if (Game.IsKeyDown(Keys.Y))
                                    {
                                      	Game.HideHelp();
                                        if (dialogWithCopIndex < dialogWithCop.Count)
                                        {
                                            Game.DisplaySubtitle(dialogWithCop[dialogWithCopIndex]);
                                            dialogWithCopIndex++;
                                        }

                                        if (dialogWithCopIndex == dialogWithCop.Count)
                                        {
                                            //continue
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
            }
        }

        private enum ECalloutState
        {
            EnRoute,
            OnScene,
            NearCop
        }

 

Edited by NoNameSet

  • Author

Thanks a MIllion, so would I put that in the "public override void process()"

Because I want to make it that I'm the officer talking to the victim with the broken down car 

Yes.

Just change "cop" to your peds name you want to have the dialog with.

  • Author

Ah that makes more sense. So with the

private Vehicle myVehicle:

Private Ped myPed:

private Blip myBlip;

 

*AND SO ON*

 

The cop in the text you gave me, would be "myPed" for me, correct?

Obviously, who else are you going to assign it to? lol

Edited by NoNameSet

  • Author

Also, ECalloutState is underlined red. How would I fix that?

 

EDITED: FIXED THAT PROBLEM, I deleted ECalloutState at the end, so I had to put it bacj in. Just need help with where to put the { End() }

Edited by SRS Bladez

Your error is obvious in the image above... you cant have a method outside of a void and you are using too many brakets.

By removing the "End()" and the brackets that are in the middle of no where

  • Author

Thanks haha, the first time I copied that in, the 

"public override void End()
        {
            base.End();
            if (myBlip.Exists()) myBlip.Delete();
            if (myPed.Exists()) myPed.Delete();
            if (myVehicle.Exists()) myVehicle.Delete();
        }"

Was all underlined with red, but I realized it was because I deleted ECalloutState 😆, thanks for helping with my callouts as well. It means a lot

  • Author

The TurnToFaceEntity(player); is underlined red. How can I fix this? I also can talk to the ped

private Ped Player => Game.LocalPlayer.Character;

        private ECalloutState calloutState;

        private List<string> dialogWithmyPed = new List<string>
        {
            "~b~You~w~: Hello Sir, what seems to be the problem today? (1/3)",
            "~b~Victim~w~: G'day officer, my vehicle broke down, can you take a look and see if you can fix it please. (2/3)",
            "~b~You~w~: Of course Sir. (3/3)"
        };

        private int dialogWithmyPedIndex;


        private void Main()
        {
            switch (calloutState)
            {
                case ECalloutState.EnRoute:
                    if (myPed)
                    {
                        if (myPed.IsAlive)
                        {
                            if (Player.DistanceTo2D(myPed) <= 15)
                            {
                                Game.DisplayHelp(
                                    Player.IsInAnyVehicle(false)
                                        ? "Leave your vehicle and speak with the ~b~Victim"
                                        : "Speak with the ~b~Victim.", 5000);
                                myPed.TurnToFaceEntity(Player);
                                calloutState = ECalloutState.OnScene;
                            }
                        }
                    }
                    break;
                case ECalloutState.OnScene:
                    if (myPed)
                    {
                        if (myPed.IsAlive)
                        {
                            if (Player.IsOnFoot)
                            {
                                if (Player.DistanceTo2D(myPed) <= 10)
                                {
                                    Game.DisplayHelp("Press ~b~Y~w~ to speak with the ~b~Victim.", 5000);
                                    calloutState = ECalloutState.NearmyPed;
                                }
                            }
                        }
                    }
                    break;
                case ECalloutState.NearmyPed:
                    if (myPed)
                    {
                        if (myPed.IsAlive)
                        {
                            if (Player.IsOnFoot)
                            {
                                if (Player.DistanceTo2D(myPed) <= 3)
                                {
                                    if (Game.IsKeyDown(System.Windows.Forms.Keys.Y))
                                    {
                                        Game.HideHelp();
                                        if (dialogWithmyPedIndex < dialogWithmyPed.Count)
                                        {
                                            Game.DisplaySubtitle(dialogWithmyPed[dialogWithmyPedIndex]);
                                            dialogWithmyPedIndex++;
                                        }

                                        if (dialogWithmyPedIndex == dialogWithmyPed.Count)
                                        {
                                            //continue
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
            }
        }

        private enum ECalloutState
        {
            EnRoute,
            OnScene,
            NearmyPed
        }

Edited by SRS Bladez

public static void TurnToFaceEntity(this Ped ped, Entity entity, int duration = -1/*-1 = forever...*/)
{
    NativeFunction.Natives.TASK_TURN_PED_TO_FACE_ENTITY(ped, entity, duration);
}

Edited by NoNameSet

If you don't know that, maybe you should go back to learning c# again.

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.