I was making a custom attribute to gain max and current health for backstabs until 11 kills, but the attribute just stops working when you take damage. I can't seem to understand why it happens, but when you go to resupply you can start gaining max health and heal again. The stock below is a TakeDamage SDKHook.
Code:
stock Action:Attribute_SpyGetSouls_OnTakeDamage(victim, &attacker, slot, &Float:damage, &damagetype, Float:damageForce[3], Float:damagePosition[3], damageCustom, &weapon, bool:bBuilding)
{
if(!IsValidClient(attacker) || !IsValidClient(victim) || slot == -1 || damage <= 0.0) return Plugin_Continue;
if(!m_bHasAttribute[attacker][slot] || !SpyGetSouls[attacker][slot]) return Plugin_Continue;
if(BackstabsForSoulsKills[attacker][slot] > 11)
{
BackstabsForSoulsKills[attacker][slot] = 11;
}
if(damageCustom == TF_CUSTOM_BACKSTAB && !GetHasBackstabShield(victim) && IsValidClient(attacker))
{
BackstabsForSoulsKills[attacker][slot] += 1;
new Handle:dataPack;
CreateDataTimer(0.001, Timer_GiveHealth, dataPack);
WritePackCell(dataPack, attacker);
}
if (BackstabsForSoulsKills[attacker][slot] == 1 && IsValidEntity(weapon))
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 25.0);
}
if (BackstabsForSoulsKills[attacker][slot] > 1)
{
TF2Attrib_RemoveByName(weapon, "max health additive bonus");
new Handle:dataPack2;
CreateDataTimer(0.00001, Timer_GiveMaxHealth, dataPack2);
WritePackCell(dataPack2, attacker);
WritePackCell(dataPack2, slot);
WritePackCell(dataPack2, weapon);
}
return Plugin_Continue;
}
public Action:Timer_GiveHealth(Handle:timer, Handle: dataPack)
{
new attacker;
ResetPack(dataPack);
attacker = ReadPackCell(dataPack);
TF2_HealPlayer(attacker, 25, true, true);
}
public Action:Timer_GiveMaxHealth(Handle:timer, any: dataPack2)
{
new attacker, slot, weapon;
ResetPack(dataPack2);
attacker = ReadPackCell(dataPack2);
slot = ReadPackCell(dataPack2);
weapon = ReadPackCell(dataPack2);
if (BackstabsForSoulsKills[attacker][slot] == 2)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 50.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 3)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 75.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 4)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 100.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 5)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 125.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 6)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 150.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 7)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 175.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 8)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 200.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 9)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 225.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 10)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 250.0);
}
if (BackstabsForSoulsKills[attacker][slot] == 11)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 275.0);
}
if (BackstabsForSoulsKills[attacker][slot] > 11)
{
TF2Attrib_SetByName(weapon, "max health additive bonus", 275.0);
KillTimer(timer);
}
}