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

Take damage not working properly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 08-07-2020 , 11:23   Take damage not working properly
Reply With Quote #1

Hey everyone.
Everything i working fine expect ammo packs in not rewarded to g_sniper and g_zadoc according to the damage.
Note. SNIPER_IGNOREAMMO and ZADOC_IGNOREAMMO is set to 0

Code --
Code:
// Ham Take Damage Forward
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type, ptr)
{
	// Non-player damage or self damage
	if (victim == attacker || !is_user_valid_connected(attacker))
	return HAM_IGNORED;

	
	// New round starting or round ended
	if (g_newround || g_endround)
	return HAM_SUPERCEDE;
	
	// Victim shouldn't take damage 
	if (g_nodamage[victim])
	return HAM_SUPERCEDE;
	
	// Prevent friendly fire
	if (g_zombie[attacker] == g_zombie[victim])
	return HAM_SUPERCEDE;

	// Set Sniper's damage
	if (g_sniper[attacker] && g_currentweapon[attacker] == CSW_AWP)
	SetHamParamFloat(4, SNIPER_DAMAGE)
	
	// Set Zadoc's damage		// Abhinash
	if (g_zadoc[attacker] && g_currentweapon[attacker] == CSW_KNIFE)
	SetHamParamFloat(4, get_pcvar_float(cvar_zadocdamage))

	
	// Attacker is human...
	if (!g_zombie[attacker])
	{
		// Armor multiplier for the final damage on normal zombies
		if (!g_nemesis[victim] && !g_assassin[victim] && !g_bombardier[victim] && !g_sniper[attacker] && !g_zadoc[attacker])		// Abhinash
		{
			damage *= get_pcvar_float(cvar_zombiearmor)
			SetHamParamFloat(4, damage)
		}
		
		// Reward ammo packs to humans for damaging zombies?	
		if (!g_zombie[attacker])
		{
			// Store damage dealt
			g_damagedealt_human[attacker] += floatround(damage)
			
			if(g_sniper[attacker])
			{
				if(SNIPER_IGNOREAMMO == 0)
				{
					while (g_damagedealt_human[attacker] >= 5000)
					{
						g_ammopacks[attacker]++
						g_damagedealt_human[attacker] -= 5000
					}
				}
				else
				{
					return HAM_IGNORED
				}
			}
			else if(g_survivor[attacker])
			{
				if(SURVIVOR_IGNOREAMMO == 0)
				{
					while (g_damagedealt_human[attacker] > 500)
					{
						g_ammopacks[attacker]++
						g_damagedealt_human[attacker] -= 500
					}
				}
				else
				{
					return HAM_IGNORED
				}
			}
			else if(g_zadoc[attacker])
			{
				if(ZADOC_IGNOREAMMO == 0)
				{
					while (g_damagedealt_human[attacker] > 5000)
					{
						g_ammopacks[attacker]++
						g_damagedealt_human[attacker] -= 5000
					}
				}
				else
				{
					return HAM_IGNORED
				}
			}
			else if(!g_sniper[attacker] || !g_survivor[attacker] || !g_zadoc[attacker])
			{
				while (g_damagedealt_human[attacker] > 500)
					{
						g_ammopacks[attacker]++
						g_damagedealt_human[attacker] -= 500
					}
			}
			
			return HAM_IGNORED
		}
		
		// Abhinash
		if (g_doubledamage[attacker])
		{
			damage *= 2.0;
			SetHamParamFloat(4, damage);
		}
		
		return HAM_IGNORED;
	}
	
	// Attacker is zombie...
	
	// Prevent infection/damage by HE grenade (bugfix)
	if (damage_type & DMG_HEGRENADE)
	return HAM_SUPERCEDE;
	
	// Nemesis?
	if (g_nemesis[attacker])
	{
		// Ignore nemesis damage override if damage comes from a 3rd party entity
		// (to prevent this from affecting a sub-plugin's rockets e.g.)
		if (inflictor == attacker)
		{
			// Set nemesis damage
			SetHamParamFloat(4, NEMESIS_DAMAGE)
		}
		
		return HAM_IGNORED;
	}
	else if (g_assassin[attacker])
	{
		// Ignore assassin damage override if damage comes from a 3rd party entity
		// (to prevent this from affecting a sub-plugin's rockets e.g.)
		if (inflictor == attacker)
		{
			// Set assassin damage
			SetHamParamFloat(4, ASSASSIN_DAMAGE)
		}
		
		return HAM_IGNORED;
	}
	else if (g_bombardier[attacker])
	{
		// Ignore assassin damage override if damage comes from a 3rd party entity
		// (to prevent this from affecting a sub-plugin's rockets e.g.)
		if (inflictor == attacker)
		{
			// Set assassin damage
			SetHamParamFloat(4, BOMBARDIER_DAMAGE)
		}
		
		return HAM_IGNORED;
	}
	
	// Reward ammo packs to zombies for damaging humans?
	if (get_pcvar_num(cvar_ammodamage_zombie) > 0)
	{
		// Store damage dealt
		g_damagedealt_zombie[attacker] += floatround(damage)
		
		// Reward ammo packs for every [ammo damage] dealt
		while (g_damagedealt_zombie[attacker] > get_pcvar_num(cvar_ammodamage_zombie))
		{
			g_ammopacks[attacker]++
			g_damagedealt_zombie[attacker] -= get_pcvar_num(cvar_ammodamage_zombie)
		}
	}
	
	// Last human or not an infection round
	if (g_survround || g_sniround || g_nemround || g_assaround || g_bombardierround/* Abhinash*/ || g_zadocround /* Abhinash */|| g_swarmround || g_plagueround || g_armageround || g_apocround || g_nightround || fnGetHumans() == 1)
	return HAM_IGNORED; // human is killed
	
	// Does human armor need to be reduced before infecting?
	if (get_pcvar_num(cvar_humanarmor))
	{
		// Get victim armor
		static Float:armor
		pev(victim, pev_armorvalue, armor)
		
		// If he has some, block the infection and reduce armor instead
		if (armor > 0.0)
		{
			emit_sound(victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
			if (armor - damage > 0.0)
			set_pev(victim, pev_armorvalue, armor - damage)
			else
			cs_set_user_armor(victim, 0, CS_ARMOR_NONE)
			return HAM_SUPERCEDE;
		}
	}
	
	// Infection allowed
	zombieme(victim, attacker, 0, 0, 0, 0, 1) // turn into zombie
	g_points[attacker]++		// Abhinash
	SavePoints(attacker)		// Abhinash
	return HAM_SUPERCEDE;
}

Last edited by Abhinash; 08-07-2020 at 11:24.
Abhinash is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 08-08-2020 , 17:35   Re: Take damage not working properly
Reply With Quote #2

Can anyone please help me out ?
Abhinash is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 08-08-2020 , 20:25   Re: Take damage not working properly
Reply With Quote #3

add debugs, check logs
ZaX is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 08-09-2020 , 11:41   Re: Take damage not working properly
Reply With Quote #4

Quote:
Originally Posted by ZaX View Post
add debugs, check logs
Debug is on and nothing in logs.
The code executes fine but doesn't work for g_sniper and g_zadoc.
How can I fix it ?
Abhinash is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-09-2020 , 15:19   Re: Take damage not working properly
Reply With Quote #5

Not "debug". You should add messages in the code to understand what gets executed and what doesn't.
__________________
HamletEagle is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 08-12-2020 , 17:15   Re: Take damage not working properly
Reply With Quote #6

Can you edit my code for example ?
Abhinash is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-12-2020 , 17:32   Re: Take damage not working properly
Reply With Quote #7

Code:
        // Reward ammo packs to humans for damaging zombies?            if (!g_zombie[attacker])         {             // Store damage dealt             g_damagedealt_human[attacker] += floatround(damage)                         if(g_sniper[attacker])             {
->
Code:
        // Reward ammo packs to humans for damaging zombies?            server_print("g_zombie[%d]: %s", attacker, g_zombie[attacker] ? "true" : "false");         if (!g_zombie[attacker])         {             // Store damage dealt             g_damagedealt_human[attacker] += floatround(damage)                         server_print("g_sniper[%d]: %s", attacker, g_sniper[attacker] ? "true" : "false");             if(g_sniper[attacker])             {

... and so on.
__________________

Last edited by Black Rose; 08-12-2020 at 17:33.
Black Rose is offline
Old 08-13-2020, 08:12
Natsheh
This message has been deleted by Natsheh. Reason: Nvm the whole code order is nonsense
Reply



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 19:25.


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