diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index a9ef955e6e..2b820adbdf 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -1790,6 +1790,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) @@ -1964,6 +1971,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; } @@ -2721,6 +2733,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) { @@ -7112,7 +7127,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 6f2ba652fb..f74671ec01 100644 --- a/Client/mods/deathmatch/logic/CClientPed.h +++ b/Client/mods/deathmatch/logic/CClientPed.h @@ -789,6 +789,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;