public static void MainMenuOnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index) { GameFiber.StartNew(delegate { if (selectedItem == AskFishingLicenseItem || selectedItem == AskHuntingLicenseItem) { Ped closestPed = World.GetAllPeds().Where(x => x.IsAlive && x != Game.LocalPlayer.Character && x.IsHuman && !x.IsInAnyVehicle(false) && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 12.5f).OrderBy(x => x.Position.DistanceTo(Game.LocalPlayer.Character.Position)).FirstOrDefault(); if (closestPed.Exists()) { closestPed.Tasks.AchieveHeading(closestPed.GetHeadingTowards(Game.LocalPlayer.Character)).WaitForCompletion(2000); Object id = new Object("hei_prop_hei_id_bank", Vector3.Zero); closestPed.Tasks.PlayAnimation("mp_common", "givetake1_a", 2.5f, AnimationFlags.None); id.AttachToEntity(closestPed, closestPed.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, new Rotator(0.0f, 180.0f, 0.0f)); GameFiber.Sleep(1200); if (selectedItem == AskFishingLicenseItem) { WildernessCallouts.Common.FishingLicense(closestPed); } else if (selectedItem == AskHuntingLicenseItem) { WildernessCallouts.Common.HuntingLicense(closestPed); } id.Delete(); StaticPeds.Add(closestPed); } } else if (selectedItem == CallAirAmbulanceItem) { Ped pedToRescue = WildernessCallouts.Common.GetPedToRescue(); AirParamedic airpara = new AirParamedic(pedToRescue, "You can leave, we will take care of him, thanks", "You can leave, we will take care of her, thanks"); airpara.Start(); } else if (selectedItem == CallVetItem) { Ped animal = WildernessCallouts.Common.GetValidAnimalForVetPickup(); Vet vet = new Vet(animal); vet.Start(); } #if DEBUG else if (selectedItem == CreateEventItem) { EventPool.CreateEvent(); } #endif }); }
/// <summary> /// Try to call the air paramedic. /// </summary> public void CallAirParamedic() { GameFiber.StartNew(() => { try { Ped pedToRescue = WildernessCallouts.Common.GetPedToRescue(); AirParamedic airParamedic = new AirParamedic(pedToRescue); airParamedic.Start(); } catch (Exception e) { Logger.LogException(e); Game.DisplayNotification("Unable to call the vet at this time. See RagePluginHook.log for details."); } }, "CallAirParamedic"); }
public static void MainMenuOnItemSelected(UIMenu sender, UIMenuItem selectedItem, int index) { GameFiber.StartNew(delegate { if (selectedItem == AskFishingLicenseItem || selectedItem == AskHuntingLicenseItem) { Ped closestPed = World.GetAllPeds().Where(x => x.IsAlive && x != Game.LocalPlayer.Character && x.IsHuman && !x.IsInAnyVehicle(false) && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 12.5f).OrderBy(x => x.Position.DistanceTo(Game.LocalPlayer.Character.Position)).FirstOrDefault(); if (closestPed.Exists()) { closestPed.Tasks.AchieveHeading(closestPed.GetHeadingTowards(Game.LocalPlayer.Character)).WaitForCompletion(2000); Object id = new Object("hei_prop_hei_id_bank", Vector3.Zero); closestPed.Tasks.PlayAnimation("mp_common", "givetake1_a", 2.5f, AnimationFlags.None); id.AttachToEntity(closestPed, closestPed.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, new Rotator(0.0f, 180.0f, 0.0f)); GameFiber.Sleep(1200); if (selectedItem == AskFishingLicenseItem) { WildernessCallouts.Common.FishingLicense(closestPed); } else if (selectedItem == AskHuntingLicenseItem) { WildernessCallouts.Common.HuntingLicense(closestPed); } id.Delete(); StaticPeds.Add(closestPed); } } else if (selectedItem == CallAirAmbulanceItem) { Ped pedToRescue = World.GetAllPeds().Where(x => (x.IsDead || x.Health <= 20 || x == MissingPerson.CurrentMissingPed) && x != Game.LocalPlayer.Character && x.IsHuman && Vector3.Distance(x.Position, Game.LocalPlayer.Character.Position) < 15.0f && !AirParamedic.RescuedPeds.Contains(x)).OrderBy(x => x.Position.DistanceTo(Game.LocalPlayer.Character.Position)).FirstOrDefault(); AirParamedic airpara = new AirParamedic(pedToRescue, "You can leave, we will take care of him, thanks", "You can leave, we will take care of her, thanks"); airpara.Start(); } else if (selectedItem == CallVetItem) { Ped animal = WildernessCallouts.Common.GetClosestAnimal(Game.LocalPlayer.Character.Position, 30.0f); int timesToLoop = 0; while (timesToLoop < 20) { if (animal.Exists() && animal.IsDead && !Vet.TakenAnimals.Contains(animal)) { break; } animal = WildernessCallouts.Common.GetClosestAnimal(Game.LocalPlayer.Character.Position, 35.0f); timesToLoop++; } // Gets the closest dead animal if (!animal.Exists() || animal.IsAlive || Vet.TakenAnimals.Contains(animal)) { return; } Vet vet = new Vet(animal); vet.Start(); } #if DEBUG else if (selectedItem == CreateEventItem) { EventPool.CreateEvent(); } #endif }); }