Skip to content

Commit 710fb36

Browse files
committed
Fix bug
1 parent 839f328 commit 710fb36

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Client/mods/deathmatch/logic/CClientPed.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,13 @@ void CClientPed::InternalSetHealth(float fHealth)
17831783
WarpIntoVehicle(pVehicle, uiVehicleSeat);
17841784
}
17851785
}
1786+
else if (m_pPlayerPed->GetHealth() > 0.0f && fHealth <= 0.0f)
1787+
{
1788+
// Remove from vehicle in MTA scope
1789+
// Fix issue GH #4017
1790+
m_vehicleWithoutPairAllowed = true;
1791+
CClientVehicle::UnpairPedAndVehicle(this);
1792+
}
17861793

17871794
// Recheck we have a ped, ReCreateModel might destroy it
17881795
if (m_pPlayerPed)
@@ -1957,6 +1964,11 @@ void CClientPed::Kill(eWeaponType weaponType, unsigned char ucBodypart, bool bSt
19571964
if (IsWearingGoggles())
19581965
SetWearingGoggles(false, false);
19591966

1967+
// Remove from vehicle in MTA scope
1968+
// Fix issue GH #4017
1969+
m_vehicleWithoutPairAllowed = true;
1970+
CClientVehicle::UnpairPedAndVehicle(this);
1971+
19601972
m_bDead = true;
19611973
}
19621974

@@ -2714,6 +2726,9 @@ void CClientPed::StreamedInPulse(bool bDoStandardPulses)
27142726
// Grab some vars here, saves getting them twice
27152727
CClientVehicle* pVehicle = GetOccupiedVehicle();
27162728

2729+
if (m_vehicleWithoutPairAllowed && (IsDead() || !GetRealOccupiedVehicle()))
2730+
m_vehicleWithoutPairAllowed = false;
2731+
27172732
// Do we have a player? (streamed in)
27182733
if (m_pPlayerPed)
27192734
{
@@ -7081,7 +7096,7 @@ void CClientPed::UpdateVehicleInOut()
70817096

70827097
// Jax: this was commented, re-comment if it was there for a reason (..and give the reason!)
70837098
// Are we in a vehicle we aren't supposed to be in?
7084-
if (pVehicle && !pOccupiedVehicle)
7099+
if (pVehicle && !pOccupiedVehicle && !m_vehicleWithoutPairAllowed)
70857100
{
70867101
g_pCore->GetConsole()->Print("You shouldn't be in this vehicle");
70877102
RemoveFromVehicle();

Client/mods/deathmatch/logic/CClientPed.h

+1
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
787787
bool m_bNoNewVehicleTask; // When set, we are not allowed to initiate a new enter/exit task because we are waiting for server reply
788788
ElementID m_NoNewVehicleTaskReasonID; // ElementID of the vehicle that we are waiting on
789789
CClientPed* m_pGettingJackedBy; // The ped that is jacking us
790+
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
790791

791792
std::shared_ptr<CClientModel> m_clientModel;
792793

0 commit comments

Comments
 (0)