diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 85c5e0d51e7..180003205ee 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -1783,6 +1783,13 @@ void CClientPed::InternalSetHealth(float fHealth) WarpIntoVehicle(pVehicle, uiVehicleSeat); } } + else if (m_pPlayerPed->GetHealth() > 0.0f && fHealth <= 0.0f) + { + // Remove from vehicle in MTA scope + // Fix issue GH #4017 + m_vehicleWithoutPairAllowed = true; + CClientVehicle::UnpairPedAndVehicle(this); + } // Recheck we have a ped, ReCreateModel might destroy it if (m_pPlayerPed) @@ -1957,6 +1964,11 @@ void CClientPed::Kill(eWeaponType weaponType, unsigned char ucBodypart, bool bSt if (IsWearingGoggles()) SetWearingGoggles(false, false); + // Remove from vehicle in MTA scope + // Fix issue GH #4017 + m_vehicleWithoutPairAllowed = true; + CClientVehicle::UnpairPedAndVehicle(this); + m_bDead = true; } @@ -2714,6 +2726,9 @@ void CClientPed::StreamedInPulse(bool bDoStandardPulses) // Grab some vars here, saves getting them twice CClientVehicle* pVehicle = GetOccupiedVehicle(); + if (m_vehicleWithoutPairAllowed && (IsDead() || !GetRealOccupiedVehicle())) + m_vehicleWithoutPairAllowed = false; + // Do we have a player? (streamed in) if (m_pPlayerPed) { @@ -7081,7 +7096,7 @@ void CClientPed::UpdateVehicleInOut() // Jax: this was commented, re-comment if it was there for a reason (..and give the reason!) // Are we in a vehicle we aren't supposed to be in? - if (pVehicle && !pOccupiedVehicle) + if (pVehicle && !pOccupiedVehicle && !m_vehicleWithoutPairAllowed) { g_pCore->GetConsole()->Print("You shouldn't be in this vehicle"); RemoveFromVehicle(); diff --git a/Client/mods/deathmatch/logic/CClientPed.h b/Client/mods/deathmatch/logic/CClientPed.h index 65d84a0a4a6..38263be8723 100644 --- a/Client/mods/deathmatch/logic/CClientPed.h +++ b/Client/mods/deathmatch/logic/CClientPed.h @@ -787,6 +787,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule bool m_bNoNewVehicleTask; // When set, we are not allowed to initiate a new enter/exit task because we are waiting for server reply ElementID m_NoNewVehicleTaskReasonID; // ElementID of the vehicle that we are waiting on CClientPed* m_pGettingJackedBy; // The ped that is jacking us + bool m_vehicleWithoutPairAllowed{false}; // Means that a ped can be in a vehicle (temporarily) without being paired with it. This is used in CClientPed::Kill and SetInternalHealth std::shared_ptr m_clientModel;