private void PlayerSearching()
        {
            if (LastKnownBlip.Exists() && LPlayer.LocalPlayer.Ped.Position.DistanceTo(LastKnownBlip.Position) < 50f)
            {
                //LastKnownBlip.Display = BlipDisplay.Hidden;
                LastKnownBlip.Delete();
            }
            //Has the player spotted the suspect (in front is set to false meaning position can be anywhere)
            if (LPlayer.LocalPlayer.Ped.HasSpottedPed(suspect, false))
            {
                pursuit = Functions.CreatePursuit();
                suspect.AttachBlip().Color = BlipColor.Red;
                Functions.AddTextToTextwall("Control I've located the suspect, in pursuit.", "Officer " + LPlayer.LocalPlayer.Username);
                Functions.AddPedToPursuit(pursuit, suspect);
                Functions.SetPursuitCalledIn(pursuit, true);

                Functions.SetPursuitCopsCanJoin(pursuit, true);
                Functions.SetPursuitIsActiveForPlayer(pursuit, true);
                State = EPedState.None;
            }

            if (LPlayer.LocalPlayer.Ped.Position.DistanceTo(getawayCar.Position) > 600f)
            {
                Functions.AddTextToTextwall("Control, suspect was never found, resuming patrol.", "Officer " + LPlayer.LocalPlayer.Username);
                Functions.AddTextToTextwall("Affirmative, we'll send details to ANPR database.", "CONTROL");
                End();
            }
        }
        private void PlayerOnScene()
        {
            if (LPlayer.LocalPlayer.Ped.Position.DistanceTo(officer.Position) <= 3f)
            {
                if (Functions.IsKeyDown(System.Windows.Forms.Keys.E))
                {
                    LPlayer.LocalPlayer.Ped.Task.TurnTo(officer);
                    DelayedCaller.Call(delegate
                    {
                        LPlayer.LocalPlayer.Ped.Animation.Play(new AnimationSet("medic"), "medic_cpr_in", 4.0f);
                        DelayedCaller.Call(delegate
                        {
                            LPlayer.LocalPlayer.Ped.Animation.Play(new AnimationSet("medic"), "medic_cpr_loop", 4.0f);
                            DelayedCaller.Call(delegate
                            {
                                LPlayer.LocalPlayer.Ped.Animation.Play(new AnimationSet("medic"), "medic_cpr_out", 4.0f);
                                Functions.PrintHelp("The officer is injured but stable and will be dealt with soon, locate the suspect.");
                                Vector3 LastKnown = new Vector3();
                                if (getawayCar.Exists())
                                {
                                    LastKnown = getawayCar.Position;
                                }
                                else
                                {
                                    End();
                                }
                                Functions.PrintText("The suspect is in a " + getawayCar.Color + " " + getawayCar.Name + ". A blip has been placed at their last known location.", 4000);
                                if (officer.Exists())
                                {
                                    officer.NoLongerNeeded();
                                }
                                if (copCar.Exists())
                                {
                                    copCar.NoLongerNeeded();
                                }
                                if (blip.Exists())
                                {
                                    blip.Delete();
                                }

                                LastKnownBlip = Functions.CreateBlipForArea(LastKnown, 40f);
                                if (LastKnownBlip.Exists())
                                {
                                    LastKnownBlip.Display     = BlipDisplay.ArrowAndMap;
                                    LastKnownBlip.RouteActive = true;
                                }
                                State = EPedState.PlayerSearching;
                            }, this, 6000);
                        }, this, 2000);
                    }, this, 2000);
                }
            }
        }
 public override void End()
 {
     base.End();
     if (pursuit != null)
     {
         Functions.ForceEndPursuit(pursuit);
     }
     if (copCar != null && copCar.Exists())
     {
         copCar.Delete();
     }
     if (getawayCar != null && getawayCar.Exists())
     {
         getawayCar.NoLongerNeeded();
     }
     if (blip != null && blip.Exists())
     {
         blip.Delete();
     }
     if (LastKnownBlip != null && LastKnownBlip.Exists())
     {
         LastKnownBlip.Delete();
     }
 }