From 836888379dc3e434752ad20c10a8d7d33ffc65a2 Mon Sep 17 00:00:00 2001 From: FileEX Date: Mon, 24 Jun 2024 17:28:41 +0200 Subject: [PATCH] Fix #414 Using setElementHealth on a dead ped makes it invincible (#3507) --- Client/mods/deathmatch/logic/CClientPed.cpp | 5 +++++ Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 7fee88ce63..735c1115c8 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -1761,6 +1761,11 @@ void CClientPed::InternalSetHealth(float fHealth) } else { + // Ped is alive again (Fix #414) + UnlockHealth(); + UnlockArmor(); + SetIsDead(false); + // Recreate the player ReCreateModel(); } diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 2036b12a70..188bf1519c 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1669,6 +1669,9 @@ bool CStaticFunctionDefinitions::SetElementHealth(CElement* pElement, float fHea unsigned char ucHealth = static_cast(fHealth * 1.25f); fHealth = static_cast(ucHealth) / 1.25f; pPed->SetHealth(fHealth); + + if (pPed->IsDead() && fHealth > 0.0f) + pPed->SetIsDead(false); } else return false;