Jump to content

Variation in Callout


Fiskey111

Recommended Posts

Hi guys!  With the hype of LSPDFR 0.3 coming out, I'd like to ask for your help!  I'm trying to make my "restraining order callout" to be the best callout I've made!  I'm having some issues, I can't figure out why my callout won't pick the second option (state = ERestrainingState.R2) and only one ped (perp = tennis).  I'm confused as to why it won't pick my variations.  Thank you!

Any help?

Spoiler

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

            if (state == ERestrainingState.Accepted)
            {
                int r = new Random().Next(1, 2);
                if (r == 1)
                // Perp nearby
                {
                    int x = new Random().Next(1, 3);
                    {
                        if (x == 1)
                        {
                            perp = new Ped("a_f_y_tennis_01", spawnpoint3, 0f);
                            state2 = EQualities.tennis;
                        }
                        else if (x == 2)
                        {
                            perp = new Ped("g_m_y_ballaeast_01", spawnpoint3, 0f);
                            state2 = EQualities.ballas;
                        }
                        else if (x == 3)
                        {
                            perp = new Ped("a_m_m_paparazzi_01", spawnpoint3, 0f);
                            state2 = EQualities.paparazzi;
                        }
                    }
                                        
                    state = ERestrainingState.R3;
                    Game.LogTrivial("ERestrainingState Set Close");
                }
                else
                // Perp far away
                {
                    int y = new Random().Next(1, 3);
                    {
                        if (y == 1)
                        {
                            perp = new Ped("a_f_y_tennis_01", spawnpoint2, 0f);
                            state2 = EQualities.tennis;
                        }
                        else if (y == 2)
                        {
                            perp = new Ped("g_m_y_ballaeast_01", spawnpoint2, 0f);
                            state2 = EQualities.ballas;
                        }
                        else if (y == 3)
                        {
                            perp = new Ped("a_m_m_paparazzi_01", spawnpoint2, 0f);
                            state2 = EQualities.paparazzi;
                        }
                    }

                    state = ERestrainingState.R2;
                    Game.LogTrivial("ERestrainingState Set Far");
                }
            }

            //Set state
            if (state == ERestrainingState.R2 && Game.LocalPlayer.Character.Position.DistanceTo(spawnpoint) <= 4)
            {
                state = ERestrainingState.OnScene;

                GameFiber.StartNew(delegate
                {
                state = ERestrainingState.R21;
                NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);

                VictimBlip.DisableRoute();
                if (VictimBlip.Exists()) VictimBlip.Delete();

                Game.DisplaySubtitle("~y~Victim~w~: Help! I have a restraining order against this person and I just saw him!", 5000);
                GameFiber.Sleep(5100);
                Game.DisplaySubtitle("~y~Victim~w~: I don't know where he went but he must be nearby!  I told 911 what he looked like!", 5000);
                GameFiber.Sleep(5100);
                Game.DisplaySubtitle("~y~Victim~w~: Please arrest him if you find him!  I want him in jail!", 4000);
                GameFiber.Sleep(4100);

                if (state2 == EQualities.ballas)
                {
                    Game.DisplayNotification("Press " + Settings.EndKey + " to end the callout when finished!");
                    Game.DisplayNotification("Use your discretion- arrest the ~r~suspect~w~, question him, or let him go.");

                    Functions.PlayScannerAudio("DISPATCH_INTRO CITIZENS_REPORT BUILD_AVERAGE SEX_MALE_BLACK HAIR_BROWN TORSO_PURPLE TORSO_SHORTSLEEVE PANTS_DARK SHOES_BROWN REMAIN_IN_AREA OUTRO");

                    if (state == ERestrainingState.R21 && Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 20)
                    {
                        int z = new Random().Next(1, 4);
                        if (z == 1)
                        {
                            Game.LogTrivial("Pursuit");
                            Functions.AddPedToPursuit(pursuit, perp);
                        }
                        else if (z == 2)
                        {
                            Game.LogTrivial("Conversation");
                            if (Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 10)
                            {
                                Rage.Native.NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", perp, Game.LocalPlayer.Character);

                                Game.DisplaySubtitle("~r~Suspect~w~: Oh, did that idiot send you after me?!", 5000);
                                GameFiber.Sleep(5100);
                                Game.DisplaySubtitle("~r~Suspect~w~: I swear I haven't done nothin' wrong!", 5000);
                                GameFiber.Sleep(5100);
                                int u = new Random().Next(1, 3);
                                if (u == 1)
                                {
                                    Game.DisplaySubtitle("~r~Suspect~w~: I just stopped off to try to make things up to her! Is that a crime?!", 5000);
                                    GameFiber.Sleep(5100);
                                }
                                else
                                {
                                    Game.DisplaySubtitle("~r~Suspect~w~: Please don't arrest me officer.  I'm not the crazy one!", 5000);
                                    GameFiber.Sleep(5100);

                                }
                            }
                        }
                        else
                        {
                            Game.LogTrivial("Wander");
                            NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);
                        }
                    }
                }
                else if (state2 == EQualities.paparazzi)
                {
                    Game.DisplayNotification("Press " + Settings.EndKey + " to end the callout when finished!");

                    Functions.PlayScannerAudio("DISPATCH_INTRO CITIZENS_REPORT BUILD_AVERAGE SEX_MALE_WHITE HAIR_BLONDE TORSO_DARK_SHIRT PANTS_DARK SHOES_LIGHT REMAIN_IN_AREA OUTRO");

                    Game.DisplayNotification("Use your discretion- arrest the ~r~suspect~w~, question him, or let him go.");

                    if (state == ERestrainingState.R21 && Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 20)
                    {
                        int q = new Random().Next(1, 4);
                        if (q == 1)
                        {
                            Game.LogTrivial("Pursuit");
                            Functions.AddPedToPursuit(pursuit, perp);
                        }
                        else if (q == 2)
                        {
                            Game.LogTrivial("Conversation");
                            if (Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 10)
                            {
                                Rage.Native.NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", perp, Game.LocalPlayer.Character);

                                Game.DisplaySubtitle("~r~Suspect~w~: Oh, were you sent after me again?!", 5000);
                                GameFiber.Sleep(5100);
                                Game.DisplaySubtitle("~r~Suspect~w~: I promise I've been minding my business!", 5000);
                                GameFiber.Sleep(5100);

                                int y = new Random().Next(1, 3);
                                if (y == 1)
                                {
                                    Game.DisplaySubtitle("~r~Suspect~w~: I just stopped off to try to make things up to her! Is that a crime?!", 5000);
                                    GameFiber.Sleep(5100);
                                }
                                else
                                {
                                    Game.DisplaySubtitle("~r~Suspect~w~: Please don't arrest me officer.  I'm not the crazy one!", 5000);
                                    GameFiber.Sleep(5100);
                                }
                            }
                        }
                        else
                        {
                            Game.LogTrivial("Wander");
                            NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);
                        }
                    }
                }
                else if (state2 == EQualities.tennis)
                {
                    Game.DisplayNotification("Press " + Settings.EndKey + " to end the callout when finished!");

                    Functions.PlayScannerAudio("DISPATCH_INTRO CITIZENS_REPORT BUILD_ATHLETIC SEX_FEMALE_WHITE HAIR_BROWN TORSO_PINK TORSO_JACKET PANTS_SHORTS SHOES_LIGHT ON_FOOT REMAIN_IN_AREA OUTRO");

                    if (state == ERestrainingState.R21 && Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 20)
                    {
                        int w = new Random().Next(1, 4);
                        if (w == 1)
                        {
                                Game.LogTrivial("Pursuit");
                                Functions.AddPedToPursuit(pursuit, perp);
                        }
                        else if (w == 2)
                        {
                                Game.LogTrivial("Conversation");
                                if (Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 10)
                            {

                                    Rage.Native.NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", perp, Game.LocalPlayer.Character);

                                Game.DisplaySubtitle("~r~Suspect~w~: Oh, were you sent after me again?!", 5000);
                                GameFiber.Sleep(5100);
                                Game.DisplaySubtitle("~r~Suspect~w~: I promise I've been minding my business!", 5000);
                                GameFiber.Sleep(5100);

                                int u = new Random().Next(1, 3);
                                if (u == 1)
                                {
                                    Game.DisplaySubtitle("~r~Suspect~w~: I just stopped off to try to make things up to her! Is that a crime?!", 5000);
                                    GameFiber.Sleep(5100);
                                }
                                else
                                {
                                    Game.DisplaySubtitle("~r~Suspect~w~: Please don't arrest me officer.  I'm not the crazy one!", 5000);
                                    GameFiber.Sleep(5100);
                                }
                            }
                        }
                        else
                        {
                                Game.LogTrivial("Wander");
                                NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);
                        }
                    }
                }
            });
            }
            if (state == ERestrainingState.R3 && Game.LocalPlayer.Character.Position.DistanceTo(spawnpoint) <= 4)
            {
                state = ERestrainingState.OnScene;

                GameFiber.StartNew(delegate
                {
                    state = ERestrainingState.R31;
                    NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);

                    VictimBlip.DisableRoute();
                    if (VictimBlip.Exists()) VictimBlip.Delete();

                    Game.DisplaySubtitle("~y~Victim~w~: Help! I have a restraining order against this person and I just saw him!", 5000);
                    GameFiber.Sleep(5100);
                    Game.DisplaySubtitle("~y~Victim~w~: I don't know where he went but he must be nearby!  I told 911 what he looked like!", 5000);
                    GameFiber.Sleep(5100);
                    Game.DisplaySubtitle("~y~Victim~w~: Please arrest him if you find him!  I want him in jail!", 4000);
                    GameFiber.Sleep(4100);

                    if (state2 == EQualities.ballas)
                    {
                        Game.DisplayNotification("Press " + Settings.EndKey + " to end the callout when finished!");

                        Functions.PlayScannerAudio("DISPATCH_INTRO CITIZENS_REPORT BUILD_AVERAGE SEX_MALE_BLACK HAIR_BROWN TORSO_PURPLE TORSO_SHORTSLEEVE PANTS_DARK SHOES_BROWN REMAIN_IN_AREA OUTRO");

                        if (state == ERestrainingState.R31 && Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 10)
                        {
                            int e = new Random().Next(1, 4);
                            if (e == 1)
                            {
                                Game.LogTrivial("Pursuit");
                                Functions.AddPedToPursuit(pursuit, perp);
                            }
                            else if (e == 2)
                            {
                                Game.LogTrivial("Conversation");
                                if (Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 5)
                                {
                                    Rage.Native.NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", perp, Game.LocalPlayer.Character);

                                    Game.DisplaySubtitle("~r~Suspect~w~: Oh, were you sent after me again?!", 5000);
                                    GameFiber.Sleep(5100);
                                    Game.DisplaySubtitle("~r~Suspect~w~: I promise I've been minding my business!", 5000);
                                    GameFiber.Sleep(5100);

                                    int i = new Random().Next(1, 3);
                                    if (i == 1)
                                    {
                                        Game.DisplaySubtitle("~r~Suspect~w~: I just stopped off to try to make things up to her! Is that a crime?!", 5000);
                                        GameFiber.Sleep(5100);
                                    }
                                    else
                                    {
                                        Game.DisplaySubtitle("~r~Suspect~w~: Please don't arrest me officer.  I'm not the crazy one!", 5000);
                                        GameFiber.Sleep(5100);
                                    }
                                }
                            }
                            else
                            {
                                Game.LogTrivial("Wander");
                                NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);
                            }
                        }
                    }
                    else if (state2 == EQualities.paparazzi)
                    {
                        Game.DisplayNotification("Press " + Settings.EndKey + " to end the callout when finished!");

                        Functions.PlayScannerAudio("DISPATCH_INTRO CITIZENS_REPORT BUILD_AVERAGE SEX_MALE_WHITE HAIR_BLONDE TORSO_DARK_SHIRT PANTS_DARK SHOES_LIGHT REMAIN_IN_AREA OUTRO");

                        if (state == ERestrainingState.R31 && Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 10)
                        {
                            int r = new Random().Next(1, 4);
                            if (r == 1)
                            {
                                Game.LogTrivial("Pursuit");
                                Functions.AddPedToPursuit(pursuit, perp);
                            }
                            else if (r == 2)
                            {
                                Game.LogTrivial("Conversation");
                                if (Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 5)
                                {
                                    Rage.Native.NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", perp, Game.LocalPlayer.Character);

                                    Game.DisplaySubtitle("~r~Suspect~w~: Oh, were you sent after me again?!", 5000);
                                    GameFiber.Sleep(5100);
                                    Game.DisplaySubtitle("~r~Suspect~w~: I promise I've been minding my business!", 5000);
                                    GameFiber.Sleep(5100);

                                    int o = new Random().Next(1, 3);
                                    if (o == 1)
                                    {
                                        Game.DisplaySubtitle("~r~Suspect~w~: I just stopped off to try to make things up to her! Is that a crime?!", 5000);
                                        GameFiber.Sleep(5100);
                                    }
                                    else
                                    {
                                        Game.DisplaySubtitle("~r~Suspect~w~: Please don't arrest me officer.  I'm not the crazy one!", 5000);
                                        GameFiber.Sleep(5100);
                                    }
                                }
                            }
                            else
                            {
                                Game.LogTrivial("Wander");
                                NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);
                            }
                        }
                    }
                    else if (state2 == EQualities.tennis)
                    {
                        Game.DisplayNotification("Press " + Settings.EndKey + " to end the callout when finished!");

                        Functions.PlayScannerAudio("DISPATCH_INTRO CITIZENS_REPORT BUILD_ATHLETIC SEX_FEMALE_WHITE HAIR_BROWN TORSO_PINK TORSO_JACKET PANTS_SHORTS SHOES_LIGHT ON_FOOT REMAIN_IN_AREA OUTRO");

                        if (state == ERestrainingState.R31 && Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 10)
                        {
                            int t = new Random().Next(1, 4);
                            if (t == 1)
                            {
                                Game.LogTrivial("Pursuit");
                                Functions.AddPedToPursuit(pursuit, perp);
                            }
                            else if (t == 2)
                            {
                                Game.LogTrivial("Conversation");
                                if (Game.LocalPlayer.Character.Position.DistanceTo(perp) <= 5)
                                {
                                    Rage.Native.NativeFunction.CallByName<uint>("TASK_TURN_PED_TO_FACE_ENTITY", perp, Game.LocalPlayer.Character);

                                    Game.DisplaySubtitle("~r~Suspect~w~: Oh, were you sent after me again?!", 5000);
                                    GameFiber.Sleep(5100);
                                    Game.DisplaySubtitle("~r~Suspect~w~: I promise I've been minding my business!", 5000);
                                    GameFiber.Sleep(5100);

                                    int p = new Random().Next(1, 3);
                                    if (p == 1)
                                    {
                                        Game.DisplaySubtitle("~r~Suspect~w~: I just stopped off to try to make things up to her! Is that a crime?!", 5000);
                                        GameFiber.Sleep(5100);
                                    }
                                    else
                                    {
                                        Game.DisplaySubtitle("~r~Suspect~w~: Please don't arrest me officer.  I'm not the crazy one!", 5000);
                                        GameFiber.Sleep(5100);
                                    }
                                }
                            }
                            else
                            {
                                Game.LogTrivial("Wander");
                                NativeFunction.CallByName<uint>("TASK_WANDER_STANDARD", perp, 0, 0);
                            }
                        }
                    }
                });
            }
            if (Game.IsKeyDown(Settings.EndKey) && state == ERestrainingState.OnScene)
            {
                Game.DisplayNotification("Forced End Successful");
                this.End();
            }
        }

        public override void End()
        {
            base.End();
            if (victim.Exists()) victim.Dismiss();
            if (perp.Exists()) perp.Dismiss();
        }

        public enum ERestrainingState
        {
            Accepted,
            R3,
            R31,
            R2,
            R21,
            OnScene,
            DecisionMade
        }
        public enum EQualities
        {
            tennis,
            ballas,
            paparazzi
        }

 

 

 

Link to comment
Share on other sites

int r = new Random().Next(1, 2);  will always return 1. What this does is pick a random number that's 1 or higher, but lower than 2 (aka 1 only).

Also, for good practice, create one single random instance that you call throughout your entire code. If you don't, you'll keep getting the same numbers:

Random rnd = new Random();

int r = rnd.Next(1,3); //returns either 1 or 2
int r = rnd.Next(2); //returns 0 or 1

 

Edited by Albo1125

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

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