Fix SetEntityHealth to support 'any' entities (#1846)
Co-authored-by: Kenzzer <[email protected]>
This commit is contained in:
@@ -534,19 +534,10 @@ stock void SetEntityHealth(int entity, int amount)
|
|||||||
gotconfig = true;
|
gotconfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char cls[64];
|
|
||||||
PropFieldType type;
|
PropFieldType type;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
if (!GetEntityNetClass(entity, cls, sizeof(cls)))
|
if ((offset = FindDataMapInfo(entity, prop, type)) == -1)
|
||||||
{
|
|
||||||
ThrowError("SetEntityHealth not supported by this mod: Could not get serverclass name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = FindSendPropInfo(cls, prop, type);
|
|
||||||
|
|
||||||
if (offset <= 0)
|
|
||||||
{
|
{
|
||||||
ThrowError("SetEntityHealth not supported by this mod");
|
ThrowError("SetEntityHealth not supported by this mod");
|
||||||
return;
|
return;
|
||||||
@@ -559,7 +550,12 @@ stock void SetEntityHealth(int entity, int amount)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetEntProp(entity, Prop_Send, prop, amount);
|
SetEntData(entity, offset, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsValidEdict(entity))
|
||||||
|
{
|
||||||
|
ChangeEdictState(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user