public virtual void OnEndEvent() { Logger.LogTrivial("Request Garbage mobile phone event"); this.IsEventRunning = false; if (this.Blip.IsValid() && this.Blip.Exists()) { this.Blip.Delete(); } if (false == FunctionsLSPDFR.IsPlayerPerformingPullover() && false == this.IsPerformedPullOver) { bool isPedNotInPursuit = false == PedsManager.isPedInPursuit(this.Driver); if (this.Driver.Exists() && isPedNotInPursuit) { this.Driver.Dismiss(); } if (this.Vehicle.Exists() && isPedNotInPursuit) { this.Vehicle.Dismiss(); } Logger.LogTrivial("Ending Garbage mobile phone event"); } OffencesManager.Instance.HandleEndEventOffence(this); }
protected bool IsPulledOverDriver() { if (FunctionsLSPDFR.IsPlayerPerformingPullover()) { Ped currentSuspect = FunctionsLSPDFR.GetPulloverSuspect(FunctionsLSPDFR.GetCurrentPullover()); return(currentSuspect == this.Driver); } return(false); }
public void OnSetCustomLocation() { CustomPulloverEventHandler.IsAlreadyFollowing = true; Logger.Log("Set Pullover"); try { if (false == FunctionsLSPDFR.IsPlayerPerformingPullover() || false == PedsManager.LocalPlayer().IsInAnyVehicle(false)) { Logger.Log("Cancelled"); CustomPulloverEventHandler.IsAlreadyFollowing = false; return; } Vehicle playerPatrolCar = PedsManager.LocalPlayer().CurrentVehicle; Vehicle pulledCar = (Vehicle)World.GetClosestEntity(playerPatrolCar.GetOffsetPosition(Vector3.RelativeFront * 8f), 8f, (GetEntitiesFlags.ConsiderGroundVehicles | GetEntitiesFlags.ConsiderBoats | GetEntitiesFlags.ExcludeEmptyVehicles | GetEntitiesFlags.ExcludeEmergencyVehicles)); if (null == pulledCar || (false == pulledCar.IsValid() || (pulledCar == playerPatrolCar))) { Logger.Log("No car or no valid car"); CustomPulloverEventHandler.IsAlreadyFollowing = false; return; } if (pulledCar.Speed > 0.2f) { Game.DisplayNotification("The vehicle must be stopped before you can do this."); CustomPulloverEventHandler.IsAlreadyFollowing = false; return; } Ped pulledDriver = pulledCar.Driver; pulledDriver.IsPersistent = true; if (!pulledDriver.IsPersistent || FunctionsLSPDFR.GetPulloverSuspect(FunctionsLSPDFR.GetCurrentPullover()) != pulledDriver) { Logger.Log("Not persistent"); CustomPulloverEventHandler.IsAlreadyFollowing = false; return; } CustomPulloverEvent customPulloverEvent = new CustomPulloverEvent(pulledCar, pulledDriver); this.OnEventHandler(customPulloverEvent); } catch (Exception e) { Game.LogTrivial("---------- EXCEPTION ---------"); Game.LogTrivial(e.Message); Game.LogTrivial("---------- END ---------"); } finally { CustomPulloverEventHandler.IsAlreadyFollowing = false; } }
public static void SetCustomPulloverLocation(CustomPulloverEvent customPulloverEvent) { Blip driverBlip = customPulloverEvent.PulledDriver.AttachBlip(); driverBlip.Flash(500, -1); driverBlip.Color = System.Drawing.Color.Yellow; if (Tools.HavingChance(2, 10)) { customPulloverEvent.PulledDriver.CanAttackFriendlies = true; } Vehicle playerPatrolCar = PedsManager.LocalPlayer().CurrentVehicle; int checkpoint = 0; try { Vector3 checkPointPosition = PedsManager.LocalPlayer().GetOffsetPosition(new Vector3(0f, 8f, -1f)); checkpoint = NativeFunction.Natives.CREATE_CHECKPOINT <int>(46, checkPointPosition.X, checkPointPosition.Y, checkPointPosition.Z, checkPointPosition.X, checkPointPosition.Y, checkPointPosition.Z, 3.5f, 255, 0, 0, 255, 0);; float xOffset = 0; float yOffset = 0; float zOffset = 0; bool SuccessfulSet = false; while (true) { GameFiber.Wait(70); Game.DisplaySubtitle("Set your desired ~o~pullover ~s~location. Hold ~b~Enter ~s~when done.", 100); checkPointPosition = PedsManager.LocalPlayer().GetOffsetPosition(new Vector3((float)xOffset + 0.5f, (float)(yOffset + 8), (float)(-1 + zOffset))); if (false == CustomPulloverEventHandler.IsAlreadyFollowing) { break; } if (false == FunctionsLSPDFR.IsPlayerPerformingPullover()) { Game.DisplayNotification("You cancelled the ~b~Traffic Stop."); break; } if (false == PedsManager.LocalPlayer().IsInVehicle(playerPatrolCar, false)) { break; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_RESET, "NumPad5"))) { xOffset = 0; yOffset = 0; zOffset = 0; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_FORWARD, "NumPad8"))) { yOffset++; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_BACK, "NumPad2"))) { yOffset--; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_RIGHT, "NumPad6"))) { xOffset++; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_LEFT, "NumPad4"))) { xOffset--; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_UP, "NumPad9"))) { zOffset++; } if (KeysManager.IsKeyDownRightNowComputerCheck(Configuration.Instance.ReadKey(CustomPulloverEventHandler.K_POS_DOWN, "NumPad3"))) { zOffset--; } if (KeysManager.IsKeyDownRightNowComputerCheck(System.Windows.Forms.Keys.Enter)) { SuccessfulSet = true; break; } NativeFunction.Natives.DELETE_CHECKPOINT(checkpoint); checkpoint = NativeFunction.Natives.CREATE_CHECKPOINT <int>(46, checkPointPosition.X, checkPointPosition.Y, checkPointPosition.Z, checkPointPosition.X, checkPointPosition.Y, checkPointPosition.Z, 3f, 255, 0, 0, 255, 0); NativeFunction.Natives.SET_CHECKPOINT_CYLINDER_HEIGHT(checkpoint, 2f, 2f, 2f); } NativeFunction.Natives.DELETE_CHECKPOINT(checkpoint); if (SuccessfulSet) { try { playerPatrolCar.BlipSiren(true); Game.LocalPlayer.Character.Tasks.PlayAnimation("friends@frj@ig_1", "wave_c", 1f, AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly); } catch { } while (true) { GameFiber.Yield(); if (Vector3.Distance(customPulloverEvent.PulledDriver.Position, PedsManager.LocalPlayer().Position) > 25f) { Game.DisplaySubtitle("~h~~r~Stay close to the vehicle.", 700); } if (false == FunctionsLSPDFR.IsPlayerPerformingPullover()) { Game.DisplayNotification("You cancelled the ~b~Traffic Stop."); break; } if (false == PedsManager.LocalPlayer().IsInVehicle(playerPatrolCar, false) || false == CustomPulloverEventHandler.IsAlreadyFollowing) { break; } Rage.Task drivetask = customPulloverEvent.PulledDriver.Tasks.DriveToPosition(checkPointPosition, 12f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); GameFiber.Wait(700); if (false == drivetask.IsActive || Vector3.Distance(customPulloverEvent.PulledDriver.Position, checkPointPosition) < 1.5f) //exit if driver end task or is away from the expected position { break; } } if (customPulloverEvent.pulledVehicle.Exists()) { if (customPulloverEvent.PulledDriver.Exists()) { customPulloverEvent.PulledDriver.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait); } } } } catch (Exception e) { NativeFunction.Natives.DELETE_CHECKPOINT(checkpoint); Game.LogTrivial("---------- EXCEPTION ---------"); Game.LogTrivial(e.Message); Game.LogTrivial("---------- END ---------"); } finally { if (driverBlip.IsValid() && driverBlip.Exists()) { driverBlip.Delete(); } CustomPulloverEventHandler.IsAlreadyFollowing = false; } }