So, I have this small problem with my % lifesteal code:
I want it to heal 10% of damage done, with a maximum overheal of 250 hp. The code works if I want to heal a flat amount (for example 10 health per hit), but for some reason it heals me instantly to max overheal if I try to heal a certain % of damage dealt.
Am I just stupid or what is wrong with this?
Code:
public OnClientPutInServer(client) {
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom){
new heal = damage * 0.1;
AddPlayerHealth(attacker, heal, 250, true);
return Plugin_Continue;
}
stock AddPlayerHealth(iClient, iAdd, iOverheal = 0, bStaticMax = false)
{
new iHealth = GetClientHealth(iClient);
new iNewHealth = iHealth + iAdd;
new iMax = bStaticMax ? iOverheal : GetEntProp(iClient, Prop_Data, "m_iMaxHealth") + iOverheal;
if (iHealth < iMax)
{
iNewHealth = min(iNewHealth, iMax);
SetEntityHealth(iClient, iNewHealth);
}
}
(This is not the full plugin, I have taken away the parts that do not affect this certain behaviour)
Sorry for being a noob and thanks in advance
!