From f8349e846aba6538df31ba44690b3ea93bcef690 Mon Sep 17 00:00:00 2001 From: Benoist <14257866+Kenzzer@users.noreply.github.com> Date: Tue, 20 Dec 2022 23:07:57 +0100 Subject: [PATCH] Fix `SetEntityHealth` to support 'any' entities (#1846) Co-authored-by: Kenzzer --- plugins/include/entity_prop_stocks.inc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/plugins/include/entity_prop_stocks.inc b/plugins/include/entity_prop_stocks.inc index c7f4a56d..ea1c3dd8 100644 --- a/plugins/include/entity_prop_stocks.inc +++ b/plugins/include/entity_prop_stocks.inc @@ -534,19 +534,10 @@ stock void SetEntityHealth(int entity, int amount) gotconfig = true; } - char cls[64]; PropFieldType type; int offset; - if (!GetEntityNetClass(entity, cls, sizeof(cls))) - { - ThrowError("SetEntityHealth not supported by this mod: Could not get serverclass name"); - return; - } - - offset = FindSendPropInfo(cls, prop, type); - - if (offset <= 0) + if ((offset = FindDataMapInfo(entity, prop, type)) == -1) { ThrowError("SetEntityHealth not supported by this mod"); return; @@ -559,7 +550,12 @@ stock void SetEntityHealth(int entity, int amount) } else { - SetEntProp(entity, Prop_Send, prop, amount); + SetEntData(entity, offset, amount); + } + + if (IsValidEdict(entity)) + { + ChangeEdictState(entity); } }