Fix SetEntityHealth to support 'any' entities (#1846)

Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com>
This commit is contained in:
Benoist 2022-12-20 23:07:57 +01:00 committed by GitHub
parent ef7d3abefd
commit f8349e846a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}
}