Jump to content

Game.DisplayHelp(""); Not Working..


ToastinYou

Recommended Posts

My Game.DisplayHelp(""); in this code below is not working. It doesn't pop up or anything. I'm really confused. I have tried removing the Settings.TalkKey part, didn't work. I've tried moving it down to process, didn't work, I'm just really confused. If anyone knows why this is, please let me know - thank you! (It's at the end of OnCalloutAccepted(); [ P.S. I have no errors. ]

 

Spoiler

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rage;
using Rage.Native;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Engine.Scripting.Entities;
using LSPD_First_Response.Engine;
using System.Drawing;

namespace ToastyCallouts.Callouts
{
    [CalloutInfo("SchoolShooting", CalloutProbability.VeryHigh)]

    public class SchoolShooting : Callout
    {
        public LHandle Pursuit;
        public Vector3 SpawnPoint;
        public Blip myBlip;
        public Ped myShooter;
        public Ped myVictim1;
        public Ped myVictim2;
        public Ped myVictim3;
        public Ped myVictim4;
        public Ped myVictim5;
        public Ped myVictim6;
        public Vehicle myCopCar1;
        public Vehicle myCopCar2;
        public Ped myCopPed1;
        public Ped myCopPed2;
        public Ped myAmbulancePed1;
        public Ped myAmbulancePed2;
        public Ped myFireTruckPed1;
        public Ped myFireTruckPed2;
        public Vehicle myAmbulance;
        public Vehicle myFireTruck;

        enum PedPropsData
        {
            prop_med_bag_01
        };
        enum CalloutStates { None = 0, EnRoute, OnScene, DecisionMade };
        enum ConversationTypes { TalkToShooter, Regular, Danger, None = 0 }
        ConversationTypes Current = ConversationTypes.None;
        CalloutStates CalloutState = CalloutStates.None;
        List<String>.Enumerator CurrentDialog;

        Dictionary<ConversationTypes, List<String>> DialogMessages = new Dictionary<ConversationTypes, List<string>>()
        {
            { ConversationTypes.Regular, new List<string>()
            {
                "Hello Officer!",
                "I'm sorry for not paying attention.",
                "Have a nice day!"
            }
        },
            { ConversationTypes.Danger, new List<string>()
            {
                "You better get away from me!",
                "I'm having a very bad day.",
                "Okay, time to die."
            }
            },
                { ConversationTypes.TalkToShooter, new List<string>()
                {
                    "~b~Officer " + Settings.OfficerName + "~w~: Let it end peacefully by putting the gun down! (1/1)",
                    "~r~Suspect~w~: Why would I? Life isn't worth living for.. (1/2)",
                    "~r~Suspect~w~: THEY'RE ALL SLAVES TO THIS SCHOOL, I SHALL LET THEM BE FREE! (2/2)",
                    "~b~Officer " + Settings.OfficerName + "~w~: They are scared, can't you see? In their faces.. (1/2)",
                    "~b~Officer " + Settings.OfficerName + "~w~: Put it down and we can help you! (2/2)"
            }
            }
        };

        public override bool OnBeforeCalloutDisplayed()
        {
            SpawnPoint SpawnPointmyShooter = new SpawnPoint(0.0f, new Vector3(-1756.265f, 140.697f, 64.372f));
            SpawnPoint SpawnPointmyVictim1 = new SpawnPoint(0.0f, new Vector3(-1756.250f, 127.546f, 64.371f));
            SpawnPoint SpawnPointmyVictim2 = new SpawnPoint(0.0f, new Vector3(-1754.835f, 125.792f, 64.371f));
            SpawnPoint SpawnPointmyVictim3 = new SpawnPoint(0.0f, new Vector3(-1753.403f, 124.138f, 64.514f));
            SpawnPoint SpawnPointmyVictim4 = new SpawnPoint(0.0f, new Vector3(-1758.757f, 129.919f, 64.371f));
            SpawnPoint SpawnPointmyVictim5 = new SpawnPoint(0.0f, new Vector3(-1759.993f, 131.448f, 64.513f));
            SpawnPoint SpawnPointmyVictim6 = new SpawnPoint(0.0f, new Vector3(-1761.016f, 132.575f, 64.519f));
            SpawnPoint SpawnPointmyCopCar1 = new SpawnPoint(0.0f, new Vector3(-1752.808f, 152.083f, 64.020f));
            SpawnPoint SpawnPointmyCopCar2 = new SpawnPoint(0.0f, new Vector3(-1744.750f, 140.999f, 64.006f));
            SpawnPoint SpawnPointmyCopPed1 = new SpawnPoint(0.0f, new Vector3(-1752.661f, 155.667f, 64.371f));
            SpawnPoint SpawnPointmyCopPed2 = new SpawnPoint(0.0f, new Vector3(-1741.227f, 141.438f, 64.367f));
            SpawnPoint SpawnPointmyAmbulance = new SpawnPoint(0.0f, new Vector3(-1738.036f, 166.311f, 63.930f));
            SpawnPoint SpawnPointmyFireTruck = new SpawnPoint(0.0f, new Vector3(-1730.846f, 167.183f, 64.438f));
            SpawnPoint = new Vector3(-1758.445f, 125.273f, 64.774f);
            Game.LogTrivial("New SpawnPoint's.");

            myShooter = new Ped(SpawnPointmyShooter.Position);
            myVictim1 = new Ped(SpawnPointmyVictim1.Position);
            myVictim2 = new Ped(SpawnPointmyVictim2.Position);
            myVictim3 = new Ped(SpawnPointmyVictim3.Position);
            myVictim4 = new Ped(SpawnPointmyVictim4.Position);
            myVictim5 = new Ped(SpawnPointmyVictim5.Position);
            myVictim6 = new Ped(SpawnPointmyVictim6.Position);
            Model[] VehicleModels = new Model[]
            {
                "POLICE", "POLICE2", "POLICE3", "POLICE4", "FBI"
            };
            myCopCar1 = new Vehicle(VehicleModels[new Random().Next(VehicleModels.Length)], SpawnPointmyCopCar1.Position);
            myCopCar2 = new Vehicle(VehicleModels[new Random().Next(VehicleModels.Length)], SpawnPointmyCopCar2.Position);
            myCopPed1 = new Ped("s_m_y_cop_01", SpawnPointmyCopPed1.Position, 0.0f);
            myCopPed2 = new Ped("s_m_y_cop_01", SpawnPointmyCopPed2.Position, 0.0f);
            myAmbulance = new Vehicle("AMBULANCE", SpawnPointmyAmbulance.Position);
            NativeFunction.CallByName<uint>("SET_VEHICLE_LIGHTS", myAmbulance, 3);
            myFireTruck = new Vehicle("FIRETRUK", SpawnPointmyFireTruck.Position);
            NativeFunction.CallByName<uint>("SET_VEHICLE_LIGHTS", myFireTruck, 3);
            myAmbulancePed1 = new Ped("s_m_m_paramedic_01", SpawnPointmyAmbulance.Position, 0.0f);
            myAmbulancePed2 = new Ped("s_m_m_paramedic_01", SpawnPointmyAmbulance.Position, 0.0f);
            myAmbulancePed1.WarpIntoVehicle(myAmbulance, -1);
            myAmbulancePed2.WarpIntoVehicle(myAmbulance, 0);
            myFireTruckPed1 = new Ped("s_m_y_fireman_01", SpawnPointmyFireTruck.Position, 0.0f);
            myFireTruckPed2 = new Ped("s_m_y_fireman_01", SpawnPointmyFireTruck.Position, 0.0f);
            myFireTruckPed1.WarpIntoVehicle(myFireTruck, -1);
            myFireTruckPed2.WarpIntoVehicle(myFireTruck, 0);

            Game.LogTrivial("Create Peds/Vehicle's.");

            ShowCalloutAreaBlipBeforeAccepting(new Vector3(-1758.445f, 125.273f, 64.774f), 30f);
            AddMinimumDistanceCheck(100f, new Vector3(-1758.445f, 125.273f, 64.774f));
            if (Game.LocalPlayer.Character.DistanceTo(SpawnPoint) > 3500f) { return false; }
            Game.LogTrivial("Create Blip.");

            NativeFunction.CallByName<uint>("GIVE_WEAPON_TO_PED", myShooter, 0xBFEFFF6D, -1, true, true);
            NativeFunction.CallByName<uint>("GIVE_WEAPON_TO_PED", myCopPed1, 0x1B06D571, -1, true, true);
            NativeFunction.CallByName<uint>("GIVE_WEAPON_TO_PED", myCopPed2, 0x1B06D571, -1, true, true);
            NativeFunction.CallByName<uint>("GIVE_WEAPON_TO_PED", myFireTruckPed1, 0x060EC506, -1, true, true);
            NativeFunction.CallByName<uint>("GIVE_WEAPON_TO_PED", myFireTruckPed2, 0x060EC506, -1, true, true);
            Game.LogTrivial("Give myShooter Weapon.");

            this.CalloutMessage = "School Shooting";
            this.CalloutPosition = new Vector3(-1758.445f, 125.273f, 64.774f);
            Game.LogTrivial("Callout Message's.");

            Functions.PlayScannerAudioUsingPosition("ATTENTION_ALL_UNITS OFFICERS_REPORT ASSAULT_WITH_WEAPON IN_OR_ON_POSITION", new Vector3(-1758.445f, 125.273f, 64.774f));
            Game.LogTrivial("Play Scanner Audio.");

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            Current = ConversationTypes.TalkToShooter;
            CalloutState = CalloutStates.EnRoute;
            CurrentDialog = DialogMessages[Current].GetEnumerator();

            Game.DisplayNotification("~b~Officer " + Settings.OfficerName + "~w~: Dispatch, show me responding Code 3 to the School Shooting.");
            Functions.PlayScannerAudio("10-4");

            myBlip = new Blip(myShooter);
            myBlip.Color = System.Drawing.Color.Red;
            myBlip.EnableRoute(System.Drawing.Color.Yellow);

            //Have the aggressor aim at the victim, and have the victim put their hands up. -1 makes the task permanent, or until we clear the task, which we do later.
            NativeFunction.CallByName<uint>("TASK_AIM_GUN_AT_ENTITY", myShooter, myVictim1, -1, true);
            NativeFunction.CallByName<uint>("TASK_AIM_GUN_AT_ENTITY", myCopPed1, myShooter, -1, true);
            NativeFunction.CallByName<uint>("TASK_AIM_GUN_AT_ENTITY", myCopPed2, myShooter, -1, true);
            myVictim1.Tasks.PutHandsUp(-1, myShooter);
            myVictim2.Tasks.PutHandsUp(-1, myShooter);
            myVictim3.Tasks.PutHandsUp(-1, myShooter);
            myVictim4.Tasks.PutHandsUp(-1, myShooter);
            myVictim5.Tasks.PutHandsUp(-1, myShooter);
            myVictim6.Tasks.PutHandsUp(-1, myShooter);

            //Block permanent events, so the victim doesn't flee if something disturbs them(A vehicle tapping them, etc..), as this would completely disrupt the callout's logic.
            myShooter.BlockPermanentEvents = true;
            myVictim1.BlockPermanentEvents = true;
            myVictim2.BlockPermanentEvents = true;
            myVictim3.BlockPermanentEvents = true;
            myVictim4.BlockPermanentEvents = true;
            myVictim5.BlockPermanentEvents = true;
            myVictim6.BlockPermanentEvents = true;
            myFireTruckPed1.BlockPermanentEvents = true;
            myFireTruckPed2.BlockPermanentEvents = true;
            myAmbulancePed1.BlockPermanentEvents = true;
            myAmbulancePed2.BlockPermanentEvents = true;

            Game.DisplayHelp("When you arrive, stay back with your officers and press " + Settings.TalkKey + " to talk to the suspect. After you are done talking, slowly approach the suspect - your officers will help defend you.", 15000);

            return base.OnCalloutAccepted();
        }

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

            Functions.PlayScannerAudio("AI_RESPONDING");

            if (myShooter.Exists())
            {
                myShooter.Delete();
            }
            if (myVictim1.Exists())
            {
                myVictim1.Delete();
            }
            if (myVictim2.Exists())
            {
                myVictim2.Delete();
            }
            if (myVictim3.Exists())
            {
                myVictim3.Delete();
            }
            if (myVictim4.Exists())
            {
                myVictim4.Delete();
            }
            if (myVictim5.Exists())
            {
                myVictim5.Delete();
            }
            if (myVictim6.Exists())
            {
                myVictim6.Delete();
            }
            if (myCopCar1.Exists())
            {
                myCopCar1.Delete();
            }
            if (myCopPed1.Exists())
            {
                myCopPed1.Delete();
            }
            if (myCopPed2.Exists())
            {
                myCopPed2.Delete();
            }
            if (myCopCar2.Exists())
            {
                myCopCar2.Delete();
            }
            if (myAmbulance.Exists())
            {
                myAmbulance.Delete();
            }
            if (myAmbulancePed1.Exists())
            {
                myAmbulancePed1.Delete();
            }
            if (myAmbulancePed2.Exists())
            {
                myAmbulancePed2.Delete();
            }
            if (myFireTruck.Exists())
            {
                myFireTruck.Delete();
            }
            if (myFireTruckPed1.Exists())
            {
                myFireTruckPed1.Delete();
            }
            if (myFireTruckPed2.Exists())
            {
                myFireTruckPed2.Delete();
            }

            if (myBlip.Exists()) myBlip.Delete();
        }
        public override void Process()
        {
            base.Process();

            if (CalloutState == CalloutStates.EnRoute && Game.LocalPlayer.Character.Position.DistanceTo(new Vector3(-1758.445f, 125.273f, 64.774f)) <= 60f)
            {
                if (Game.IsKeyDown(Settings.TalkKey))
                {
                    if (CurrentDialog.MoveNext())
                    {
                        Game.DisplaySubtitle(CurrentDialog.Current, 7500);
                    }
                    else
                    {

                    }
                }
            }

            Game.DisplayHelp("After speaking with the suspect, approach him slowly.");
                if (CalloutState == CalloutStates.EnRoute && Game.LocalPlayer.Character.Position.DistanceTo(new Vector3(-1758.445f, 125.273f, 64.774f)) <= 23f)
            {
                CalloutState = CalloutStates.OnScene;
                StartShootingScenario();
            }
            /*if (CalloutState !=CalloutStates.DecisionMade && !Functions.IsPursuitStillRunning(Pursuit))
            {
                this.End();
            }*/
            Game.HideHelp();
            if (myShooter.IsDead)
            {
                Game.DisplayNotification("~b~Officer " + Settings.OfficerName + "~w~: Suspect is down, Code 4.");
                Functions.PlayScannerAudio("CODE4 SUSP_DOWN");

                End();
            }
            if (myShooter.IsCuffed)
            {
                Game.DisplayNotification("~b~Officer~w~: Suspect in custody, Code 4.");
                Functions.PlayScannerAudio("CODE4 SUSP_ARRESTED");

                End();
            }
       }

        public override void End()
        {
            if (myShooter.Exists()) myShooter.Dismiss();

            if (myVictim1.Exists()) myVictim1.Dismiss();
            if (myVictim2.Exists()) myVictim2.Dismiss();
            if (myVictim3.Exists()) myVictim3.Dismiss();
            if (myVictim4.Exists()) myVictim4.Dismiss();
            if (myVictim5.Exists()) myVictim5.Dismiss();
            if (myVictim6.Exists()) myVictim6.Dismiss();
            if (myCopPed1.Exists()) myCopPed1.Dismiss();
            if (myCopPed2.Exists()) myCopPed2.Dismiss();
            if (myCopCar1.Exists()) myCopCar1.Dismiss();
            if (myCopCar2.Exists()) myCopCar2.Dismiss();
            if (myAmbulance.Exists()) myAmbulance.Dismiss();
            if (myAmbulancePed1.Exists()) myAmbulancePed1.Dismiss();
            if (myAmbulancePed2.Exists()) myAmbulancePed2.Dismiss();
            if (myFireTruck.Exists()) myFireTruck.Dismiss();
            if (myFireTruckPed1.Exists()) myFireTruckPed1.Dismiss();
            if (myFireTruckPed2.Exists()) myFireTruckPed2.Dismiss();

            if (myBlip.Exists()) myBlip.Delete();

            base.End();
        }

        public void StartShootingScenario()
        {
            //ALWAYS START A NEW GAME FIBER IF YOU'RE GOING TO USE GameFiber.Sleep, DON'T SLEEP THE MAIN FIBER.
            GameFiber.StartNew(delegate
            {
                //Create the Pursuit
                this.Pursuit = Functions.CreatePursuit();

                //Pick a random number, to choose a random outcome
                int r = new Random().Next(1, 4);

                //Set the state to decision made, since the outcome is chosen.
                CalloutState = CalloutStates.DecisionMade;

                //Execute one of the random outcomes
                if (r == 1)
                {
                    //The aggressor kills the victim before fleeing from the scene, and the victim flees the scene, trying to escape the aggressor.
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim1, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim2, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim3, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim4, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim5, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim6, myShooter);

                    GameFiber.Sleep(3000);

                    myShooter.Tasks.PutHandsUp(-1, Game.LocalPlayer.Character);
                    NativeFunction.CallByName<uint>("SET_PED_DROPS_WEAPON", myShooter);
                    Game.DisplaySubtitle("~b~Officer " + Settings.OfficerName + "~w~: Dispatch, suspect is surrendering.", 5000);

                    //Now for another random outcome
                    if (new Random().Next(1, 3) == 2)
                    {
                        //The aggressor attacks the player.
                        myShooter.Tasks.FireWeaponAt(myVictim1, 30000, FiringPattern.FullAutomatic);
                        myCopPed1.Tasks.FireWeaponAt(myShooter, 30000, FiringPattern.SingleShot);
                        myCopPed2.Tasks.FireWeaponAt(myShooter, 30000, FiringPattern.SingleShot);
                        Game.DisplaySubtitle("~b~Officer " + Settings.OfficerName + "~w~: SHOTS FIRED! GET SOME BACKUP HERE NOW!", 5000);
                        GameFiber.Sleep(3000);
                        Functions.PlayScannerAudio("NEED_BACKUP DISPATCH_SHOTS_FIRED REQUESTING_BACKUP");
                        NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim1, myShooter);
                        NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim2, myShooter);
                        NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim3, myShooter);
                        NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim4, myShooter);
                        NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim5, myShooter);
                        NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim6, myShooter);

                        GameFiber.Sleep(5000);

                        Functions.AddPedToPursuit(this.Pursuit, myShooter);
                    }
                }
                else
                {
                    //The aggressor doesn't attack the victim, instead, both peds flee. We don't need to tell the aggressor to flee, as LSPDFR's Pursuit system does that for us.
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim1, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim2, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim3, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim4, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim5, myShooter);
                    NativeFunction.CallByName<uint>("TASK_REACT_AND_FLEE_PED", myVictim6, myShooter);

                    GameFiber.Sleep(5000);

                    Functions.AddPedToPursuit(this.Pursuit, myShooter);
                }
                //Dismiss the aggressor from our plugin
                myShooter.Dismiss();

                //Dispatch a backup unit.
                if (myShooter.IsAlive)
                {
                    Functions.RequestBackup(Game.LocalPlayer.Character.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit);
                    Functions.RequestBackup(Game.LocalPlayer.Character.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.Ambulance);
                    Functions.RequestBackup(Game.LocalPlayer.Character.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit);
                    Functions.RequestBackup(Game.LocalPlayer.Character.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit);
                }
            });
        }
    }
}

 

 

Edited by ToastinYou
Link to comment
Share on other sites

Because Process() is a while loop and gets called constantly, by the time it has passed Game.DisplayHelp() it's already at Game.HideHelp.

Couple of other things, make your peds Persistent, AimWeaponAtis in TaskInvoker from Rage, unless you have a good reason to use the native.

Link to comment
Share on other sites

5 minutes ago, khorio said:

Because Process() is a while loop and gets called constantly, by the time it has passed Game.DisplayHelp() it's already at Game.HideHelp.

Couple of other things, make your peds Persistent, AimWeaponAtis in TaskInvoker from Rage, unless you have a good reason to use the native.

Thank you. I did forget to do a few things, one of which was setting paramedics and firefighters persistent, I believe. I'll switch from native to tasks of available, I just find some natives to be more customisable. And so I guess your saying I have a Hide Help in my process? I didn't see it but I'm on my phone right now, I'll look into this tomorrow. Thanks khorio the khallout man :)

Link to comment
Share on other sites

9 hours ago, khorio said:

Couple of other things, make your peds Persistent,

Pretty sure that when you create a Ped it's already persistent, I never used Ped.IsPersisten = true or Ped.MakePersistent() and they never dissapeared before calling Dismiss().

Toastin, also instead of the give weapon native you can use Ped.Inventory.GiveNewWeapon().

Edited by alexguirre
Link to comment
Share on other sites

1 minute ago, alexguirre said:

Pretty sure that when you create aPed it's already persistent, I never used Ped.IsPersisten = true or Ped.MakePersistent() and they never dissapeared before calling Dismiss().

Toastin, also instead of the give weapon native you can use Ped.Inventory.GiveNewWeapon().

Well, I was noticing that my Firemen and Paramedics were disappearing after I looked at the suspect, as they were behind me. Hopefully it's fixed now that I have used IsPersistent on them. I'll let you know.

I'll definitely change from Natives for that to Inv. Thank you!

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