public static void SetCustomPulloverLocation() { CustomPulloverHandler.IsSomeoneFollowing = true; GameFiber.StartNew(delegate { try { if (!Functions.IsPlayerPerformingPullover()) { CustomPulloverHandler.IsSomeoneFollowing = false; return; } if (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) { CustomPulloverHandler.IsSomeoneFollowing = false; return; } Vehicle playerCar = Game.LocalPlayer.Character.CurrentVehicle; Vehicle stoppedCar = (Vehicle)World.GetClosestEntity(playerCar.GetOffsetPosition(Vector3.RelativeFront * 8f), 8f, (GetEntitiesFlags.ConsiderGroundVehicles | GetEntitiesFlags.ConsiderBoats | GetEntitiesFlags.ExcludeEmptyVehicles | GetEntitiesFlags.ExcludeEmergencyVehicles)); if (stoppedCar == null) { Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're behind the vehicle and try again."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } if (!stoppedCar.IsValid() || (stoppedCar == playerCar)) { Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're behind the vehicle and try again."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } if (stoppedCar.Speed > 0.2f && !ExtensionMethods.IsPointOnWater(stoppedCar.Position)) { Game.DisplayNotification("The vehicle must be stopped before you can do this."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } string modelName = stoppedCar.Model.Name.ToLower(); if (numbers.Contains <string>(modelName.Last().ToString())) { modelName = modelName.Substring(0, modelName.Length - 1); } modelName = char.ToUpper(modelName[0]) + modelName.Substring(1); Ped pulledDriver = stoppedCar.Driver; if (!pulledDriver.IsPersistent || Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != pulledDriver) { Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're in front of the vehicle and try again."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } Blip blip = pulledDriver.AttachBlip(); blip.Flash(500, -1); blip.Color = System.Drawing.Color.Aqua; playerCar.BlipSiren(true); Vector3 CheckPointPosition = Game.LocalPlayer.Character.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 pullover location. Hold ~b~Enter ~s~when done.", 100); CheckPointPosition = Game.LocalPlayer.Character.GetOffsetPosition(new Vector3((float)xOffset + 0.5f, (float)(yOffset + 8), (float)(-1 + zOffset))); if (!CustomPulloverHandler.IsSomeoneFollowing) { break; } if (!Functions.IsPlayerPerformingPullover()) { Game.DisplayNotification("You cancelled the ~b~Traffic Stop."); break; } if (!Game.LocalPlayer.Character.IsInVehicle(playerCar, false)) { break; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionResetKey)) { xOffset = 0; yOffset = 0; zOffset = 0; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionForwardKey)) { yOffset++; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionBackwardKey)) { yOffset--; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionRightKey)) { xOffset++; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionLeftKey)) { xOffset--; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionUpKey)) { zOffset++; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(IniDefaults.PositionDownKey)) { zOffset--; } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(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 { Game.LocalPlayer.Character.Tasks.PlayAnimation("friends@frj@ig_1", "wave_c", 1f, AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly); } catch { } while (true) { GameFiber.Yield(); if (Vector3.Distance(pulledDriver.Position, Game.LocalPlayer.Character.Position) > 25f) { Game.DisplaySubtitle("~h~~r~Stay close to the vehicle.", 700); } if (!Functions.IsPlayerPerformingPullover()) { Game.DisplayNotification("You cancelled the ~b~Traffic Stop."); break; } if (!Game.LocalPlayer.Character.IsInVehicle(playerCar, false)) { break; } if (!CustomPulloverHandler.IsSomeoneFollowing) { break; } Rage.Task drivetask = pulledDriver.Tasks.DriveToPosition(CheckPointPosition, 12f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); GameFiber.Wait(700); if (!drivetask.IsActive) { break; } if (Vector3.Distance(pulledDriver.Position, CheckPointPosition) < 1.5f) { break; } } Game.LogTrivial("Done custom pullover location"); if (stoppedCar.Exists()) { if (pulledDriver.Exists()) { pulledDriver.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait); } } if (blip.Exists()) { blip.Delete(); } } } catch (Exception e) { NativeFunction.Natives.DELETE_CHECKPOINT(CheckPoint); if (blip.Exists()) { blip.Delete(); } Game.LogTrivial(e.ToString()); Game.LogTrivial("CustomPulloverLocationError handled."); } finally { CustomPulloverHandler.IsSomeoneFollowing = false; } }); }
public static void FollowMe() { CustomPulloverHandler.IsSomeoneFollowing = true; GameFiber.StartNew(delegate { try { if (!Functions.IsPlayerPerformingPullover()) { CustomPulloverHandler.IsSomeoneFollowing = false; return; } Game.LogTrivial("Following"); Ped playerPed = Game.LocalPlayer.Character; if (!playerPed.IsInAnyVehicle(false)) { CustomPulloverHandler.IsSomeoneFollowing = false; return; } Vehicle playerCar = playerPed.CurrentVehicle; Vehicle stoppedCar = (Vehicle)World.GetClosestEntity(playerCar.GetOffsetPosition(Vector3.RelativeBack * 10f), 10f, (GetEntitiesFlags.ConsiderGroundVehicles | GetEntitiesFlags.ConsiderBoats | GetEntitiesFlags.ExcludeEmptyVehicles | GetEntitiesFlags.ExcludeEmergencyVehicles)); if (stoppedCar == null) { Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're in front of the vehicle and try again."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } if (!stoppedCar.IsValid() || (stoppedCar == playerCar)) { Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're in front of the vehicle and try again."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } if (stoppedCar.Speed > 0.2f && !ExtensionMethods.IsPointOnWater(stoppedCar.Position)) { Game.DisplayNotification("The vehicle must be stopped before they can follow you."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } string modelName = stoppedCar.Model.Name.ToLower(); if (numbers.Contains <string>(modelName.Last().ToString())) { modelName = modelName.Substring(0, modelName.Length - 1); } modelName = char.ToUpper(modelName[0]) + modelName.Substring(1); Ped pulledDriver = stoppedCar.Driver; if (!pulledDriver.IsPersistent || Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != pulledDriver) { Game.DisplayNotification("Unable to detect the pulled over vehicle. Make sure you're in front of the vehicle and try again."); CustomPulloverHandler.IsSomeoneFollowing = false; return; } Blip blip = pulledDriver.AttachBlip(); blip.Flash(500, -1); blip.Color = System.Drawing.Color.Aqua; playerCar.BlipSiren(true); pulledDriver.Tasks.DriveToPosition(playerCar.GetOffsetPosition(Vector3.RelativeBack * 3f), 7f, VehicleDrivingFlags.FollowTraffic | VehicleDrivingFlags.YieldToCrossingPedestrians); Game.DisplayNotification("The blipped ~r~" + modelName + "~s~ is now following you."); Game.DisplayNotification("Press ~b~" + ExtensionMethods.GetKeyString(CustomPulloverHandler.TrafficStopFollowKey, CustomPulloverHandler.TrafficStopFollowModifierKey) + " ~s~to stop the ~r~" + modelName + "."); try { playerPed.Tasks.PlayAnimation("friends@frj@ig_1", "wave_c", 1f, AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly); } catch { } GameFiber.Sleep(100); float speed = 7f; while (true) { pulledDriver.Tasks.DriveToPosition(playerCar.GetOffsetPosition(Vector3.RelativeBack * 3f), speed, VehicleDrivingFlags.IgnorePathFinding); GameFiber.Sleep(60); if (!CustomPulloverHandler.IsSomeoneFollowing) { break; } if (!Functions.IsPlayerPerformingPullover()) { Game.DisplayNotification("You cancelled the ~b~Traffic Stop."); break; } if (!playerPed.IsInVehicle(playerCar, false)) { break; } speed = playerCar.Speed; if (Vector3.Distance(playerCar.Position, stoppedCar.Position) > 45f) { stoppedCar.Position = playerCar.GetOffsetPosition(Vector3.RelativeBack * 7f); stoppedCar.Heading = playerCar.Heading; blip.Delete(); blip = pulledDriver.AttachBlip(); blip.Flash(500, -1); blip.Color = System.Drawing.Color.Aqua; } else { if (speed > 17f) { speed = 17f; } else if (speed < 6.5f) { speed = 6.5f; } if (Vector3.Distance(playerCar.Position, stoppedCar.Position) > 21f) { speed = 17f; } } } Game.DisplayNotification("The ~r~" + modelName + "~s~ is no longer following you."); Game.LogTrivial("Done following"); if (blip.Exists()) { blip.Delete(); } } catch (Exception e) { if (blip.Exists()) { blip.Delete(); } Game.LogTrivial(e.ToString()); Game.LogTrivial("Error handled."); } finally { CustomPulloverHandler.IsSomeoneFollowing = false; } }); }
public static bool IsKeyCombinationDownRightNowComputerCheck(Keys MainKey, Keys ModifierKey) { if (MainKey != Keys.None) { return(ExtensionMethods.IsKeyDownRightNowComputerCheck(MainKey) && ((ExtensionMethods.IsKeyDownRightNowComputerCheck(ModifierKey) || (ModifierKey == Keys.None && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Shift) && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Control) && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LControlKey) && !ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LShiftKey))))); } else { return(false); } }