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; } }