Raised This Month: $51 Target: $400
 12% 

[TF2] Both max and current health stops adding after taking damage


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 04-24-2018 , 08:47   [TF2] Both max and current health stops adding after taking damage
Reply With Quote #1

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);
	}
}
Nursik is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode