Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
42 changes: 38 additions & 4 deletions FivePRS.Client/Arrest/ArrestManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CitizenFX.Core;
using CitizenFX.Core.Native;
Expand All @@ -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<int> _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;
Expand Down Expand Up @@ -59,6 +64,14 @@ public static async Task<bool> 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)
{
Expand All @@ -73,17 +86,31 @@ public static async Task<bool> 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,
Expand Down Expand Up @@ -164,10 +191,17 @@ public static async Task<bool> EscortToVehicleAsync(Vehicle vehicle)
return false;
}

var seat = RearSeats.Where(s => API.IsVehicleSeatFree(vehicle.Handle, s)).Cast<int?>().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);
Expand Down
5 changes: 5 additions & 0 deletions FivePRS.Client/Arrest/ArrestTick.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using FivePRS.Core.Events;

namespace FivePRS.Client.Arrest
{
Expand All @@ -20,6 +21,10 @@ public class ArrestTick : BaseScript
public ArrestTick()
{
Tick += OnTickAsync;
EventHandlers[EventNames.LocalDutyChanged] += new System.Action<bool, int>((onDuty, _) =>
{
if (!onDuty && ArrestManager.HasCustody) ArrestManager.Uncuff();
});
}

private async Task OnTickAsync()
Expand Down
6 changes: 6 additions & 0 deletions FivePRS.Client/Callouts/CalloutBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 9 additions & 3 deletions FivePRS.EMS/PatientCare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<int?>().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);
Expand Down
Loading