General: Fix regen issue introduced in `870ef51197`

Woops, didnt think about players that have more then the limit, when the
regen would kick in.
This commit is contained in:
zaCade 2018-07-31 23:53:57 +02:00
parent 9676fb9852
commit dc8ea3be56
1 changed files with 10 additions and 8 deletions

View File

@ -99,17 +99,19 @@ public Action:ClassHealthRegenTimer(Handle:timer, any:client)
}
new health = GetClientHealth(client);
health += ClientHealthRegenAmount[client];
// Clamp the health points to the maximum.
if (health > ClientHealthRegenMax[client])
// Check if the health is below the limit.
if (health < ClientHealthRegenMax[client])
{
health = ClientHealthRegenMax[client];
}
// Apply the health regen.
health += ClientHealthRegenAmount[client];
// Clamp the health regen to the limit.
if (health > ClientHealthRegenMax[client])
{
health = ClientHealthRegenMax[client];
}
// Check if the health points is below the limit.
if (health <= ClientHealthRegenMax[client])
{
// Increase health.
SetEntityHealth(client, health);
}