Jump to content

HOW TO DISPLAY TEXT WHEN NEAR A PED


Deactivated Member

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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