public override bool OnCalloutAccepted() { karen = new Ped(spawnPoint); if (!karen.Exists()) { return(false); } karenBlip = karen.AttachBlip(); phone = new Rage.Object("prop_npc_phone", Vector3.Zero); if (phone.Exists()) { phone.AttachTo(karen, karen.GetBoneIndex(PedBoneId.LeftHand), new Vector3(0.1490f, 0.0560f, -0.0100f), new Rotator(-17f, -142f, -151f)); } karen.Tasks.PlayAnimation("cellphone@", "cellphone_photo_idle", 1.3f, AnimationFlags.Loop | AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask); karen.BlockPermanentEvents = true; //Ped[] nearbyPeds = karen.GetNearbyPeds(5); //Ped storeClerk = nearbyPeds.OrderBy(x => x.Position.DistanceTo(karen.Position)).FirstOrDefault(); //karen.Tasks.AchieveHeading(MathHelper.ConvertDirectionToHeading(storeClerk.Direction - karen.Direction)); Game.DisplaySubtitle("A gas station ~o~attendant~w~ reports a ~r~customer~w~ yelling in the store and refusing to leave", 10000); return(base.OnCalloutAccepted()); }
private void CheckForDeliverTicketTrigger() { if (!Globals.HasTrafficTicketsInHand() && (ShouldEndPullover.HasValue && ShouldEndPullover.Value) && !Game.LocalPlayer.Character.HasScenario()) { ShouldEndPullover = null; GameFiber.StartNew(() => { if (Game.LocalPlayer.LastVehicle && !Game.LocalPlayer.LastVehicle.HasDriver) { Game.DisplayNotification("The driver will wait until you are back in your vehicle before taking off"); } while (Game.LocalPlayer.LastVehicle && !Game.LocalPlayer.LastVehicle.HasDriver) { GameFiber.Yield(); //Wait for the player to enter their vehicle } Function.Log("Starting Ending pull over wait timer for ped to leave"); var stopAt = DateTime.Now.AddMilliseconds(5000); //have the sadPed drive off in 5 seconds if the traffic stop isnt over while (DateTime.Now < stopAt) { GameFiber.Yield(); } try { lock (mPromptedCitations) mPromptedCitations.Clear(); var handle = Functions.GetCurrentPullover(); if (handle != null) { Functions.ForceEndCurrentPullover(); } } catch (Exception e) { Function.LogCatch(e.Message); } }); } else if (Globals.HasTrafficTicketsInHand() && !Game.LocalPlayer.Character.HasScenario()) //only run when we have tickets and we're not already doing WORLD_HUMAN_CLIPBOARD { var stopped = World.GetEntities(Game.LocalPlayer.Character.Position, 2.5f, GetEntitiesFlags.ConsiderAllPeds); if (stopped != null && stopped.Count() > 0) { var pedsAboutToGetTheSmackDown = stopped.Select(x => x as Ped) .Where(x => x.DistanceTo(Game.LocalPlayer.Character.FrontPosition) < 2f && Globals.GetTrafficCitationsInHandForPed(x) != null); //may have to add ordering by distance foreach (var sadPed in pedsAboutToGetTheSmackDown) { if (Configs.GiveTicketsToPed.Any(x => x.IsPressed)) { //The user wants to give the sad ped the ticket now.. GameFiber.StartNew(() => { var item = new Rage.Object(new Model("prop_cs_documents_01"), Game.LocalPlayer.Character.Position); item.AttachTo(Game.LocalPlayer.Character, Game.LocalPlayer.Character.GetBoneIndex(PedBoneId.RightThumb1), new Vector3(item.Model.Dimensions.Length() * 0.4f, 0, 0), Rotator.Zero); Game.LocalPlayer.Character.Tasks.PlayAnimation("mp_common", "givetake1_b", 3f, AnimationFlags.None).WaitForCompletion(); item.Detach(); item.Delete(); }); ShouldEndPullover = true; Globals.RemoveTrafficCitationsInHandForPed(sadPed); break; } else { //Prompt the user that they can deliver the ticket OnFacingPedWithPendingTickets(null, sadPed, Globals.GetTrafficCitationsInHandForPed(sadPed)); } } } } else if (Functions.GetCurrentPullover() == null && Globals.HasTrafficTicketsInHand()) { Globals.ClearTrafficCitationsInHand(); return; } }