public static void Main() { // Create a fiber to process our menus MenusProcessFiber = new GameFiber(ProcessLoop); // Create the MenuPool to easily process our menus _menuPool = new MenuPool(); // Create our main menu mainMenu = new UIMenu("RAGENative UI", "~b~RAGENATIVEUI SHOWCASE"); // Add our main menu to the MenuPool _menuPool.Add(mainMenu); // create our items and add them to our main menu mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?")); var foods = new List<dynamic> { "Banana", "Apple", "Pizza", "Quartilicious", 0xF00D, // Dynamic! }; mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0)); mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.")); var menuItem = new UIMenuItem("Go to another menu."); mainMenu.AddItem(menuItem); cookItem.SetLeftBadge(UIMenuItem.BadgeStyle.Star); cookItem.SetRightBadge(UIMenuItem.BadgeStyle.Tick); var carsModel = new List<dynamic> { "Adder", "Bullet", "Police", "Police2", "Asea", "FBI", "FBI2", "Firetruk", "Ambulance", "Rhino", }; carsList = new UIMenuListItem("Cars Models", carsModel, 0); mainMenu.AddItem(carsList); spawnCar = new UIMenuItem("Spawn Car"); mainMenu.AddItem(spawnCar); coloredItem = new UIMenuColoredItem("Color!", System.Drawing.Color.Red, System.Drawing.Color.Blue); mainMenu.AddItem(coloredItem); mainMenu.RefreshIndex(); mainMenu.OnItemSelect += OnItemSelect; mainMenu.OnListChange += OnListChange; mainMenu.OnCheckboxChange += OnCheckboxChange; mainMenu.OnIndexChange += OnItemChange; // Create another menu newMenu = new UIMenu("RAGENative UI", "~b~RAGENATIVEUI SHOWCASE"); newMenu.CounterOverride = "Counter Override"; _menuPool.Add(newMenu); // add it to the menu pool for (int i = 0; i < 35; i++) // add items { newMenu.AddItem(new UIMenuItem("PageFiller " + i.ToString(), "Sample description that takes more than one line. More so, it takes way more than two lines since it's so long. Wow, check out this length!")); } newMenu.RefreshIndex(); mainMenu.BindMenuToItem(newMenu, menuItem); // and bind it to an item in our main menu // Start our process fiber MenusProcessFiber.Start(); // Continue with our plugin... in this example, hibernate to prevent it from being unloaded GameFiber.Hibernate(); }
public static void RoadSignsMainLogic() { GameFiber.StartNew(delegate { createRoadSignsMenu(); try { while (true) { GameFiber.Yield(); if (PlaceSignMenu.Visible && EnablePreviewItem.Checked) { if (TrafficSignPreview.Exists()) { if (TrafficSignPreview.DistanceTo2D(DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))) > 0.4f) { TrafficSignPreview.Position = DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString())); TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f); } TrafficSignPreview.Rotation = RotationToPlaceAt; if (barriersList.Collection[barriersList.Index].Value.ToString() == "Stripes Left") { //TrafficSignPreview.Heading = Game.LocalPlayer.Character.Heading + 180f; TrafficSignPreview.Heading += 180f; } TrafficSignPreview.Heading += float.Parse(HeadingItem.Collection[HeadingItem.Index].Value.ToString()); int waitCount = 0; while (TrafficSignPreview.HeightAboveGround > 0.01f) { GameFiber.Yield(); TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z - (TrafficSignPreview.HeightAboveGround * 0.75f)); //Game.LogTrivial("Heighaboveground: " + TrafficSignPreview.HeightAboveGround); waitCount++; if (waitCount >= 1000) { break; } } TrafficSignPreview.IsPositionFrozen = true; TrafficSignPreview.Opacity = 0.7f; TrafficSignPreview.NeedsCollision = false; NativeFunction.Natives.SET_ENTITY_COLLISION(TrafficSignPreview, false, false); } if (SignTypeToPlace == SignTypes.Barrier && !TrafficSignPreview.Exists()) { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } TrafficSignPreview = new Rage.Object(barriersToChooseFrom[barriersList.Index], DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))); TrafficSignPreview.Rotation = RotationToPlaceAt; TrafficSignPreview.NeedsCollision = false; } else if (SignTypeToPlace == SignTypes.Cone && !TrafficSignPreview.Exists()) { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } TrafficSignPreview = new Rage.Object(conesToChooseFrom[conesList.Index], DetermineSignSpawn(SpawnDirectionListItem.Collection[SpawnDirectionListItem.Index].Value.ToString(), float.Parse(SpawnMultiplierListItem.Collection[SpawnMultiplierListItem.Index].Value.ToString()))); TrafficSignPreview.Rotation = RotationToPlaceAt; TrafficSignPreview.NeedsCollision = false; } } else { if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } } if (!PlaceSignMenu.Visible) { if (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) { if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(placeSignShortcutKey, placeSignShortcutModifierKey)) { RotationToPlaceAt = Game.LocalPlayer.Character.Rotation; dropSign(SignTypeToPlace == SignTypes.Barrier ? barriersToChooseFrom[barriersList.Index] : conesToChooseFrom[conesList.Index], false, Game.LocalPlayer.Character.GetOffsetPositionFront(2), 0); Game.LogTrivial("Shortcut Sign dropped"); Rage.Native.NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0); } else if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyCombinationDownComputerCheck(removeAllSignsKey, removeAllSignsModifierKey)) { removeAllSigns(); } } } } } catch { removeAllSigns(); if (TrafficSignPreview.Exists()) { TrafficSignPreview.Delete(); } } }); }
private static void MainLogic() { GameFiber.StartNew(delegate { while (true) { GameFiber.Yield(); if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LControlKey) && ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LShiftKey) && ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Z)) { handleEditMode(); } else if (CurrentButtonPages.Count > 0) { if ((Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(ToggleRadioKey) && (ToggleRadioModifierKey == Keys.None || Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownRightNowComputerCheck(ToggleRadioModifierKey))) || (Game.IsControllerButtonDown(ToggleRadioButton) && (Game.IsControllerButtonDownRightNow(ToggleRadioModifierButton) || ToggleRadioModifierButton == ControllerButtons.None))) { CurrentButtonIndex = 0; if (!RadioShowing) { cascadeCurrentButtonPages(); } if (ResetRadioWhenOpening) { CurrentPageIndex = 0; } RadioShowing = !RadioShowing; } if (RadioShowing) { if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(NextButtonKey) || Game.IsControllerButtonDown(NextButtonButton)) { MoveButtonIndex(true); } else if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(PreviousButtonKey) || Game.IsControllerButtonDown(PreviousButtonButton)) { MoveButtonIndex(false); } else if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(SelectButtonKey) || Game.IsControllerButtonDown(SelectButtonButton)) { RadioShowing = false; if (CurrentPage.Buttons.Count > CurrentButtonIndex) { if (CurrentPage.Buttons[CurrentButtonIndex].IsAvailable) { handleButtonPress(CurrentPage.Buttons[CurrentButtonIndex]); } else { Game.LogTrivial("This PoliceSmartRadio button was set as currently not available."); } } else { Game.LogTrivial("Current button out of range on select (blank page)?"); Game.DisplayNotification("You'll need to add buttons to your SmartRadio first."); } } else if (ExtensionMethods.IsKeyDownComputerCheck(NextPageKey) || Game.IsControllerButtonDown(NextPageButton)) { goToNextPage(true); } else if (ExtensionMethods.IsKeyDownComputerCheck(PreviousPageKey) || Game.IsControllerButtonDown(PreviousPageButton)) { goToPreviousPage(true); CurrentButtonIndex = 0; } } else { if (Game.LocalPlayer.Character.IsInAnyVehicle(false) && OnFootPagesActive) { CurrentButtonPages = InVehicleButtonPages; cascadeCurrentButtonPages(); CurrentPage = CurrentButtonPages[0]; CurrentPageIndex = 0; CurrentButtonIndex = 0; OnFootPagesActive = false; } else if (!Game.LocalPlayer.Character.IsInAnyVehicle(false) && !OnFootPagesActive) { CurrentButtonPages = OnFootButtonPages; cascadeCurrentButtonPages(); CurrentPage = CurrentButtonPages[0]; CurrentPageIndex = 0; CurrentButtonIndex = 0; OnFootPagesActive = true; } } } } }); }
//public static void CheckForUpdate() //{ // if(!Settings.AllowUpdatesCheck) return; // GameFiber.StartNew(delegate // { // //Stopwatch sw = Stopwatch.StartNew(); // try // { // while (Game.IsLoading) // GameFiber.Yield(); // Version fileVersion = CalloutHelper.GetVersion(@"Plugins\LSPDFR\Wilderness Callouts.dll"); // Version publicVersion = new Version(CalloutHelper.DownloadText("http://www.lcpdfr.com/applications/downloadsng/interface/api.php?do=checkForUpdates&fileId=8108&textOnly=1")); // int comparition = fileVersion.CompareTo(publicVersion); // if (comparition == 0 || comparition > 0) // { // Logger.LogTrivial("Current version is up to date"); // } // else if (comparition < 0) // { // Logger.LogTrivial("Current version is outdated"); // Logger.LogTrivial("Current version is v" + fileVersion + ", newest version is v" + publicVersion); // if (Settings.AllowUpdateRedirect) // { // Logger.LogTrivial("Redirect allowed..."); // Game.DisplayHelp("~g~Wilderness Callouts~s~ is ~r~outdated~s~. You will be redirected to the download page in 5 seconds", 5000); // GameFiber.Sleep(5000); // Process.Start("http://www.lcpdfr.com/files/file/8108-wilderness-callouts/"); // } // else // { // Game.DisplayHelp("~g~Wilderness Callouts~s~ is ~r~outdated~s~. Check the download page for the latest version", 5000); // Logger.LogTrivial("Redirect not allowed. Check http://www.lcpdfr.com/files/file/8108-wilderness-callouts/ for the update"); // } // } // } // catch (Exception ex) // { // Logger.LogTrivial("Exception handled while checking for updates"); // Logger.LogException(ex); // } // //sw.Stop(); // //Logger.LogTrivial("Ms: " + sw.ElapsedMilliseconds); // //Logger.LogTrivial("Ticks: " + sw.ElapsedTicks); // //Logger.LogTrivial("Time: " + sw.Elapsed); // }, "Update Checker Fiber"); //} /// <summary> /// Checks whether the person has the specified minimum version or higher. /// </summary> /// <param name="minimumVersion">Provide in the format of a float i.e.: 0.22</param> /// <returns></returns> public static bool CheckRPHVersion(float minimumVersion) { bool correctVersion; var versionInfo = FileVersionInfo.GetVersionInfo("RAGEPluginHook.exe"); float Rageversion; try { //If you decide to use this in your plugin, I would appreciate some credit :) Rageversion = Single.Parse(versionInfo.ProductVersion.Substring(0, 4), CultureInfo.InvariantCulture); Logger.LogTrivial("Detected RAGEPluginHook version: " + Rageversion); //If user's RPH version is older than the minimum if (Rageversion < minimumVersion) { correctVersion = false; GameFiber.StartNew(delegate { while (Game.IsLoading) { GameFiber.Yield(); } //If you decide to use this in your plugin, I would appreciate some credit :) Game.DisplayNotification("RPH ~r~v" + Rageversion + " ~s~detected. ~b~Version ~s~required is ~b~v" + minimumVersion + " ~s~or higher."); GameFiber.Sleep(5000); Logger.LogTrivial("RAGEPluginHook version " + Rageversion + " detected. Version required is v" + minimumVersion + " or higher."); Logger.LogTrivial("Preparing redirect..."); Game.DisplayNotification("You are being redirected to the RagePluginHook website so you can download the latest version."); Game.DisplayNotification("Press Backspace to cancel the redirect."); int count = 0; while (true) { GameFiber.Sleep(5); count++; if (Game.IsKeyDownRightNow(System.Windows.Forms.Keys.Back)) { Game.DisplayNotification("Redirect cancelled"); break; } if (count >= 575) { //URL to the RPH download page. System.Diagnostics.Process.Start("https://ragepluginhook.net/Downloads.aspx"); break; } } }); } //If user's RPH version is (above) the specified minimum else { correctVersion = true; } } catch (Exception e) { //If for whatever reason the version couldn't be found. Logger.LogTrivial(e.ToString()); Logger.LogTrivial("Unable to detect your Rage installation."); if (File.Exists("RAGEPluginHook.exe")) { Logger.LogTrivial("RAGEPluginHook.exe exists"); } else { Game.LogTrivial("RAGEPluginHook doesn't exist."); } Logger.LogTrivial("Rage Version: " + versionInfo.ProductVersion.ToString()); Game.DisplayNotification("Wilderness Callouts by alexguirre unable to detect RPH installation. Please send me your logfile."); correctVersion = false; } return(correctVersion); }
public override void Process(MurderInvestigation owner) { if (state == Var1State.EnRoute) { if (Game.LocalPlayer.Character.IsInRangeOf2D(victimPed, 12.5f)) { state = Var1State.CrimeSceneReached; return; } } else if (state == Var1State.CrimeSceneReached) { Game.DisplayNotification("~b~" + Settings.General.Name + ": ~w~Dispatch, I'm on scene, ~g~victim is dead"); GameFiber.Wait(1250); Game.DisplayNotification("~b~Dispatch: ~w~Roger, investigate the scene"); state = Var1State.SearchingEvidences; owner.IsPlayerOnScene = true; return; } else if (state == Var1State.SearchingEvidences) { // if (owner.InvestigationModeRaycastResult.Hit) // { // if (owner.InvestigationModeRaycastResult.HitEntity != null) // { // if (owner.InvestigationModeRaycastResult.HitEntity == cctvObject) // { // Game.DisplayHelp("~b~Investigation Mode:~s~ Press ~b~" + Controls.SecondaryAction.ToUserFriendlyName() + "~s~ to watch the ~g~CCTV camera footage~s~", 10); // //cctvObjectVar1.Opacity = cctvObjectVar1.Opacity == 1.0f ? 0.33f : 1.0f; // if (Controls.SecondaryAction.IsJustPressed()) // { // //cctvObjectVar1.Opacity = 1.0f; // watchCCTVCameraFootage(owner); // } // } // else if (owner.InvestigationModeRaycastResult.HitEntity == knifeObject) // { // Game.DisplayHelp("~b~Investigation Mode:~s~ Press ~b~" + Controls.SecondaryAction.ToUserFriendlyName() + "~s~ to collect the ~g~knife~s~ as an evidence", 10); // if (Controls.SecondaryAction.IsJustPressed()) // { // if (!hasFoundKnife) // { // if (knifeObject.Exists()) // knifeObject.Delete(); // owner.Report.AddTextToReport( // @"[" + DateTime.UtcNow.ToShortDateString() + " " + DateTime.UtcNow.ToLongTimeString() + @"] //Knife found. //Has blood remains. //Possible crime weapon."); // } // hasFoundKnife = true; // } // } // } // } if (hasCCTVTextBeenAddedToReport) { if (Controls.SecondaryAction.IsJustPressed()) { Ped closestPed = World.GetClosestEntity(Game.LocalPlayer.Character.Position, 5.0f, GetEntitiesFlags.ConsiderHumanPeds | GetEntitiesFlags.ExcludePlayerPed) as Ped; if (closestPed.Exists()) { if (alreadyAskedPeds.Contains(closestPed)) { Game.DisplayHelp("You already asked this pedestrian"); return; } if (closestPed.IsDead) { string[] phrases = { "What do you think you're doing? You can't ask a dead body...", "Ha, ha, ha! So funny... Asking a dead body...", "Mmh, I think that's a dead body, you shouldn't ask " + (closestPed.IsMale ? "him" : "her"), }; Game.DisplayHelp(phrases.GetRandomElement(), 5750); return; } closestPed.BlockPermanentEvents = true; bool askingPed = true; GameFiber.StartNew(delegate { while (askingPed && closestPed.Exists()) { GameFiber.Yield(); closestPed.Tasks.AchieveHeading(closestPed.GetHeadingTowards(Game.LocalPlayer.Character)); } }); GameFiber.Sleep(225); bool pedDisrespectPolice = Globals.Random.Next(12) <= 1 ? true : false; bool pedSawMurderer = Globals.Random.Next(3) == 1 ? true : false; if (closestPed.IsMale) { Game.DisplaySubtitle("~b~" + Settings.General.Name + ": ~w~Sir, have you seen this person?", 3250); //TODO: implement asking peds } else { Game.DisplaySubtitle("~b~" + Settings.General.Name + ": ~w~Ma'am, have you seen this person?", 3250); } GameFiber.Sleep(3150); if (closestPed == murdererPed) { askingPed = false; murdererPed.Tasks.Clear(); murdererPed.Flee(Game.LocalPlayer.Character, 1000.0f, 60000); // notfleeing } else { if (pedSawMurderer) { if (pedDisrespectPolice) { Game.DisplaySubtitle("pedSawMurderer pedDisrespectPolice", 5000); } else { Game.DisplaySubtitle("pedSawMurderer", 5000); } } else { if (pedDisrespectPolice) { string notSawDisrespect = new string[] { "Ha, ha! So now you pigs need my help!? Go ask your speed tickets!" }.GetRandomElement(); Game.DisplaySubtitle("~b~Pedestrian: ~w~" + notSawDisrespect, 3250); } else { Game.DisplaySubtitle("pedNOTSawMurderer", 5000); } } } askingPed = false; alreadyAskedPeds.Add(closestPed); } } } } else if (state == Var1State.SuspectFound) { } }
public static void GrabPed() { Blip PedBlip; GameFiber.StartNew(delegate { pedfollowing = GetNearestValidPed(); if (!pedfollowing) { return; } EnableGrab = true; GrabItem.Text = "Let go"; CallTaxiItem.Enabled = false; FollowItem.Enabled = false; PedBlip = pedfollowing.AttachBlip(); PedBlip.Color = System.Drawing.Color.Yellow; GrabShortcutMessageShown = true; PedBlip.Flash(400, -1); pedfollowing.Rotation = Game.LocalPlayer.Character.Rotation; Game.LocalPlayer.Character.Tasks.PlayAnimation("doors@", "door_sweep_r_hand_medium", 9f, AnimationFlags.StayInEndFrame | AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly).WaitForCompletion(2000); if (EntryPoint.IsLSPDFRPlusRunning) { API.LSPDFRPlusFuncs.AddCountToStatistic(Main.PluginName, "People grabbed"); } pedfollowing.Tasks.ClearImmediately(); NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(pedfollowing, Game.LocalPlayer.Character, (int)PedBoneId.RightHand, 0.2f, 0.4f, 0f, 0f, 0f, 0f, true, true, false, false, 2, true); API.Functions.OnPlayerGrabbedPed(pedfollowing); while (true) { GameFiber.Yield(); if (!pedfollowing.Exists()) { break; } NativeFunction.Natives.ATTACH_ENTITY_TO_ENTITY(pedfollowing, Game.LocalPlayer.Character, (int)PedBoneId.RightHand, 0.2f, 0.4f, 0f, 0f, 0f, 0f, true, true, false, false, 2, true); if (Game.LocalPlayer.Character.GetNearbyVehicles(1).Length > 0 && Functions.IsPedArrested(pedfollowing)) { Vehicle nearestveh = Game.LocalPlayer.Character.GetNearbyVehicles(1)[0]; if (Game.LocalPlayer.Character.DistanceTo(nearestveh.Position) < 3.9f && nearestveh.PassengerCapacity >= 3) { int SeatToPutInto = 1; if (Game.LocalPlayer.Character.DistanceTo(nearestveh.GetOffsetPosition(Vector3.RelativeLeft * 1.5f)) > Game.LocalPlayer.Character.DistanceTo(nearestveh.GetOffsetPosition(Vector3.RelativeRight * 1.5f))) { SeatToPutInto = 2; } if (nearestveh.IsSeatFree(SeatToPutInto)) { Game.DisplayHelp("Press ~b~" + EntryPoint.kc.ConvertToString(PlacePedInVehicleKey) + "~s~ to place the suspect in the vehicle."); if (Game.IsKeyDown(PlacePedInVehicleKey)) { if (nearestveh.GetDoors().Length > SeatToPutInto + 1) { NativeFunction.Natives.TASK_OPEN_VEHICLE_DOOR(Game.LocalPlayer.Character, nearestveh, 6000f, SeatToPutInto, 1.47f); int waitCount = 0; while (true) { GameFiber.Wait(1000); waitCount++; if (nearestveh.Doors[SeatToPutInto + 1].IsOpen || waitCount >= 6 || pedfollowing.IsInVehicle(nearestveh, false)) { pedfollowing.Detach(); GameFiber.Sleep(500); break; } if (pedfollowing.Exists()) { if (!pedfollowing.IsDead) { NativeFunction.Natives.TASK_OPEN_VEHICLE_DOOR(Game.LocalPlayer.Character, nearestveh, 6000f, SeatToPutInto, 1.47f); } } } } pedfollowing.Detach(); pedfollowing.Tasks.EnterVehicle(nearestveh, 4000, SeatToPutInto).WaitForCompletion(); if (!pedfollowing.IsInVehicle(nearestveh, false)) { if (Game.LocalPlayer.Character.IsInVehicle(nearestveh, false) && Game.LocalPlayer.Character.SeatIndex == SeatToPutInto) { Game.LocalPlayer.Character.Tasks.ClearImmediately(); } pedfollowing.WarpIntoVehicle(nearestveh, SeatToPutInto); } break; } } } } //NativeFunction.Natives<uint>("SET_PLAYER_SPRINT", Game.LocalPlayer, false); if (!NativeFunction.Natives.IS_ENTITY_PLAYING_ANIM <bool>(Game.LocalPlayer.Character, "doors@", "door_sweep_r_hand_medium", 3)) { Game.LocalPlayer.Character.Tasks.PlayAnimation("doors@", "door_sweep_r_hand_medium", 9f, AnimationFlags.StayInEndFrame | AnimationFlags.SecondaryTask | AnimationFlags.UpperBodyOnly); } if (!EnableGrab || Game.LocalPlayer.Character.IsInAnyVehicle(false) || pedfollowing.IsInAnyVehicle(true) || Game.LocalPlayer.Character.DistanceTo(pedfollowing) > 4f) { break; } } if (pedfollowing.Exists()) { if (!pedfollowing.IsInAnyVehicle(false)) { pedfollowing.Detach(); pedfollowing.Tasks.StandStill(7000); } } Game.LocalPlayer.Character.Tasks.ClearSecondary(); EnableGrab = false; GrabItem.Text = "Grab"; if (PedBlip.Exists()) { PedBlip.Delete(); } CallTaxiItem.Enabled = true; FollowItem.Enabled = true; }); }
internal void insurancePickUp() { GameFiber.StartNew(delegate { try { Vehicle[] nearbyvehs = Game.LocalPlayer.Character.GetNearbyVehicles(2); if (nearbyvehs.Length == 0) { Game.DisplayNotification("~r~Couldn't detect a close enough vehicle."); return; } car = nearbyvehs[0]; if (Vector3.Distance(Game.LocalPlayer.Character.Position, car.Position) > 6f) { Game.DisplayNotification("~r~Couldn't detect a close enough vehicle."); return; } if (car.HasOccupants) { if (nearbyvehs.Length == 2) { car = nearbyvehs[1]; if (car.HasOccupants) { Game.DisplayNotification("~r~Couldn't detect a close enough vehicle without occupants."); return; } } else { Game.DisplayNotification("~r~Couldn't detect a close enough vehicle without occupants."); return; } } if (car.IsPoliceVehicle) { Game.DisplayNotification("Are you sure you want to remove the police vehicle? ~h~~b~Y/N"); while (true) { GameFiber.Yield(); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(System.Windows.Forms.Keys.Y)) { break; } if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(System.Windows.Forms.Keys.N)) { return; } } } ToggleMobilePhone(Game.LocalPlayer.Character, true); GameFiber.Sleep(3000); ToggleMobilePhone(Game.LocalPlayer.Character, false); car.IsPersistent = true; carblip = car.AttachBlip(); carblip.Color = System.Drawing.Color.Black; carblip.Scale = 0.7f; string modelName = car.Model.Name.ToLower(); modelName = char.ToUpper(modelName[0]) + modelName.Substring(1); Ped playerPed = Game.LocalPlayer.Character; if (EntryPoint.IsLSPDFRPlusRunning) { API.LSPDFRPlusFuncs.AddCountToStatistic(Main.PluginName, "Insurance pickups"); } Vector3 SpawnPoint = World.GetNextPositionOnStreet(playerPed.Position.Around(EntryPoint.SceneManagementSpawnDistance)); float travelDistance; int waitCount = 0; while (true) { SpawnPoint = World.GetNextPositionOnStreet(playerPed.Position.Around(EntryPoint.SceneManagementSpawnDistance)); travelDistance = Rage.Native.NativeFunction.Natives.CALCULATE_TRAVEL_DISTANCE_BETWEEN_POINTS <float>(SpawnPoint.X, SpawnPoint.Y, SpawnPoint.Z, playerPed.Position.X, playerPed.Position.Y, playerPed.Position.Z); waitCount++; if (Vector3.Distance(playerPed.Position, SpawnPoint) > EntryPoint.SceneManagementSpawnDistance - 10f) { if (travelDistance < (EntryPoint.SceneManagementSpawnDistance * 4.5f)) { break; } } if (waitCount == 600) { Game.DisplayNotification("Take the car ~s~to a more reachable location."); Game.DisplayNotification("Alternatively, press ~b~Y ~s~to force a spawn in the ~g~wilderness."); } if ((waitCount >= 600) && Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(Keys.Y)) { SpawnPoint = Game.LocalPlayer.Character.Position.Around(15f); break; } GameFiber.Yield(); } car.LockStatus = VehicleLockStatus.Unlocked; car.MustBeHotwired = false; Game.DisplayNotification("mphud", "mp_player_ready", "~h~Mors Mutual Insurance", "~b~Vehicle Pickup Status Update", "Two of our employees are en route to pick up our client's ~h~" + modelName + "."); businessCar = new Vehicle(insurancevehicles[rnd.Next(insurancevehicles.Length)], SpawnPoint); businesscarblip = businessCar.AttachBlip(); businesscarblip.Color = System.Drawing.Color.Blue; businessCar.IsPersistent = true; Vector3 directionFromVehicleToPed = (car.Position - businessCar.Position); directionFromVehicleToPed.Normalize(); businessCar.Heading = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed); driver = new Ped("a_m_y_business_02", businessCar.Position, businessCar.Heading); driver.BlockPermanentEvents = true; driver.WarpIntoVehicle(businessCar, -1); driver.Money = 1; passenger = new Ped("a_m_y_business_02", businessCar.Position, businessCar.Heading); passenger.BlockPermanentEvents = true; passenger.WarpIntoVehicle(businessCar, 0); passenger.Money = 1; driveToEntity(driver, businessCar, car, true); Rage.Native.NativeFunction.Natives.START_VEHICLE_HORN(businessCar, 3000, 0, true); while (true) { GameFiber.Yield(); driver.Tasks.DriveToPosition(car.GetOffsetPosition(Vector3.RelativeFront * 2f), 10f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians).WaitForCompletion(500); if (Vector3.Distance(businessCar.Position, car.Position) < 15f) { driver.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait); break; } if (Vector3.Distance(car.Position, businessCar.Position) > 50f) { SpawnPoint = World.GetNextPositionOnStreet(car.Position); businessCar.Position = SpawnPoint; directionFromVehicleToPed = (car.Position - SpawnPoint); directionFromVehicleToPed.Normalize(); float vehicleHeading = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed); businessCar.Heading = vehicleHeading; } } driver.PlayAmbientSpeech("GENERIC_HOWS_IT_GOING", true); passenger.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(); Rage.Native.NativeFunction.Natives.SET_PED_CAN_RAGDOLL(passenger, false); passenger.Tasks.FollowNavigationMeshToPosition(car.GetOffsetPosition(Vector3.RelativeLeft * 2f), car.Heading, 2f).WaitForCompletion(2000); driver.Dismiss(); passenger.Tasks.FollowNavigationMeshToPosition(car.GetOffsetPosition(Vector3.RelativeLeft * 2f), car.Heading, 2f).WaitForCompletion(3000); passenger.Tasks.EnterVehicle(car, 9000, -1).WaitForCompletion(); if (car.HasDriver) { if (car.Driver != passenger) { car.Driver.Tasks.LeaveVehicle(LeaveVehicleFlags.WarpOut).WaitForCompletion(); } } passenger.WarpIntoVehicle(car, -1); GameFiber.Sleep(2000); passenger.PlayAmbientSpeech("GENERIC_THANKS", true); passenger.Dismiss(); car.Dismiss(); carblip.Delete(); businesscarblip.Delete(); GameFiber.Sleep(9000); Game.DisplayNotification("mphud", "mp_player_ready", "~h~Mors Mutual Insurance", "~b~Vehicle Pickup Status Update", "Thank you for letting us collect our client's ~h~" + modelName + "!"); } catch (Exception e) { Game.LogTrivial(e.ToString()); Game.LogTrivial("Insurance company Crashed"); Game.DisplayNotification("The insurance pickup service was interrupted."); if (businesscarblip.Exists()) { businesscarblip.Delete(); } if (carblip.Exists()) { carblip.Delete(); } if (driver.Exists()) { driver.Delete(); } if (car.Exists()) { car.Delete(); } if (businessCar.Exists()) { businessCar.Delete(); } if (passenger.Exists()) { passenger.Delete(); } } }); }
public static void TaskDriveToEntity(Ped driver, Vehicle vehicle, Entity target, bool getClose) { int drivingLoopCount = 0; bool transportVanTeleported = false; int waitCount = 0; bool forceCloseSpawn = false; // Get close to player with various checks try { GameFiber.StartNew(delegate { while (!forceCloseSpawn) { GameFiber.Yield(); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(EntryPoint.SceneManagementKey)) { GameFiber.Sleep(300); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownRightNowComputerCheck(EntryPoint.SceneManagementKey)) { GameFiber.Sleep(1000); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownRightNowComputerCheck(EntryPoint.SceneManagementKey)) { forceCloseSpawn = true; } else { Game.DisplayNotification("Hold down the ~b~Scene Management Key ~s~to force a close spawn."); } } } } }); Task driveToPed = null; driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraight).WaitForCompletion(500); while (Vector3.Distance(vehicle.Position, target.Position) > 35f) { if (!target.Exists() || !target.IsValid()) { return; } vehicle.Repair(); if (driveToPed?.IsActive != true) { driver.Tasks.DriveToPosition(target.Position, 15f, VehicleDrivingFlags.FollowTraffic | VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); } NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE(driver, 786607); NativeFunction.Natives.SET_DRIVER_AGGRESSIVENESS(driver, 0f); NativeFunction.Natives.SET_DRIVER_ABILITY(driver, 1f); GameFiber.Wait(600); waitCount++; if (waitCount == 55) { Game.DisplayHelp("Service taking too long? Hold down ~b~" + EntryPoint.KeyConvert.ConvertToString(EntryPoint.SceneManagementKey) + " ~s~to speed it up.", 5000); } //If van isn't moving if (vehicle.Speed < 2f) { drivingLoopCount++; } //if van is very far away if (Vector3.Distance(target.Position, vehicle.Position) > EntryPoint.SceneManagementSpawnDistance + 65f) { drivingLoopCount++; } //If Van is stuck, relocate it if (drivingLoopCount >= 33 && drivingLoopCount <= 38 && EntryPoint.AllowWarping) { Vector3 SpawnPoint; float Heading; bool UseSpecialID = true; float travelDistance; int wC = 0; while (true) { GetSpawnPoint(target.Position, out SpawnPoint, out Heading, UseSpecialID); travelDistance = Rage.Native.NativeFunction.Natives.CALCULATE_TRAVEL_DISTANCE_BETWEEN_POINTS <float>(SpawnPoint.X, SpawnPoint.Y, SpawnPoint.Z, target.Position.X, target.Position.Y, target.Position.Z); wC++; if (Vector3.Distance(target.Position, SpawnPoint) > EntryPoint.SceneManagementSpawnDistance - 15f && travelDistance < (EntryPoint.SceneManagementSpawnDistance * 4.5f)) { var spawnDirection = (target.Position - SpawnPoint); spawnDirection.Normalize(); var headingToPlayer = MathHelper.ConvertDirectionToHeading(spawnDirection); if (Math.Abs(MathHelper.NormalizeHeading(Heading) - MathHelper.NormalizeHeading(headingToPlayer)) < 150f) { break; } } if (wC >= 400) { UseSpecialID = false; } GameFiber.Yield(); } Game.Console.Print("Relocating because service was stuck..."); vehicle.Position = SpawnPoint; vehicle.Heading = Heading; drivingLoopCount = 39; } // if van is stuck for a 2nd time or takes too long, spawn it very near to the car else if (((drivingLoopCount >= 70 || waitCount >= 110) && EntryPoint.AllowWarping) || forceCloseSpawn) { Game.Console.Print("Relocating service to a close position"); Vector3 SpawnPoint = World.GetNextPositionOnStreet(target.Position.Around2D(15f)); int waitCounter = 0; while ((SpawnPoint.Z - target.Position.Z < -3f) || (SpawnPoint.Z - target.Position.Z > 3f) || (Vector3.Distance(SpawnPoint, target.Position) > 26f)) { waitCounter++; SpawnPoint = World.GetNextPositionOnStreet(target.Position.Around(20f)); GameFiber.Yield(); if (waitCounter >= 500) { SpawnPoint = target.Position.Around(20f); break; } } Vector3 directionFromVehicleToPed = (target.Position - SpawnPoint); directionFromVehicleToPed.Normalize(); float vehicleHeading = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed); vehicle.Heading = vehicleHeading + 180f; vehicle.Position = SpawnPoint; transportVanTeleported = true; break; } } forceCloseSpawn = true; //park the van Game.HideHelp(); if (!getClose) { while (((Vector3.Distance(target.Position, vehicle.Position) > 19f && (vehicle.Position.Z - target.Position.Z < -2.5f)) || (vehicle.Position.Z - target.Position.Z > 2.5f)) && !transportVanTeleported) { if (!target.Exists() || !target.IsValid()) { return; } Rage.Task parkNearcar = driver.Tasks.DriveToPosition(target.Position, 6f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); parkNearcar.WaitForCompletion(900); if (Vector3.Distance(target.Position, vehicle.Position) > 60f) { Vector3 SpawnPoint = World.GetNextPositionOnStreet(target.Position.Around(10f)); int waitCounter = 0; while ((SpawnPoint.Z - target.Position.Z < -3f) || (SpawnPoint.Z - target.Position.Z > 3f) || (Vector3.Distance(SpawnPoint, target.Position) > 26f)) { waitCounter++; SpawnPoint = World.GetNextPositionOnStreet(target.Position.Around(20f)); GameFiber.Yield(); if (waitCounter >= 500) { SpawnPoint = target.Position.Around(20f); break; } } Vector3 directionFromVehicleToPed = (target.Position - SpawnPoint); directionFromVehicleToPed.Normalize(); float vehicleHeading = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed); vehicle.Heading = vehicleHeading + 180f; vehicle.Position = SpawnPoint; transportVanTeleported = true; } } } else { while ((Vector3.Distance(target.Position, vehicle.Position) > 17f) || transportVanTeleported) { if (!target.Exists() || !target.IsValid()) { return; } Rage.Task parkNearSuspect = driver.Tasks.DriveToPosition(target.Position, 6f, VehicleDrivingFlags.FollowTraffic | VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians); parkNearSuspect.WaitForCompletion(800); transportVanTeleported = false; if (Vector3.Distance(target.Position, vehicle.Position) > 50f) { vehicle.Position = World.GetNextPositionOnStreet(target.Position.Around(12f)); } } GameFiber.Sleep(600); } } #pragma warning disable CA1031 // Do not catch general exception types catch { // If we don't catch everything we got, we will crash the plug-in // That is what analyzers would not understand } #pragma warning restore CA1031 // Do not catch general exception types }
internal static void Main() { MechAction mechAction = new MechAction(); GameFiber.StartNew(mechAction.Drive); }
private void SituationTwo() { StolenGoodsValue = AssortedCalloutsHandler.rnd.Next(5, 500); SpawnStorePeds(); while (CalloutRunning) { GameFiber.Yield(); if (Vector3.Distance(Game.LocalPlayer.Character.Position, SearchArea) < 150f) { SearchArea.IsRouteEnabled = false; break; } } if (ComputerPlusRunning) { API.ComputerPlusFuncs.SetCalloutStatusToAtScene(CalloutID); } if (CalloutRunning) { SearchArea.Delete(); Suspects[0].Position = World.GetNextPositionOnStreet(Suspects[0].Position); Pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(Pursuit, Suspects[0]); Functions.SetPedAsCop(Security[0]); Security[0].MakeMissionPed(); Functions.AddCopToPursuit(Pursuit, Security[0]); Functions.SetPursuitIsActiveForPlayer(Pursuit, true); Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~b~" + ShopliftingStore.Name + " ~r~shoplifting", "Dispatch to ~b~" + AssortedCalloutsHandler.DivisionUnitBeat, "Suspect has reportedly escaped from the store and is now being chased by security. Apprehend the suspect."); Functions.PlayScannerAudioUsingPosition("WE_HAVE_01 CRIME_RESIST_ARREST IN_OR_ON_POSITION", SpawnPoint); } while (CalloutRunning) { GameFiber.Yield(); if (!Functions.IsPursuitStillRunning(Pursuit)) { GameFiber.Wait(3000); SearchArea = ShopKeepers[0].AttachBlip(); SearchArea.Color = System.Drawing.Color.Yellow; SearchArea.IsRouteEnabled = true; break; } } while (CalloutRunning) { GameFiber.Yield(); if (Vector3.Distance(Game.LocalPlayer.Character.Position, ShopKeepers[0].Position) < 4f) { if (SearchArea.Exists()) { SearchArea.IsRouteEnabled = false; SearchArea.Delete(); } Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.TalkKey) + " ~s~to talk."); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(AssortedCalloutsHandler.TalkKey)) { ShopKeepers[0].Tasks.ClearImmediately(); SpeechHandler.HandleSpeech("Shopkeeper", DetermineShopkeeperLines(), ShopKeepers[0]); GameFiber.Wait(4000); break; } } else { Game.DisplayHelp("Talk to the ~b~shopkeeper ~s~for a victim statement."); } } while (CalloutRunning) { GameFiber.Yield(); Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.EndCallKey) + " ~s~when you're done investigating."); if (Game.IsKeyDown(AssortedCalloutsHandler.EndCallKey)) { Game.HideHelp(); break; } } DisplayCodeFourMessage(); }
public override void End() { CalloutRunning = false; Rage.Native.NativeFunction.Natives.CLEAR_PED_NON_CREATION_AREA(); NativeFunction.Natives.SET_STORE_ENABLED(true); if (Game.LocalPlayer.Character.Exists()) { if (Game.LocalPlayer.Character.IsDead) { GameFiber.Wait(1500); Functions.PlayScannerAudio("OFFICER HAS_BEEN_FATALLY_SHOT NOISE_SHORT OFFICER_NEEDS_IMMEDIATE_ASSISTANCE"); GameFiber.Wait(3000); if (ComputerPlusRunning) { API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Officer down. Urgent assistance required."); } } } else { GameFiber.Wait(1500); Functions.PlayScannerAudio("OFFICER HAS_BEEN_FATALLY_SHOT NOISE_SHORT OFFICER_NEEDS_IMMEDIATE_ASSISTANCE"); GameFiber.Wait(3000); if (ComputerPlusRunning) { API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Officer down. Urgent assistance required."); } } base.End(); if (SearchArea.Exists()) { SearchArea.Delete(); } if (CalloutFinished) { foreach (Ped ShopKeeper in ShopKeepers) { if (ShopKeeper.Exists()) { ShopKeeper.Tasks.Clear(); ShopKeeper.IsPersistent = false; } } foreach (Ped suspect in Suspects) { if (suspect.Exists()) { Suspect.IsPersistent = false; } } foreach (Ped suspect in Security) { if (suspect.Exists()) { suspect.IsPersistent = false; } } } else { foreach (Ped ShopKeeper in ShopKeepers) { if (ShopKeeper.Exists()) { ShopKeeper.Delete(); } } foreach (Ped suspect in Suspects) { if (suspect.Exists()) { suspect.Delete(); } } foreach (Ped suspect in Security) { if (suspect.Exists()) { suspect.Delete(); } } } }
private void SituationOne() { //One robber, one shopkeeper. Wait, fight, flee (pursuit). StolenGoodsValue = AssortedCalloutsHandler.rnd.Next(5, 300); SpawnStorePeds(); while (CalloutRunning) { GameFiber.Yield(); if (Vector3.Distance(Game.LocalPlayer.Character.Position, SearchArea) < 40f) { SearchArea.IsRouteEnabled = false; break; } } if (ComputerPlusRunning) { API.ComputerPlusFuncs.SetCalloutStatusToAtScene(CalloutID); } while (CalloutRunning) { GameFiber.Yield(); if (NativeFunction.Natives.GET_INTERIOR_FROM_ENTITY <int>(Game.LocalPlayer.Character) != 0) { SpeechHandler.HandleSpeech("Shopkeeper", "Hey officer, the scumbag is in the back!"); break; } } while (CalloutRunning) { GameFiber.Yield(); if (Vector3.Distance(Game.LocalPlayer.Character.Position, Security[0].Position) < 4f) { Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.TalkKey) + " ~s~to talk."); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(AssortedCalloutsHandler.TalkKey)) { Security[0].Tasks.ClearImmediately(); break; } } else { Game.HideHelp(); } } if (CalloutRunning) { SearchArea.Delete(); DetermineSecurityLines(); SpeechHandler.HandleSpeech("Security", DetermineSecurityLines(), Security[0]); SpeechHandler.HandleSpeech("Suspect", DetermineSuspectLines(), Suspects[0]); } while (CalloutRunning) { GameFiber.Yield(); Game.DisplayHelp("Deal with the situation as you see fit. Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.EndCallKey) + " ~s~when done."); if (Game.IsKeyDown(AssortedCalloutsHandler.EndCallKey)) { Game.HideHelp(); break; } } DisplayCodeFourMessage(); }
public override void Process() { GameFiber.StartNew(delegate { if (_subject.Exists() && _subject.DistanceTo(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront)) < 35f && !_isArmed) { if (_Blip.Exists()) { _Blip.Delete(); } _subject.Inventory.GiveNewWeapon(new WeaponAsset(wepList[new Random().Next((int)wepList.Length)]), 500, true); _isArmed = true; } if (_subject.Exists() && _subject.DistanceTo(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront)) < 50f && !_hasBegunAttacking) { if (_scenario > 40) { _subject.KeepTasks = true; new RelationshipGroup("AG"); new RelationshipGroup("VI"); _subject.RelationshipGroup = "AG"; _V1.RelationshipGroup = "VI"; _V2.RelationshipGroup = "VI"; _V3.RelationshipGroup = "VI"; Game.SetRelationshipBetweenRelationshipGroups("AG", "VI", Relationship.Hate); _subject.Tasks.FightAgainstClosestHatedTarget(1000f); Functions.PlayScannerAudio("INTRO_02 CRIME_GUNFIRE_01"); Game.DisplayNotification("~b~Meldkamer: ~w~Het Gepanserd Persoon is aan het ~r~schieten~w~ op mensen!"); GameFiber.Wait(2000); _subject.Tasks.FightAgainst(Game.LocalPlayer.Character); _hasBegunAttacking = true; GameFiber.Wait(600); } else { if (!_hasPursuitBegun) { _subject.KeepTasks = true; _subject.Tasks.FightAgainst(Game.LocalPlayer.Character); _hasBegunAttacking = true; GameFiber.Wait(2000); } } } if (Game.LocalPlayer.Character.IsDead) { End(); } if (Game.IsKeyDown(Settings.EndCall)) { End(); } if (_subject.IsDead) { End(); } if (Functions.IsPedArrested(_subject)) { End(); } }, "Schieter [DutchCallouts]"); base.Process(); }
private void MainMenuButtonClickedHandler(Base sender, ClickedEventArgs e) { this.Window.Close(); form_main = new GameFiber(OpenMainMenuForm); form_main.Start(); }
private void PublishCourtResults() { if (!CourtSystem.PublishedCourtCases.Contains(this)) { if (CourtSystem.PendingCourtCases.Contains(this)) { Menus.PendingResultsList.Items.RemoveAt(CourtSystem.PendingCourtCases.IndexOf(this)); if (Menus.PendingResultsList.Items.Count == 0) { Menus.PendingResultsList.Items.Add(new TabItem(" ")); PendingResultsMenuCleared = false; } Menus.PendingResultsList.Index = 0; CourtSystem.PendingCourtCases.Remove(this); } CourtSystem.PublishedCourtCases.Insert(0, this); string CrimeString = char.ToUpper(Crime[0]) + Crime.ToLower().Substring(1); if (GuiltyChance < 0) { GuiltyChance = 0; } else if (GuiltyChance > 100) { GuiltyChance = 100; } if (LSPDFRPlusHandler.rnd.Next(100) >= GuiltyChance && !ResultsPublishedNotificationShown) { CourtVerdict = "Found not guilty and cleared of all charges."; } TabTextItem item = new TabTextItem(MenuLabel(false), "Court Result", MenuLabel(false) + "~s~. ~r~" + CrimeString + (Crime[Crime.Length - 1] == '.' ? "" : "~s~.") + "~s~~n~ " + CourtVerdict + (CourtVerdict[CourtVerdict.Length - 1] == '.' ? "" : "~s~.") + "~s~~n~ Offence took place on ~b~" + CrimeDate.ToShortDateString() + "~s~ at ~b~" + CrimeDate.ToShortTimeString() + "~s~.~n~ Hearing was on ~b~" + ResultsPublishTime.ToShortDateString() + "~s~ at ~b~" + ResultsPublishTime.ToShortTimeString() + "." + "~n~~n~~y~Select this case and press ~b~Delete ~y~to dismiss it."); Menus.PublishedResultsList.Items.Insert(0, item); Menus.PublishedResultsList.RefreshIndex(); if (!ResultsMenuCleared) { Game.LogTrivial("Emtpy items, clearing menu at index 1."); Menus.PublishedResultsList.Items.RemoveAt(1); ResultsMenuCleared = true; } ResultsPublished = true; if (!ResultsPublishedNotificationShown) { if (CourtSystem.LoadingXMLFileCases) { GameFiber.StartNew(delegate { GameFiber.Wait(25000); if (CourtSystem.OpenCourtMenuKey != Keys.None) { Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~b~San Andreas Court", "~r~" + SuspectName, "A court case you're following has been heard. Press ~b~" + Albo1125.Common.CommonLibrary.ExtensionMethods.GetKeyString(CourtSystem.OpenCourtMenuKey, CourtSystem.OpenCourtMenuModifierKey) + "."); } }); } else { if (CourtSystem.OpenCourtMenuKey != Keys.None) { Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~b~San Andreas Court", "~r~" + SuspectName, "A court case you're following has been heard. Press ~b~" + Albo1125.Common.CommonLibrary.ExtensionMethods.GetKeyString(CourtSystem.OpenCourtMenuKey, CourtSystem.OpenCourtMenuModifierKey) + "."); } } ResultsPublishedNotificationShown = true; CourtSystem.OverwriteCourtCase(this); } } }
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 void CallTaxi() { GameFiber.StartNew(delegate { try { pedtobepickedup = GetNearestValidPed(); if (!pedtobepickedup) { return; } if (Functions.IsPedArrested(pedtobepickedup)) { return; } if (EntryPoint.suspectsPendingTransport.Contains(pedtobepickedup)) { return; } if (pedtobepickedup.IsInAnyVehicle(false)) { Game.DisplaySubtitle("Remove ped from vehicle", 3000); return; } if (pedsbeingpickedup.Contains(pedtobepickedup)) { Game.DisplaySubtitle("Taxi already enroute", 3000); return; } ToggleMobilePhone(Game.LocalPlayer.Character, true); pedsbeingpickedup.Add(pedtobepickedup); pedtobepickedup.IsPersistent = true; pedtobepickedup.BlockPermanentEvents = true; pedtobepickedup.Tasks.StandStill(-1); Functions.SetPedCantBeArrestedByPlayer(pedtobepickedup, true); if (EntryPoint.IsLSPDFRPlusRunning) { API.LSPDFRPlusFuncs.AddCountToStatistic(Main.PluginName, "Taxis called"); } float Heading; bool UseSpecialID = true; Vector3 SpawnPoint; float travelDistance; int waitCount = 0; while (true) { GetSpawnPoint(pedtobepickedup.Position, out SpawnPoint, out Heading, UseSpecialID); travelDistance = Rage.Native.NativeFunction.Natives.CALCULATE_TRAVEL_DISTANCE_BETWEEN_POINTS <float>(SpawnPoint.X, SpawnPoint.Y, SpawnPoint.Z, pedtobepickedup.Position.X, pedtobepickedup.Position.Y, pedtobepickedup.Position.Z); waitCount++; if (Vector3.Distance(pedtobepickedup.Position, SpawnPoint) > EntryPoint.SceneManagementSpawnDistance - 15f) { if (travelDistance < (EntryPoint.SceneManagementSpawnDistance * 4.5f)) { Vector3 directionFromVehicleToPed1 = (pedtobepickedup.Position - SpawnPoint); directionFromVehicleToPed1.Normalize(); float HeadingToPlayer = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed1); if (Math.Abs(MathHelper.NormalizeHeading(Heading) - MathHelper.NormalizeHeading(HeadingToPlayer)) < 150f) { break; } else { } } else { } } else { } if (waitCount >= 400) { UseSpecialID = false; } if (waitCount == 600) { Game.DisplayNotification("Take the suspect ~s~to a more reachable location."); Game.DisplayNotification("Alternatively, press ~b~Y ~s~to force a spawn in the ~g~wilderness."); } if ((waitCount >= 600) && Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(Keys.Y)) { SpawnPoint = Game.LocalPlayer.Character.Position.Around(15f); break; } GameFiber.Yield(); } GameFiber.Wait(3000); ToggleMobilePhone(Game.LocalPlayer.Character, false); taxi = new Vehicle("TAXI", SpawnPoint, Heading); taxi.IsPersistent = true; taxi.IsTaxiLightOn = false; taxiblip = taxi.AttachBlip(); taxiblip.Color = System.Drawing.Color.Blue; taxiblip.Flash(500, -1); taxidriver = taxi.CreateRandomDriver(); taxidriver.IsPersistent = true; taxidriver.BlockPermanentEvents = true; taxidriver.Money = 1233; Game.DisplayNotification("A ~y~taxi ~s~is enroute to pick up the ped."); driveToEntity(taxidriver, taxi, pedtobepickedup, true); Rage.Native.NativeFunction.Natives.START_VEHICLE_HORN(taxi, 5000, 0, true); if (taxi.Speed > 15f) { NativeFunction.Natives.SET_VEHICLE_FORWARD_SPEED(taxi, 15f); } taxidriver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraightBraking); GameFiber.Sleep(600); taxidriver.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait); if (taxiblip.Exists()) { taxiblip.Delete(); } if (pedfollowing == pedtobepickedup) { EnableFollow = false; } Rage.Native.NativeFunction.Natives.SET_PED_CAN_RAGDOLL(pedtobepickedup, false); pedtobepickedup.Tasks.Clear(); pedtobepickedup.Tasks.FollowNavigationMeshToPosition(taxi.GetOffsetPosition(Vector3.RelativeLeft * 2f), taxi.Heading, 1.65f).WaitForCompletion(12000); pedtobepickedup.Tasks.EnterVehicle(taxi, 8000, 1).WaitForCompletion(); taxidriver.Dismiss(); taxi.Dismiss(); while (true) { GameFiber.Yield(); try { if (pedtobepickedup.Exists()) { if (!taxi.Exists()) { pedtobepickedup.Delete(); } if (!pedtobepickedup.IsDead) { if (Vector3.Distance(Game.LocalPlayer.Character.Position, pedtobepickedup.Position) > 80f) { pedtobepickedup.Delete(); break; } if (!pedtobepickedup.IsInVehicle(taxi, false)) { pedtobepickedup.Delete(); break; } } else { pedtobepickedup.Delete(); break; } } else { break; } } catch (Exception e) { Game.LogTrivial(e.ToString()); if (pedtobepickedup.Exists()) { pedtobepickedup.Delete(); } break; } } //Game.DisplayNotification("Cleaned up"); } catch (Exception e) { Game.LogTrivial(e.ToString()); Game.DisplayNotification("The taxi pickup service was interrupted"); if (taxi.Exists()) { taxi.Delete(); } if (taxidriver.Exists()) { taxidriver.Delete(); } if (pedtobepickedup.Exists()) { pedtobepickedup.Delete(); } } }); }
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; } }); }
internal void towVehicle(Vehicle car, bool playanims = true) { GameFiber.StartNew(delegate { if (!car.Exists()) { return; } try { bool flatbed = true; if (car.HasOccupants) { Game.DisplayNotification("Vehicle has occupants. Aborting tow."); return; } if (car.IsPoliceVehicle) { uint noti = Game.DisplayNotification("Are you sure you want to tow the police vehicle? ~h~~b~Y/N"); while (true) { GameFiber.Yield(); if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(System.Windows.Forms.Keys.Y)) { Game.RemoveNotification(noti); break; } if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(System.Windows.Forms.Keys.N)) { Game.RemoveNotification(noti); return; } } if (!car.Exists()) { return; } } if (!car.Model.IsCar && !car.Model.IsBike && !car.Model.IsQuadBike && !car.Model.IsBoat && !car.Model.IsJetski) { Game.DisplayNotification("Unfortunately, this vehicle can't be towed or impounded."); return; } car.IsPersistent = true; if (playanims) { Game.LocalPlayer.Character.Tasks.PlayAnimation("random@arrests", "generic_radio_chatter", 1.5f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask); GameFiber.Wait(1000); bleepPlayer.Play(); GameFiber.Wait(500); } carblip = car.AttachBlip(); carblip.Color = System.Drawing.Color.Black; carblip.Scale = 0.7f; if (EntryPoint.IsLSPDFRPlusRunning) { API.LSPDFRPlusFuncs.AddCountToStatistic(Main.PluginName, "Vehicles towed"); } Ped playerPed = Game.LocalPlayer.Character; if (car.Model.IsCar && RecruitNearbyTowtruck(out driver, out towTruck)) { Game.LogTrivial("Recruited nearby tow truck."); } else { float Heading; bool UseSpecialID = true; Vector3 SpawnPoint; float travelDistance; int waitCount = 0; while (true) { GetSpawnPoint(car.Position, out SpawnPoint, out Heading, UseSpecialID); travelDistance = Rage.Native.NativeFunction.Natives.CALCULATE_TRAVEL_DISTANCE_BETWEEN_POINTS <float>(SpawnPoint.X, SpawnPoint.Y, SpawnPoint.Z, car.Position.X, car.Position.Y, car.Position.Z); waitCount++; if (Vector3.Distance(car.Position, SpawnPoint) > EntryPoint.SceneManagementSpawnDistance - 15f) { if (travelDistance < (EntryPoint.SceneManagementSpawnDistance * 4.5f)) { Vector3 directionFromVehicleToPed1 = (car.Position - SpawnPoint); directionFromVehicleToPed1.Normalize(); float HeadingToPlayer = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed1); if (Math.Abs(MathHelper.NormalizeHeading(Heading) - MathHelper.NormalizeHeading(HeadingToPlayer)) < 150f) { break; } } } if (waitCount >= 400) { UseSpecialID = false; } if (waitCount == 600) { Game.DisplayNotification("Take the car ~s~to a more reachable location."); Game.DisplayNotification("Alternatively, press ~b~Y ~s~to force a spawn in the ~g~wilderness."); } if ((waitCount >= 600) && Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(Keys.Y)) { SpawnPoint = Game.LocalPlayer.Character.Position.Around(15f); break; } GameFiber.Yield(); } modelName = car.Model.Name.ToLower(); modelName = char.ToUpper(modelName[0]) + modelName.Substring(1); if (car.Model.IsCar && !car.IsDead && !AlwaysFlatbed) { Game.DisplayNotification("A ~g~tow truck ~s~has been dispatched for the target ~r~" + modelName + ". ~s~Await arrival."); towTruck = new Vehicle(TowtruckModel, SpawnPoint, Heading); Game.DisplayHelp("~b~If you want to attach the vehicle yourself, get in now."); flatbed = false; } else { Game.DisplayNotification("A ~g~flatbed ~s~has been dispatched for the target ~r~" + modelName + ". ~s~Await arrival."); towTruck = new Vehicle(FlatbedModel, SpawnPoint, Heading); } } TowTrucksBeingUsed.Add(towTruck); towTruck.IsPersistent = true; towTruck.CanTiresBurst = false; towTruck.IsInvincible = true; if (OverrideTowTruckColour) { towTruck.PrimaryColor = TowTruckColour; towTruck.SecondaryColor = TowTruckColour; towTruck.PearlescentColor = TowTruckColour; } towblip = towTruck.AttachBlip(); towblip.Color = System.Drawing.Color.Blue; //Vector3 directionFromVehicleToPed = (car.Position - towTruck.Position); //directionFromVehicleToPed.Normalize(); //towTruck.Heading = MathHelper.ConvertDirectionToHeading(directionFromVehicleToPed); if (!driver.Exists()) { driver = towTruck.CreateRandomDriver(); } driver.MakeMissionPed(); driver.IsInvincible = true; driver.Money = 1233; driveToEntity(driver, towTruck, car, false); Rage.Native.NativeFunction.Natives.START_VEHICLE_HORN(towTruck, 5000, 0, true); if (towTruck.Speed > 15f) { NativeFunction.Natives.SET_VEHICLE_FORWARD_SPEED(towTruck, 15f); } driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraightBraking); GameFiber.Sleep(600); driver.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait); towTruck.IsSirenOn = true; GameFiber.Wait(2000); bool automaticallyAttach = false; bool showImpoundMsg = true; if (flatbed) { while (car && car.HasOccupants) { GameFiber.Yield(); Game.DisplaySubtitle("~r~Please remove all occupants from the vehicle.", 1); } if (car) { car.AttachTo(towTruck, 20, FlatbedModifier, Rotator.Zero); } } else { if (!Game.LocalPlayer.Character.IsInVehicle(car, true)) { automaticallyAttach = true; } while (true) { GameFiber.Sleep(1); driver.Money = 1233; if (!car.Exists()) { break; } if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.D0) || automaticallyAttach) { if (Game.LocalPlayer.Character.IsInVehicle(car, false)) { Game.DisplaySubtitle("~r~Get out of the vehicle first.", 5000); } else { car.Position = towTruck.GetOffsetPosition(Vector3.RelativeBack * 7f); car.Heading = towTruck.Heading; if (towTruck.HasTowArm) { towTruck.TowVehicle(car, true); } else { car.Delete(); Game.LogTrivial("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); Game.DisplayNotification("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); } Game.HideHelp(); break; } } else if (Vector3.Distance(towTruck.GetOffsetPosition(Vector3.RelativeBack * 7f), car.Position) < 2.1f) { //Game.LogTrivial((towTruck.Heading - car.Heading).ToString()); if ((towTruck.Heading - car.Heading < 30f) && (towTruck.Heading - car.Heading > -30f)) { Game.DisplaySubtitle("~b~Exit the vehicle", 1); if (!Game.LocalPlayer.Character.IsInVehicle(car, true)) { GameFiber.Sleep(1000); towTruck.TowVehicle(car, true); break; } } else if (((towTruck.Heading - car.Heading < -155f) && (towTruck.Heading - car.Heading > -205f)) || ((towTruck.Heading - car.Heading > 155f) && (towTruck.Heading - car.Heading < 205f))) { Game.DisplaySubtitle("~b~Exit the vehicle", 1); if (!Game.LocalPlayer.Character.IsInVehicle(car, true)) { GameFiber.Sleep(1000); if (towTruck.HasTowArm) { towTruck.TowVehicle(car, false); } else { car.Delete(); Game.LogTrivial("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); Game.DisplayNotification("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); } break; } } else { Game.DisplaySubtitle("~b~Align the ~b~vehicle~s~ with the ~g~tow truck.", 1); } } else { Game.DisplaySubtitle("Drive the vehicle behind the tow truck.", 1); } if (Vector3.Distance(Game.LocalPlayer.Character.Position, car.Position) > 70f) { car.Position = towTruck.GetOffsetPosition(Vector3.RelativeBack * 7f); car.Heading = towTruck.Heading; if (towTruck.HasTowArm) { towTruck.TowVehicle(car, true); } else { car.Delete(); Game.LogTrivial("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); Game.DisplayNotification("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); } break; } if (Vector3.Distance(car.Position, towTruck.Position) > 80f) { Game.DisplaySubtitle("Towing service cancelled", 5000); showImpoundMsg = false; break; } } } Game.HideHelp(); if (showImpoundMsg) { Game.DisplayNotification("The target ~r~" + modelName + " ~s~has been impounded!"); } driver.Tasks.PerformDrivingManeuver(VehicleManeuver.GoForwardStraight).WaitForCompletion(600); driver.Tasks.CruiseWithVehicle(25f); GameFiber.Wait(1000); if (car.Exists() && towTruck.Exists() && !flatbed) { if (!car.FindTowTruck().Exists()) { car.Position = towTruck.GetOffsetPosition(Vector3.RelativeBack * 7f); car.Heading = towTruck.Heading; if (towTruck.HasTowArm) { towTruck.TowVehicle(car, true); } else { car.Delete(); Game.LogTrivial("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); Game.DisplayNotification("Tow truck model is not registered as a tow truck ingame - if this is a custom vehicle, contact the vehicle author."); } } } if (driver.Exists()) { driver.Dismiss(); } if (car.Exists()) { car.Dismiss(); } if (towTruck.Exists()) { towTruck.Dismiss(); } if (towblip.Exists()) { towblip.Delete(); } if (carblip.Exists()) { carblip.Delete(); } while (towTruck.Exists() && car.Exists()) { GameFiber.Sleep(1000); } if (car.Exists()) { car.Delete(); } } catch (Exception e) { Game.LogTrivial(e.ToString()); Game.LogTrivial("Tow Truck Crashed"); Game.DisplayNotification("The towing service was interrupted."); if (towblip.Exists()) { towblip.Delete(); } if (carblip.Exists()) { carblip.Delete(); } if (driver.Exists()) { driver.Delete(); } if (car.Exists()) { car.Delete(); } if (towTruck.Exists()) { towTruck.Delete(); } } }); }
private static void Main() { PluginState.Init(); PluginState.IsLoaded = true; while (Game.IsLoading) { GameFiber.Sleep(500); } if (!Directory.Exists(@"Plugins\Spotlight Resources\")) { Directory.CreateDirectory(@"Plugins\Spotlight Resources\"); } // let's keep using the Offsets.ini file for now //string vehSettingsFile = @"Plugins\Spotlight Resources\VehiclesSettings.xml"; //if (!File.Exists(vehSettingsFile) && File.Exists(@"Plugins\Spotlight Resources\Offsets.ini")) //{ // // legacy // vehSettingsFile = @"Plugins\Spotlight Resources\Offsets.ini"; //} Settings = new Settings(@"Plugins\Spotlight Resources\General.ini", @"Plugins\Spotlight Resources\Offsets.ini", @"Plugins\Spotlight Resources\VisualSettings.xml", true); LoadSpotlightControllers(); if (!(GameFunctions.Init() && GameMemory.Init() && GameOffsets.Init())) { Game.DisplayNotification($"~r~[ERROR] Spotlight: ~s~Failed to initialize, unloading..."); Game.LogTrivial($"[ERROR] Failed to initialize, unloading..."); Game.UnloadActivePlugin(); } if (Settings.EnableLightEmissives) { VehiclesUpdateHook.Hook(); } // when the queue array that the GetFreeLightDrawDataSlotFromQueue function accesses is full, // it uses the TLS to get an allocator to allocate memory for a bigger array, // therefore we copy the allocator pointers from the main thread TLS to our current thread TLS. WinFunctions.CopyTlsValues(WinFunctions.GetProcessMainThreadId(), WinFunctions.GetCurrentThreadId(), GameOffsets.TlsAllocator); if (Settings.EnableLightEmissives) { // TODO: find something better than this vehicles update hook to override the extralight emissives values // This function may execute multiple times per tick, which is not optimal VehiclesUpdateHook.VehiclesUpdate += OnVehiclesUpdate; } Game.LogTrivial("Initialized"); #if DEBUG bool f = false; #endif while (true) { GameFiber.Yield(); #if DEBUG if (Game.LocalPlayer.Character.CurrentVehicle) { if (Game.IsKeyDown(System.Windows.Forms.Keys.Y)) { Game.LocalPlayer.Character.CurrentVehicle.IsPositionFrozen = f = !f; } else if (Game.IsKeyDown(System.Windows.Forms.Keys.D7)) { Game.LocalPlayer.Character.CurrentVehicle.Rotation = new Rotator(45.0f, 0.0f, 0.0f); } else if (Game.IsKeyDown(System.Windows.Forms.Keys.D8)) { Game.LocalPlayer.Character.CurrentVehicle.Rotation = new Rotator(0.0f, 45.0f, 0.0f); } else if (Game.IsKeyDown(System.Windows.Forms.Keys.D9)) { Game.LocalPlayer.Character.CurrentVehicle.Rotation = new Rotator(0.0f, 0.0f, 45.0f); } else if (Game.IsKeyDown(System.Windows.Forms.Keys.D0)) { Game.LocalPlayer.Character.CurrentVehicle.Rotation = Rotator.Zero; } } #endif Update(); } }
public override void Process() { GameFiber.StartNew(delegate { if (_Seller.DistanceTo(Game.LocalPlayer.Character) < 20f) { if (_attack == true && _startedPursuit == false) { _pursuit = Functions.CreatePursuit(); Functions.AddPedToPursuit(_pursuit, _Seller); Functions.AddPedToPursuit(_pursuit, _Buyer); Functions.SetPursuitIsActiveForPlayer(_pursuit, true); _startedPursuit = true; } if (_Seller.DistanceTo(Game.LocalPlayer.Character) < 15f && Game.LocalPlayer.Character.IsOnFoot && _alreadySubtitleIntrod == false && _pursuit == null) { Game.DisplaySubtitle("Press ~y~Y ~w~to speak with the Seller", 5000); _Buyer.Face(_Car); _Seller.Face(Game.LocalPlayer.Character); Functions.PlayScannerAudio("ATTENTION_GENERIC_01 OFFICERS_ARRIVED_ON_SCENE"); _alreadySubtitleIntrod = true; _wasClose = true; } if (_attack == false && _Seller.DistanceTo(Game.LocalPlayer.Character) < 2f && Game.IsKeyDown(Settings.Dialog)) { _Seller.Face(Game.LocalPlayer.Character); switch (_storyLine) { case 1: Game.DisplaySubtitle("~y~Seller: ~w~Oh, hello officer, I didn't hear you. How can I help? (1/5)", 5000); _storyLine++; break; case 2: Game.DisplaySubtitle("~b~You: ~w~Are you the owner? (2/5)", 5000); _storyLine++; break; case 3: Game.DisplaySubtitle("~y~Suspect: ~w~Ah...yes I am the owner! Is anything wrong? (3/5)", 5000); _storyLine++; break; case 4: if (_callOutMessage == 1) { Game.DisplaySubtitle("~b~You: ~w~Is there a reason you have a police vehicle in your garage? (4/5)", 5000); } if (_callOutMessage == 2) { Game.DisplaySubtitle("~b~You: ~w~That's a police vehicle... what's going on here? (4/5)", 5000); } if (_callOutMessage == 3) { Game.DisplaySubtitle("~b~You: ~w~I couldn't help but notice that police vehicle. Care to explain? (4/5)", 5000); } _storyLine++; break; case 5: if (_callOutMessage == 1) { Game.DisplaySubtitle("~y~Suspect: ~w~Uh... Yes! It's here because... Ah, forget it. Do what you need to do. (5/5)", 5000); } Game.DisplayNotification("web_lossantospolicedept", "web_lossantospolicedept", "~w~UnitedCallouts", "~y~Dispatch Information", "The plate of the ~b~" + _Car.Model.Name + "~w~ is ~o~" + _Car.LicensePlate + "~w~. The car was ~r~stolen~w~ from the police station in ~b~Mission Row~w~."); Game.DisplayHelp("~y~Arrest the owner and the buyer.", 5000); if (_callOutMessage == 2) { Game.DisplaySubtitle("~y~Suspect: ~w~You weren't meant to see this! (5/5)", 5000); _Buyer.Inventory.GiveNewWeapon("WEAPON_PISTOL", 500, true); Rage.Native.NativeFunction.CallByName <uint>("TASK_COMBAT_PED", _Buyer, Game.LocalPlayer.Character, 0, 16); } if (_callOutMessage == 3) { Game.DisplaySubtitle("~y~Suspect: ~w~I could, but there's no point in talking to a corpse! (5/5)", 5000); _Seller.Inventory.GiveNewWeapon("WEAPON_KNIFE", 500, true); Rage.Native.NativeFunction.CallByName <uint>("TASK_COMBAT_PED", _Seller, Game.LocalPlayer.Character, 0, 16); Rage.Native.NativeFunction.CallByName <uint>("TASK_COMBAT_PED", _Buyer, Game.LocalPlayer.Character, 0, 16); } _storyLine++; break; default: break; } } } if (Game.LocalPlayer.Character.IsDead) { End(); } if (Game.IsKeyDown(Settings.EndCall)) { End(); } if (_Seller && _Seller.IsDead && _Buyer.Exists() && _Buyer.IsDead) { End(); } if (_Seller && Functions.IsPedArrested(_Seller) && _Buyer.Exists() && Functions.IsPedArrested(_Buyer)) { End(); } }, "CarTrade [UnitedCallouts]"); base.Process(); }
public void Manager() { if (Game.LocalPlayer.Character.IsInHelicopter) { if (_showHelpText) { Game.DisplayHelp("~g~Wilderness Callouts:~s~ Press ~b~" + Controls.ToggleHeliCam.ToUserFriendlyName() + "~s~ to activate the helicopter camera", 6500); _showHelpText = false; } if (Controls.ToggleHeliCam.IsJustPressed() && (Camera == null || !Camera.Exists())) { Camera = new Camera(true); Camera.SetRotationYaw(Game.LocalPlayer.Character.CurrentVehicle.Heading); Scaleform = new Scaleform(); Scaleform.Load("heli_cam"); NativeFunction.CallByName <uint>("REQUEST_STREAMED_TEXTURE_DICT", "helicopterhud", true); Scaleform.CallFunction("SET_CAM_LOGO", 1); Camera.AttachToEntity(Game.LocalPlayer.Character.CurrentVehicle, GetCameraPositionOffsetForModel(Game.LocalPlayer.Character.CurrentVehicle.Model), true); Sound.RequestAmbientAudioBank("SCRIPT\\POLICE_CHOPPER_CAM"); NativeFunction.CallByName <uint>("SET_NOISEOVERIDE", true); NativeFunction.CallByName <uint>("SET_NOISINESSOVERIDE", 0.15f); } else if ((Controls.ToggleHeliCam.IsJustPressed() || !Game.LocalPlayer.Character.IsInHelicopter || Game.LocalPlayer.Character.CurrentVehicle.IsDead || Game.LocalPlayer.Character.IsDead) && (Camera != null && Camera.Exists())) { NativeFunction.CallByName <uint>("SET_NOISEOVERIDE", false); NativeFunction.CallByName <uint>("SET_NOISINESSOVERIDE", 0.0f); Camera.Delete(); Camera = null; Scaleform = null; if (WildernessCallouts.Common.IsNightVisionActive()) { new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null); WildernessCallouts.Common.SetNightVision(false); } if (WildernessCallouts.Common.IsThermalVisionActive()) { new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null); WildernessCallouts.Common.SetThermalVision(false); } } if (Camera != null && Camera.Exists() && Scaleform != null) { if (BackgroundSound.HasFinished()) { BackgroundSound.PlayFrontend("COP_HELI_CAM_BACKGROUND", null); } NativeFunction.CallByName <uint>("HIDE_HUD_AND_RADAR_THIS_FRAME"); WildernessCallouts.Common.DisEnableGameControls(false, GameControl.Enter, GameControl.VehicleExit, GameControl.VehicleAim, GameControl.VehicleAttack, GameControl.VehicleAttack2, GameControl.VehicleDropProjectile, GameControl.VehicleDuck /*, GameControl.VehicleFlyAttack, GameControl.VehicleFlyAttack2*/, GameControl.VehicleFlyAttackCamera, GameControl.VehicleFlyDuck, GameControl.VehicleFlySelectNextWeapon, GameControl.VehicleFlySelectPrevWeapon, GameControl.VehicleHandbrake, GameControl.VehicleJump, GameControl.LookLeftRight, GameControl.LookUpDown, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext); float FOVpercentage = -((Camera.FOV - 70 /*max FOV*/)) / 35 /*min FOV*/; if (FOVpercentage > 1f) { FOVpercentage = 1f; } else if (FOVpercentage < 0f) { FOVpercentage = 0f; } Scaleform.CallFunction("SET_ALT_FOV_HEADING", Camera.Position.Z, FOVpercentage, Camera.Rotation.Yaw); WildernessCallouts.Common.DrawScaleformMovieFullscreen(Scaleform, Color.FromArgb(0, 255, 255, 255)); float moveSpeed = (Camera.FOV / 100) * (WildernessCallouts.Common.IsUsingController() ? 3.5f : 5.25f); //float upDown = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookUpDown) * moveSpeed; //float leftRight = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookLeftRight) * moveSpeed; //Camera.Rotation = new Rotator(Camera.Rotation.Pitch - upDown, Camera.Rotation.Roll, Camera.Rotation.Yaw - leftRight); float yRotMagnitude = NativeFunction.CallByName <float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookUpDown) * moveSpeed; float xRotMagnitude = NativeFunction.CallByName <float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookLeftRight) * moveSpeed; float newPitch = Camera.Rotation.Pitch - yRotMagnitude; float newYaw = Camera.Rotation.Yaw - xRotMagnitude; Camera.Rotation = new Rotator((newPitch >= 25f || newPitch <= -70f) ? Camera.Rotation.Pitch : newPitch, /*_cam.Rotation.Roll*/ 0f, newYaw); if (yRotMagnitude != 0f || xRotMagnitude != 0) { if (TurnSound.HasFinished()) { TurnSound.PlayFrontend("COP_HELI_CAM_TURN", null); } } else if (!TurnSound.HasFinished()) { TurnSound.Stop(); } //if (Camera.Rotation.Pitch <= -70f) Camera.SetRotationPitch(-69.99f); //else if (Camera.Rotation.Pitch >= 25f) Camera.SetRotationPitch(24.99f); if (!WildernessCallouts.Common.IsUsingController()) { WildernessCallouts.Common.DisEnableGameControls(false, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext); float wheelForwards = NativeFunction.CallByName <float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.WeaponWheelPrev) * 1.725f; float wheelBackwards = NativeFunction.CallByName <float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.WeaponWheelNext) * 1.725f; Camera.FOV -= wheelForwards - wheelBackwards; if (Camera.FOV > 70f) { Camera.FOV = 70f; } else if (Camera.FOV < 1f) { Camera.FOV = 1f; } } if (Game.IsControllerButtonDownRightNow(ControllerButtons.A) /* || Game.IsKeyDownRightNow(Keys.LShiftKey)*/) { if (ZoomSound.HasFinished()) { ZoomSound.PlayFrontend("COP_HELI_CAM_ZOOM", null); } WildernessCallouts.Common.DisEnableGameControls(false, GameControl.VehicleFlyThrottleUp, GameControl.VehicleFlyThrottleDown); float up = NativeFunction.CallByName <float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.VehicleFlyThrottleUp); float down = NativeFunction.CallByName <float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.VehicleFlyThrottleDown); Camera.FOV -= up - down; if (Camera.FOV > 70f) { Camera.FOV = 70f; } else if (Camera.FOV < 5f) { Camera.FOV = 5f; } } else { if (!ZoomSound.HasFinished()) { ZoomSound.Stop(); } } if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && !WildernessCallouts.Common.IsNightVisionActive() && !WildernessCallouts.Common.IsThermalVisionActive()) { new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_ON_MASTER", null); WildernessCallouts.Common.SetNightVision(true); } else if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && WildernessCallouts.Common.IsNightVisionActive()) { new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null); WildernessCallouts.Common.SetNightVision(false); } if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && !WildernessCallouts.Common.IsThermalVisionActive() && !WildernessCallouts.Common.IsNightVisionActive()) { new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_ON_MASTER", null); WildernessCallouts.Common.SetThermalVision(true); } else if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && WildernessCallouts.Common.IsThermalVisionActive()) { new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null); WildernessCallouts.Common.SetThermalVision(false); } #if DEBUG Game.DisplayHelp(Camera.Direction.ToString()); #endif Entity raycastedEntity = WildernessCallouts.Common.RaycastEntity2(Camera.Position, Camera.Direction, 2000.0f, Game.LocalPlayer.Character, Game.LocalPlayer.Character.CurrentVehicle); if (_searchCounter != 0) { SizeF res = RAGENativeUI.UIMenu.GetScreenResolutionMantainRatio(); new Sprite("helicopterhud", "hud_line", new Point(((int)res.Width / 2) - ((int)res.Width / 8) /*- ((int)res.Width / 32)*/, ((int)res.Height / 2) + ((int)res.Height / 4)), new Size(5 + _searchCounter * 2, 30)).Draw(); } if (raycastedEntity != null && raycastedEntity.Exists()) { if (Controls.HeliCamScan.IsPressed() && (raycastedEntity.IsPed() || raycastedEntity.IsVehicle())) { _searchCounter++; if (SearchLoopSound.HasFinished()) { SearchLoopSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_LOOP", null); } Vector2 v2 = World.ConvertWorldPositionToScreenPosition(raycastedEntity.Position); SizeF res = RAGENativeUI.UIMenu.GetScreenResolutionMantainRatio();//fix: work with all res new Sprite("helicopterhud", "hud_target", new Point((int)v2.X + (125 / (int)res.Width) /*- ((int)res.Width / 125)*/, (int)v2.Y + (125 / (int)res.Height) /*- ((int)res.Height / 125)*/), new Size(125, 125)).Draw(); if (_searchCounter > 240) { if (raycastedEntity.IsPed()) { //Game.DisplayNotification("Ped detected"); if (SearchSuccessSound.HasFinished()) { SearchSuccessSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_SUCCESS", null); } _canOverrideDrawInfo = true; GameFiber.StartNew(delegate { DrawPedInfo((Ped)raycastedEntity, 13000); }, "DrawPedInfo Fiber"); } else if (raycastedEntity.IsVehicle()) { //Game.DisplayNotification("Vehicle detected"); if (SearchSuccessSound.HasFinished()) { SearchSuccessSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_SUCCESS", null); } _canOverrideDrawInfo = true; GameFiber.StartNew(delegate { DrawVehicleInfo((Vehicle)raycastedEntity, 13000); }, "DrawVehicleInfo Fiber"); } if (!SearchLoopSound.HasFinished()) { SearchLoopSound.Stop(); } _searchCounter = 0; } } if (raycastedEntity.IsVehicle()) { DrawVehicleSpeed((Vehicle)raycastedEntity); } } else if (_searchCounter > 0) { _searchCounter--; } if (!SearchLoopSound.HasFinished()) { SearchLoopSound.Stop(); } } else { if (!BackgroundSound.HasFinished()) { BackgroundSound.Stop(); } if (!ZoomSound.HasFinished()) { ZoomSound.Stop(); } if (!TurnSound.HasFinished()) { TurnSound.Stop(); } if (!SearchLoopSound.HasFinished()) { SearchLoopSound.Stop(); } if (!SearchSuccessSound.HasFinished()) { SearchLoopSound.Stop(); } } } else if (!_showHelpText) { _showHelpText = true; } }
private void watchCCTVCameraFootage(MurderInvestigation owner) { // set up isCCTVCameraFootageActive = true; Game.FadeScreenOut(1750, true); List <Entity> invisibleEntities = new List <Entity>(); invisibleEntities.AddRange(World.GetEntities(scenario.VictimSpawnPoint.Position, 150.0f, GetEntitiesFlags.ConsiderAllVehicles | GetEntitiesFlags.ConsiderAllPeds)); Vector3[] invisibleEntitiesInitialPositions = new Vector3[invisibleEntities.Count]; for (int i = 0; i < invisibleEntities.Count; i++) { if (invisibleEntities[i].Exists()) { invisibleEntitiesInitialPositions[i] = invisibleEntities[i].Position; if (invisibleEntities[i] != victimPed && invisibleEntities[i] != murdererPed) { invisibleEntities[i].SetPositionZ(invisibleEntities[i].Position.X + 50.0f); } invisibleEntities[i].IsPositionFrozen = true; invisibleEntities[i].IsVisible = false; Ped asPed = invisibleEntities[i] as Ped; if (asPed.Exists()) { asPed.BlockPermanentEvents = true; } } } victimPedClone = victimPed.Clone(0.0f); NativeFunction.CallByName <uint>("REVIVE_INJURED_PED", victimPedClone); NativeFunction.CallByName <uint>("SET_ENTITY_HEALTH", victimPedClone, 200.0f); NativeFunction.CallByName <uint>("RESURRECT_PED", victimPedClone); victimPedClone.Tasks.ClearImmediately(); victimPedClone.Position = scenario.VictimFootageSpawnPoint.Position; victimPedClone.Heading = scenario.VictimFootageSpawnPoint.Heading; victimPedClone.ClearBlood(); victimPedClone.Tasks.ClearImmediately(); victimPedClone.CanPlayAmbientAnimations = true; murdererPedClone = murdererPed.Clone(0.0f); murdererPedClone.Position = scenario.MurdererFootageSpawnPoint.Position; murdererPedClone.Heading = scenario.MurdererFootageSpawnPoint.Heading; Game.LocalPlayer.Character.IsPositionFrozen = true; cctvObject.IsVisible = false; footageCamera = new Camera(true); footageCamera.FOV -= 20; footageCamera.Position = cctvObject.Position; footageCamera.PointAtEntity(victimPed, Vector3.Zero, true); NativeFunction.CallByName <uint>("SET_NOISEOVERIDE", true); NativeFunction.CallByName <uint>("SET_NOISINESSOVERIDE", 0.1f); victimPedClone.Health = 170; murdererPedClone.IsInvincible = true; victimPedClone.IsInvincible = false; DateTime initialTime = World.DateTime; World.DateTime = footageInitialDateTime; Logger.LogTrivial(cctvFootageVictimScenario.Item1 + " " + cctvFootageVictimScenario.Item2); Scenario.StartInPlace(victimPedClone, cctvFootageVictimScenario.Item1, cctvFootageVictimScenario.Item2); GameFiber.StartNew(delegate { while (isCCTVCameraFootageActive) { GameFiber.Yield(); NativeFunction.CallByName <uint>("HIDE_HUD_AND_RADAR_THIS_FRAME"); new ResRectangle(new Point(0, 0), new Size(245, 195), Color.FromArgb(145, Color.Gray)).Draw(); new ResText("CCTV #" + cctvCameraNumber + "~n~" + DateTime.UtcNow.ToShortDateString() + "~n~" + DateTime.UtcNow.ToLongTimeString(), new Point(5, 5), 0.747f).Draw(); } }); Game.FadeScreenIn(1750, true); // footage Task murdererMoveTask = murdererPedClone.Tasks.GoToOffsetFromEntity(victimPedClone, 1.1325f, 180.0f, 0.5f); NativeFunction.CallByName <uint>("SET_PED_STEALTH_MOVEMENT", murdererPedClone, 1, 0); murdererMoveTask.WaitForCompletion(); murdererPedClone.Inventory.GiveNewWeapon(WeaponHash.Knife, 1, true); victimPedClone.Tasks.Clear(); murdererPedClone.Tasks.FightAgainst(victimPedClone, -1).WaitForCompletion(); GameFiber.Sleep(1200); murdererPedClone.Inventory.Weapons.Remove(WeaponHash.Knife); murdererPedClone.Tasks.FollowNavigationMeshToPosition(scenario.MurdererSpawnPoint.Position, scenario.MurdererSpawnPoint.Heading, 2.0f, 5.0f, -1).WaitForCompletion(); murdererPedClone.Tasks.Wander(); GameFiber.Sleep(700); // clean up Game.FadeScreenOut(1750, true); NativeFunction.CallByName <uint>("SET_NOISEOVERIDE", false); NativeFunction.CallByName <uint>("SET_NOISINESSOVERIDE", 0.0f); footageCamera.Delete(); murdererPedClone.Delete(); victimPedClone.Delete(); Game.LocalPlayer.Character.IsPositionFrozen = false; cctvObject.IsVisible = true; for (int i = 0; i < invisibleEntities.Count; i++) { if (invisibleEntities[i].Exists()) { invisibleEntities[i].Position = invisibleEntitiesInitialPositions[i]; invisibleEntities[i].IsPositionFrozen = false; invisibleEntities[i].IsVisible = true; Ped asPed = invisibleEntities[i] as Ped; if (asPed.Exists()) { asPed.BlockPermanentEvents = false; } } } invisibleEntities.Clear(); invisibleEntities = null; invisibleEntitiesInitialPositions = null; World.DateTime = initialTime; isCCTVCameraFootageActive = false; if (!hasCCTVTextBeenAddedToReport) { owner.Report.AddTextToReport( @"[" + DateTime.UtcNow.ToShortDateString() + " " + DateTime.UtcNow.ToLongTimeString() + @"] CCTV Camera footage found. Shows suspect attacking victim with a knife and fleeing the crime scene. " + scenario.MurderDescription + ""); hasCCTVTextBeenAddedToReport = true; } Game.FadeScreenIn(2000, true); }
public void BuildFor(SerializableData.Objectives.SerializableActorObjective actor) { Clear(); #region SpawnAfter { var item = new MenuListItem("Spawn After Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region ObjectiveIndex { var item = new MenuListItem("Objective Index", StaticData.StaticLists.ObjectiveIndexList, actor.ActivateAfter); item.OnListChanged += (sender, index) => { actor.ActivateAfter = index; if (string.IsNullOrEmpty(Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter])) { MenuItems[4].SetRightBadge(NativeMenuItem.BadgeStyle.Alert); MenuItems[4].SetRightLabel(""); } else { var title = Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter]; MenuItems[4].SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); MenuItems[4].SetRightBadge(NativeMenuItem.BadgeStyle.None); } }; AddItem(item); } #endregion // TODO: Change NumberMenu to max num of objectives in mission // Note: if adding items before weapons, change item order in VehiclePropertiesMenu #region Weapons { var item = new NativeMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetPed().Handle.Value, true); actor.GetPed().GiveNewWeapon(hash, actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo, true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)actor.WeaponAmmo); var item = new MenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if (actor.WeaponHash == 0) { return; } NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetPed().Handle.Value, true); ((Ped)actor.GetPed()).GiveNewWeapon(actor.WeaponHash, newAmmo, true); }; AddItem(item); } #endregion #region Objective Name { var item = new NativeMenuItem("Objective Name"); if (string.IsNullOrEmpty(Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter])) { item.SetRightBadge(NativeMenuItem.BadgeStyle.Alert); } else { var title = Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter]; item.SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); } item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { ResetKey(Common.MenuControls.Back); Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); if (string.IsNullOrEmpty(title)) { item.SetRightBadge(NativeMenuItem.BadgeStyle.Alert); Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter] = ""; SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); Editor.DisableControlEnabling = false; return; } item.SetRightBadge(NativeMenuItem.BadgeStyle.None); title = Regex.Replace(title, "-=", "~"); Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter] = title; selectedItem.SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); }); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new MenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new MenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion #region Accuracy { var listIndex = StaticData.StaticLists.AccuracyList.FindIndex(n => n == (dynamic)actor.Accuracy); var item = new MenuListItem("Accuracy", StaticData.StaticLists.AccuracyList, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Accuracy = newAmmo; }; AddItem(item); } #endregion #region Relationship { var item = new MenuListItem("Relationship", StaticData.StaticLists.RelationshipGroups, actor.RelationshipGroup); item.OnListChanged += (sender, index) => { actor.RelationshipGroup = index; }; AddItem(item); } #endregion #region Behaviour { var wpyItem = new NativeMenuItem("Waypoints"); { var waypMenu = new WaypointEditor(actor); BindMenuToItem(waypMenu.CreateWaypointMenu, wpyItem); Vector3 camPos = new Vector3(); Rotator camRot = new Rotator(); wpyItem.Activated += (sender, selectedItem) => { camPos = Editor.MainCamera.Position; camRot = Editor.MainCamera.Rotation; waypMenu.Enter(); Editor.WaypointEditor = waypMenu; }; waypMenu.OnEditorExit += (sender, args) => { Editor.WaypointEditor = null; Editor.DisableControlEnabling = true; if (camPos != new Vector3()) { Editor.MainCamera.Position = camPos; Editor.MainCamera.Rotation = camRot; } }; } if (actor.Behaviour != 4) // Follow Waypoints { wpyItem.Enabled = false; } var item = new MenuListItem("Behaviour", StaticData.StaticLists.Behaviour, actor.Behaviour); item.OnListChanged += (sender, index) => { actor.Behaviour = index; wpyItem.Enabled = index == 4; }; AddItem(item); AddItem(wpyItem); } #endregion #region Show Health Bar { var item = new MenuCheckboxItem("Show Healthbar", actor.ShowHealthBar); AddItem(item); item.CheckboxEvent += (sender, @checked) => { actor.ShowHealthBar = @checked; MenuItems[12].Enabled = @checked; }; } #endregion #region Bar Name { var item = new NativeMenuItem("Healthbar Label"); AddItem(item); if (!actor.ShowHealthBar) { item.Enabled = false; } if (string.IsNullOrEmpty(actor.Name) && actor.ShowHealthBar) { actor.Name = "HEALTH"; } if (actor.ShowHealthBar) { item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); } item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { ResetKey(Common.MenuControls.Back); Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); if (string.IsNullOrEmpty(title)) { actor.Name = "HEALTH"; item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); Editor.DisableControlEnabling = false; return; } title = Regex.Replace(title, "-=", "~"); actor.Name = title; item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); }); }; } #endregion RefreshIndex(); }
public static void PedBackIntoVehicleLogic(Ped suspect, Vehicle suspectvehicle) { GameFiber.StartNew(delegate { try { while (true) { GameFiber.Yield(); if (!suspect.Exists() || !suspectvehicle.Exists()) { return; } else if (Functions.IsPedGettingArrested(suspect) || Functions.IsPedArrested(suspect) || suspect.IsDead) { return; } else if (Functions.IsPedStoppedByPlayer(suspect)) { while (Functions.IsPedStoppedByPlayer(suspect)) { GameFiber.Yield(); if (!suspect.Exists() || !suspectvehicle.Exists()) { return; } else if (Functions.IsPedGettingArrested(suspect) || Functions.IsPedArrested(suspect) || suspect.IsDead) { return; } } if (suspect.DistanceTo(suspectvehicle) < 25f) { suspect.IsPersistent = true; suspect.BlockPermanentEvents = true; suspectvehicle.IsPersistent = true; suspect.Tasks.FollowNavigationMeshToPosition(suspectvehicle.GetOffsetPosition(Vector3.RelativeLeft * 2f), suspectvehicle.Heading, 1.45f).WaitForCompletion(10000); if (suspectvehicle.GetFreeSeatIndex() != null) { int?freeseat = suspectvehicle.GetFreeSeatIndex(); suspect.Tasks.EnterVehicle(suspectvehicle, 6000, freeseat == null ? -1 : freeseat.Value).WaitForCompletion(6100); } } suspect.Dismiss(); suspectvehicle.Dismiss(); return; } } } catch (System.Threading.ThreadAbortException e) { } catch (Exception e) { Game.LogTrivial(e.ToString()); if (suspect.Exists()) { suspect.Dismiss(); } if (suspectvehicle) { suspectvehicle.Dismiss(); } } }); }
private static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index) { //if (sender == ChecksMenu) //{ // if (selectedItem == CheckCourtResultsItem) // { // sender.Visible = false; // CourtsMenu.Visible = true; // } //} if (sender == TrafficStopMenu) { if (selectedItem == SpeechItem) { string speech = SpeechItem.Collection[SpeechItem.Index].Value.ToString(); CurrentEnhancedTrafficStop.PlaySpecificSpeech(speech); } else if (selectedItem == IDItem) { //Ask for ID CurrentEnhancedTrafficStop.AskForID((EnhancedTrafficStop.OccupantSelector)IDItem.Index); } else if (selectedItem == QuestionDriverItem) { sender.Visible = false; UpdateTrafficStopQuestioning(); QuestioningMenu.Visible = true; } else if (selectedItem == PenaltyItem) { //Issue ticket(bind menu to item)? sender.Visible = false; //Menus.UpdateTicketReasons(); updatePenaltyType(IssueTicketItem.Index); TicketMenu.Visible = true; } else if (selectedItem == WarningItem) { //Let driver go CurrentEnhancedTrafficStop.IssueWarning(); _MenuPool.CloseAllMenus(); } else if (selectedItem == OutOfVehicleItem) { //Order driver out CurrentEnhancedTrafficStop.OutOfVehicle((EnhancedTrafficStop.OccupantSelector)OutOfVehicleItem.Index); _MenuPool.CloseAllMenus(); } } else if (sender == TicketMenu) { if (selectedItem == IssueTicketItem) { //Issue TOR bool SeizeVehicle = SeizeVehicleTicketCheckboxItem.Checked; if (Functions.IsPlayerPerformingPullover()) { CurrentEnhancedTrafficStop.IssueTicket(SeizeVehicle); } else { GameFiber.StartNew(delegate { EnhancedTrafficStop.performTicketAnimation(); }); } _MenuPool.CloseAllMenus(); } else if (selectedItem == TicketOffenceSelectorItem) { sender.Visible = false; OpenOffencesMenu(sender, CurrentEnhancedTrafficStop.SelectedOffences); } } else if (sender == QuestioningMenu) { if (selectedItem == IllegalInVehQuestionItem) { Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.AnythingIllegalInVehAnswer); } else if (selectedItem == DrinkingQuestionItem) { Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.DrinkingAnswer); } else if (selectedItem == DrugsQuestionItem) { Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.DrugsAnswer); } else if (selectedItem == SearchPermissionItem) { Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.SearchVehAnswer); } else if (CustomQuestionsItems.Contains(selectedItem)) { Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.CustomQuestionsWithAnswers[CustomQuestionsItems.IndexOf(selectedItem)].Item2); } else if (CustomQuestionsCallbacksAnswersItems.Contains(selectedItem)) { Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.CustomQuestionsWithCallbacksAnswers[CustomQuestionsCallbacksAnswersItems.IndexOf(selectedItem)].Item2(CurrentEnhancedTrafficStop.Suspect)); } else if (CustomQuestionsAnswersCallbackItems.Contains(selectedItem)) { string Text = CurrentEnhancedTrafficStop.CustomQuestionsAnswerWithCallbacks[CustomQuestionsAnswersCallbackItems.IndexOf(selectedItem)].Item2; Game.DisplaySubtitle("~h~" + Text); CurrentEnhancedTrafficStop.CustomQuestionsAnswerWithCallbacks[CustomQuestionsAnswersCallbackItems.IndexOf(selectedItem)].Item3(CurrentEnhancedTrafficStop.Suspect, Text); } } }
public static void dropSign(string selectedSign, bool swapHeading, Vector3 Location, float HeadingModifier) { GameFiber.StartNew(delegate { try { //string selectedCone = barriersToChooseFrom[EntryPoint.rnd.Next(barriersToChooseFrom.Length)]; //string selectedCone = "PROP_MP_ARROW_BARRIER_01"; if (TrafficPolicerHandler.IsLSPDFRPlusRunning) { API.LSPDFRPlusFunctions.AddCountToStatistic(Main.PluginName, "Road signs placed"); } Rage.Object trafficCone = new Rage.Object(selectedSign, Location); trafficCone.IsPersistent = true; trafficCone.IsInvincible = true; trafficCone.Rotation = RotationToPlaceAt; if (swapHeading) { trafficCone.Heading = Game.LocalPlayer.Character.Heading + 180f; } trafficCone.Heading += HeadingModifier; trafficCone.IsPositionFrozen = false; if (TrafficSignPreview.Exists()) { TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f); } int waitCount = 0; while (trafficCone.HeightAboveGround > 0.01f) { trafficCone.SetPositionZ(trafficCone.Position.Z - (trafficCone.HeightAboveGround * 0.75f)); waitCount++; if (waitCount >= 1000) { break; } } if (trafficCone.Exists()) { trafficCone.IsPositionFrozen = true; roadSignsDropped.Add(trafficCone); UInt32 handle = World.AddSpeedZone(trafficCone.Position, 5f, 5f); speedZones.Add(handle); Rage.Object invWall = new Rage.Object("p_ice_box_01_s", trafficCone.Position); invWall.IsPersistent = true; Ped invPed = new Ped(trafficCone.Position); invPed.MakeMissionPed(); invPed.IsVisible = false; invPed.IsPositionFrozen = true; invWall.Heading = Game.LocalPlayer.Character.Heading; invWall.IsVisible = false; RoadSignsWithInvisWallsAndPeds.Add(trafficCone, invWall, invPed); } } catch (Exception e) { Game.LogTrivial(e.ToString()); } }); }
private static void MainLogic() { GameFiber.StartNew(delegate { try { while (true) { GameFiber.Yield(); if (EnhancedPursuitAI.InPursuit && Game.LocalPlayer.Character.IsInAnyVehicle(false)) { if (ExtensionMethods.IsKeyCombinationDownComputerCheck(EnhancedPursuitAI.OpenPursuitTacticsMenuKey, EnhancedPursuitAI.OpenPursuitTacticsMenuModifierKey)) { PursuitTacticsMenu.Visible = !PursuitTacticsMenu.Visible; } } else { PursuitTacticsMenu.Visible = false; } if (Functions.IsPlayerPerformingPullover()) { if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != CurrentEnhancedTrafficStop.Suspect) { CurrentEnhancedTrafficStop = new EnhancedTrafficStop(); StatisticsCounter.AddCountToStatistic("Traffic Stops", "LSPDFR+"); Game.LogTrivial("Adding traffic stop count - LSPDFR+"); API.Functions.OnTrafficStopInitiated(Functions.GetPulloverSuspect(Functions.GetCurrentPullover())); } } //Shift Q ticket menu handler. else if (!_MenuPool.IsAnyMenuOpen() && !Game.LocalPlayer.Character.IsInAnyVehicle(false) && ExtensionMethods.IsKeyCombinationDownComputerCheck(Offence.OpenTicketMenuKey, Offence.OpenTicketMenuModifierKey) && Game.LocalPlayer.Character.GetNearbyPeds(1)[0].Exists() && Game.LocalPlayer.Character.DistanceTo(Game.LocalPlayer.Character.GetNearbyPeds(1)[0]) < 5f) { Game.LocalPlayer.Character.Tasks.ClearImmediately(); _MenuPool.ResetMenus(true, true); CurrentEnhancedTrafficStop.SelectedOffences.Clear(); SeizeVehicleTicketCheckboxItem.Enabled = false; TicketMenu.ParentMenu = null; foreach (UIMenu m in OffenceCategoryMenus) { m.Visible = false; } TicketMenu.Visible = true; } if (!LSPDFRPlusHandler.BritishPolicingScriptRunning && ExtensionMethods.IsKeyDownComputerCheck(CourtSystem.OpenCourtMenuKey) && (ExtensionMethods.IsKeyDownRightNowComputerCheck(CourtSystem.OpenCourtMenuModifierKey) || CourtSystem.OpenCourtMenuModifierKey == Keys.None)) { if (!CourtsMenu.Visible) { CourtsMenu.Visible = true; } } if (_MenuPool.IsAnyMenuOpen()) { NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0); } //Prevent the traffic stop menu from being used when it shouldn't be. if (TrafficStopMenu.Visible) { if (!Functions.IsPlayerPerformingPullover()) { if (TrafficStopMenuEnabled) { ToggleUIMenuEnabled(TrafficStopMenu, false); TrafficStopMenuEnabled = false; } } else if (Vector3.Distance2D(Game.LocalPlayer.Character.Position, Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).Position) > TrafficStopMenuDistance) { if (TrafficStopMenuEnabled) { ToggleUIMenuEnabled(TrafficStopMenu, false); TrafficStopMenuEnabled = false; } } else if (!TrafficStopMenuEnabled) { ToggleUIMenuEnabled(TrafficStopMenu, true); TrafficStopMenuEnabled = true; } } if (CourtsMenu.Visible) { if (!CourtsMenuPaused) { CourtsMenuPaused = true; Game.IsPaused = true; } if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Delete)) { if (PendingResultsList.Active) { if (CourtCase.PendingResultsMenuCleared) { CourtSystem.DeleteCourtCase(CourtSystem.PendingCourtCases[PendingResultsList.Index]); PendingResultsList.Index = 0; } } else if (PublishedResultsList.Active) { if (CourtCase.ResultsMenuCleared) { CourtSystem.DeleteCourtCase(CourtSystem.PublishedCourtCases[PublishedResultsList.Index]); PublishedResultsList.Index = 0; } } } if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Insert)) { if (PendingResultsList.Active) { if (CourtCase.PendingResultsMenuCleared) { CourtSystem.PendingCourtCases[PendingResultsList.Index].ResultsPublishTime = DateTime.Now; PendingResultsList.Index = 0; } } } } else if (CourtsMenuPaused) { CourtsMenuPaused = false; Game.IsPaused = false; } } } catch (System.Threading.ThreadAbortException e) { } catch (Exception e) { Game.LogTrivial(e.ToString()); } }); }
private static void handleEditMode() { GameFiber.Wait(200); ExtensionMethods.DisplayPopupTextBoxWithConfirmation("Police SmartRadio", "Edit mode is now active. w,a,s,d - Move. q,e - Scale. Press LCtrl LShift Z again to save and deactivate edit mode. Press Escape to discard.", false); while (true) { GameFiber.Yield(); Game.DisplayHelp("Police SmartRadio-Edit Mode Active. LCtrl LShift Z to save. Escape to discard."); Game.LocalPlayer.HasControl = false; RadioShowing = true; CurrentButtonIndex = 0; CurrentPageIndex = 0; if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.W)) { BaseY -= 1; cascadeCurrentButtonPages(); GameFiber.Sleep(30); } else if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.S)) { BaseY += 1; cascadeCurrentButtonPages(); GameFiber.Sleep(30); } else if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.A)) { BaseX -= 1; cascadeCurrentButtonPages(); GameFiber.Sleep(30); } else if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.D)) { BaseX += 1; cascadeCurrentButtonPages(); GameFiber.Sleep(30); } else if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Q)) { MasterScalingFactor += 0.005f; RadioBackgroundTextureWidth = RadioBackgroundTexture.Size.Width * MasterScalingFactor; RadioBackgroundTextureHeight = RadioBackgroundTexture.Size.Height * MasterScalingFactor; cascadeCurrentButtonPages(); GameFiber.Sleep(30); } else if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.E)) { MasterScalingFactor -= 0.005f; RadioBackgroundTextureWidth = RadioBackgroundTexture.Size.Width * MasterScalingFactor; RadioBackgroundTextureHeight = RadioBackgroundTexture.Size.Height * MasterScalingFactor; if (MasterScalingFactor < 0) { MasterScalingFactor = 0; } cascadeCurrentButtonPages(); GameFiber.Sleep(30); } if (ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LControlKey) && ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.LShiftKey) && ExtensionMethods.IsKeyDownRightNowComputerCheck(Keys.Z)) { DisplayIni.Write("DisplaySpecificPositioning", "X", BaseX); DisplayIni.Write("DisplaySpecificPositioning", "Y", BaseY); DisplayIni.Write("DisplayConfig", "DisplayScalingFactor", MasterScalingFactor); Game.DisplayHelp("Police Radio Edit Mode Deactivated - Changes saved to config files."); break; } if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Escape)) { SetupBackgroundSettings(); RadioBackgroundTextureWidth = RadioBackgroundTexture.Size.Width * MasterScalingFactor; RadioBackgroundTextureHeight = RadioBackgroundTexture.Size.Height * MasterScalingFactor; cascadeCurrentButtonPages(); Game.DisplayHelp("Police Radio Edit Mode Deactivated - Changes discarded."); break; } } GameFiber.Wait(200); Game.LocalPlayer.HasControl = true; }
public static void MakePedFollowPlayer() { Blip PedBlip; GameFiber.StartNew(delegate { pedfollowing = GetNearestValidPed(); if (!pedfollowing) { return; } PedBlip = pedfollowing.AttachBlip(); PedBlip.Color = System.Drawing.Color.Yellow; PedBlip.Flash(400, -1); EnableFollow = true; FollowItem.Text = "Stop follow"; CallTaxiItem.Enabled = false; GrabItem.Enabled = false; if (TransportToHospitalItem != null) { TransportToHospitalItem.Enabled = false; } if (EntryPoint.IsLSPDFRPlusRunning) { API.LSPDFRPlusFuncs.AddCountToStatistic(Main.PluginName, "People made to follow you"); } while (pedfollowing.Exists()) { GameFiber.Yield(); if (!pedfollowing.Exists()) { break; } if (EnableFollow) { if (Vector3.Distance(Game.LocalPlayer.Character.Position, pedfollowing.Position) > 2.3f) { FollowTask = pedfollowing.Tasks.FollowNavigationMeshToPosition(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeBack * 1.5f), pedfollowing.Heading, 1.6f); FollowTask.WaitForCompletion(600); } } else { break; } } if (pedfollowing.Exists()) { pedfollowing.Tasks.StandStill(7000); } EnableFollow = false; FollowItem.Text = "Follow"; if (PedBlip.Exists()) { PedBlip.Delete(); } CallTaxiItem.Enabled = true; GrabItem.Enabled = true; if (TransportToHospitalItem != null) { TransportToHospitalItem.Enabled = true; } }); }
public BigMessageThread(bool loadInstance) { MessageInstance = new BigMessageHandler(loadInstance); Fiber = GameFiber.StartNew(() => { while (true) { GameFiber.Yield(); MessageInstance.Update(); } }); }
//private bool breakForceEnd = false; /// <summary> /// OnBeforeCalloutDisplayed is where we create a blip for the user to see where the pursuit is happening, we initiliaize any variables above and set /// the callout message and position for the API to display /// </summary> /// <returns></returns> public override bool OnBeforeCalloutDisplayed() { //Set our spawn point to be on a street around 300f (distance) away from the player. spawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.AroundPosition(800f)); if (Vector3.Distance(Game.LocalPlayer.Character.Position, spawnPoint) < 115.0f) { return(false); } //Create the vehicle for our ped crash = new Rage.Object(crashVehModel.GetRandomElement(), spawnPoint); //Create our ped in the world dead = new Ped(pilotModel.GetRandomElement(), crash.Position.AroundPosition(5.0f), 0f); if (dead.Exists()) { dead.IsRagdoll = true; } GameFiber.Wait(500); if (dead.Exists()) { dead.Kill(); } //Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it) if (!dead.Exists()) { return(false); } if (!crash.Exists()) { return(false); } GameFiber.StartNew(delegate { GameFiber.Sleep(MathHelper.GetRandomInteger(500, 12501)); if (crash.Exists()) { int rndFarExplosion = MathHelper.GetRandomInteger(101); if (rndFarExplosion < 80) { World.SpawnExplosion(crash.Position.AroundPosition(5.0f), 5, 10.0f, true, false, MathHelper.GetRandomSingle(0.0f, 4.0f)); } } }); // Show the user where the pursuit is about to happen and block very close peds. this.ShowCalloutAreaBlipBeforeAccepting(spawnPoint, 25f); this.AddMinimumDistanceCheck(5f, dead.Position); // Set up our callout message and location this.CalloutMessage = "Aircraft crash"; this.CalloutPosition = spawnPoint; Functions.PlayScannerAudioUsingPosition("ATTENTION_ALL_UNITS ASSISTANCE_REQUIRED CRIME_AIRCRAFT_CRASH IN_OR_ON_POSITION UNITS_RESPOND_CODE_99", spawnPoint); return(base.OnBeforeCalloutDisplayed()); }