diff --git a/CHANGELOG.md b/CHANGELOG.md index 817724d..aca885c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +## [0.9.0-ptb.7] - 2026-11-28 + +### Fixed +- Cuffing someone no longer leaves you stuck facing them, able to turn but not walk. The same fix applies when treating a patient as EMS. Thanks to gunboatrebel for the report +- Escorting a suspect into a vehicle uses a free rear seat, and says when both are taken, instead of always using the left rear seat even when someone is sitting there +- Loading a patient no longer puts them in the front passenger seat when the rear seats are full. EMS is told there's no free seat instead +- Going off duty with a suspect in custody releases them, instead of leaving them cuffed and following you +- People at a callout scene go back to normal when the call ends, instead of standing frozen in place +- Pressing the cuff key again during the cuff animation no longer starts a second cuff, and you can't cuff from inside a vehicle + ## [0.9.0-ptb.6] - 2026-11-28 ### Added @@ -175,7 +185,8 @@ The first public test build. - Only Mission Row has armory, locker room and garage points - Back up your database before updating between test builds -[Unreleased]: https://github.com/FivePRS/core/compare/v0.9.0-ptb.6...HEAD +[Unreleased]: https://github.com/FivePRS/core/compare/v0.9.0-ptb.7...HEAD +[0.9.0-ptb.7]: https://github.com/FivePRS/core/compare/v0.9.0-ptb.6...v0.9.0-ptb.7 [0.9.0-ptb.6]: https://github.com/FivePRS/core/compare/v0.9.0-ptb.5...v0.9.0-ptb.6 [0.9.0-ptb.5]: https://github.com/FivePRS/core/compare/v0.9.0-ptb.4...v0.9.0-ptb.5 [0.9.0-ptb.4]: https://github.com/FivePRS/core/compare/v0.9.0-ptb.3...v0.9.0-ptb.4 diff --git a/FivePRS.Client/Arrest/ArrestManager.cs b/FivePRS.Client/Arrest/ArrestManager.cs index 2573b9d..5c23145 100644 --- a/FivePRS.Client/Arrest/ArrestManager.cs +++ b/FivePRS.Client/Arrest/ArrestManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using CitizenFX.Core; using CitizenFX.Core.Native; @@ -23,12 +24,16 @@ public static class ArrestManager public const float EscortRangeM = 5.0f; public const float BookRangeM = 5.0f; + private const int TurnMs = 1_000; + private const string CuffAnimDict = "mp_arresting"; private const string CuffAnimClip = "idle"; private const string OfficerAnimDict = "mp_arresting"; private const string OfficerAnimClip = "a_uncuff"; private static readonly HashSet _registeredSuspects = new(); + private static readonly int[] RearSeats = { (int)VehicleSeat.LeftRear, (int)VehicleSeat.RightRear }; + private static bool _cuffing; public static Ped? CuffedPed { get; private set; } public static ArrestState State { get; private set; } = ArrestState.None; @@ -59,6 +64,14 @@ public static async Task TryCuffNearestAsync() return false; } + if (_cuffing) return false; + + if (Game.PlayerPed.IsInVehicle()) + { + ClientBrain.ShowNotification("~r~Get out of the vehicle to cuff a suspect."); + return false; + } + var suspect = FindNearestRegisteredSuspect(); if (suspect is null) { @@ -73,17 +86,31 @@ public static async Task TryCuffNearestAsync() public static async Task CuffPedAsync(Ped suspect) { - if (suspect is null || !suspect.Exists() || HasCustody) return; + if (suspect is null || !suspect.Exists() || HasCustody || _cuffing) return; await ExecuteCuffSequenceAsync(suspect); } private static async Task ExecuteCuffSequenceAsync(Ped suspect) + { + _cuffing = true; + try + { + await CuffSequenceAsync(suspect); + } + finally + { + _cuffing = false; + } + } + + private static async Task CuffSequenceAsync(Ped suspect) { var player = Game.PlayerPed; - player.Task.TurnTo(suspect); - suspect.Task.TurnTo(player); + player.Task.TurnTo(suspect, TurnMs); + suspect.Task.TurnTo(player, TurnMs); await BaseScript.Delay(400); + player.Task.ClearAll(); await LoadAnimDictAsync(OfficerAnimDict); await player.Task.PlayAnimation(OfficerAnimDict, OfficerAnimClip, @@ -164,10 +191,17 @@ public static async Task EscortToVehicleAsync(Vehicle vehicle) return false; } + var seat = RearSeats.Where(s => API.IsVehicleSeatFree(vehicle.Handle, s)).Cast().FirstOrDefault(); + if (seat is null) + { + ClientBrain.ShowNotification("~r~No free rear seat~w~ in this vehicle."); + return false; + } + var suspect = CuffedPed; suspect.Task.ClearAll(); - API.TaskWarpPedIntoVehicle(suspect.Handle, vehicle.Handle, (int)VehicleSeat.LeftRear); + API.TaskWarpPedIntoVehicle(suspect.Handle, vehicle.Handle, seat.Value); await BaseScript.Delay(500); await ApplyCuffedAnimationAsync(suspect); diff --git a/FivePRS.Client/Arrest/ArrestTick.cs b/FivePRS.Client/Arrest/ArrestTick.cs index 8a829d9..7d34711 100644 --- a/FivePRS.Client/Arrest/ArrestTick.cs +++ b/FivePRS.Client/Arrest/ArrestTick.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using CitizenFX.Core; using CitizenFX.Core.Native; +using FivePRS.Core.Events; namespace FivePRS.Client.Arrest { @@ -20,6 +21,10 @@ public class ArrestTick : BaseScript public ArrestTick() { Tick += OnTickAsync; + EventHandlers[EventNames.LocalDutyChanged] += new System.Action((onDuty, _) => + { + if (!onDuty && ArrestManager.HasCustody) ArrestManager.Uncuff(); + }); } private async Task OnTickAsync() diff --git a/FivePRS.Client/Callouts/CalloutBase.cs b/FivePRS.Client/Callouts/CalloutBase.cs index d3f5ab6..6cc9379 100644 --- a/FivePRS.Client/Callouts/CalloutBase.cs +++ b/FivePRS.Client/Callouts/CalloutBase.cs @@ -239,6 +239,12 @@ internal void Cleanup(bool releaseToWorld = false) if (releaseToWorld) { + if (entity is Ped released && !released.IsDead) + { + released.BlockPermanentEvents = false; + if (!released.IsInVehicle()) API.ClearPedTasks(released.Handle); + } + var handle = entity.Handle; API.SetEntityAsNoLongerNeeded(ref handle); } diff --git a/FivePRS.EMS/PatientCare.cs b/FivePRS.EMS/PatientCare.cs index 78ac314..d4b1aa5 100644 --- a/FivePRS.EMS/PatientCare.cs +++ b/FivePRS.EMS/PatientCare.cs @@ -106,7 +106,7 @@ private bool TryInteract() private async Task TreatAsync() { Stage = PatientStage.Treating; - Game.PlayerPed.Task.TurnTo(_patient); + Game.PlayerPed.Task.TurnTo(_patient, 1_000); var treated = await Treatment.RunAsync(() => _patient.Exists() ? _patient.Position : (Vector3?)null, TreatMs, "Treating the patient"); if (!treated) @@ -123,9 +123,15 @@ private async Task TreatAsync() private void Load(Vehicle vehicle) { - var seat = RearSeats.FirstOrDefault(s => API.IsVehicleSeatFree(vehicle.Handle, s)); + var seat = RearSeats.Where(s => API.IsVehicleSeatFree(vehicle.Handle, s)).Cast().FirstOrDefault(); + if (seat is null) + { + ClientBrain.ShowNotification("~r~No free seat~w~ for the patient in this vehicle.", "~b~EMS"); + return; + } + _patient.Task.ClearAll(); - API.TaskWarpPedIntoVehicle(_patient.Handle, vehicle.Handle, seat); + API.TaskWarpPedIntoVehicle(_patient.Handle, vehicle.Handle, seat.Value); _transport = vehicle; _hospital = Hospitals.Nearest(vehicle.Position);