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

Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 12-26-2011 , 16:20   Damage
Reply With Quote #1

Does not work properly
Do I have wrong?

Code:
#include <amxmodx>

public plugin_init()
{
	register_plugin("PLUGIN", "VERSION", "AUTHOR")

	register_event("Damage", "event_damage", "b")
}

public event_damage(id)
{
	new iDamage = read_data(2)
	new iHealth = get_user_health(id)

	set_hudmessage(0, 255, 0, -1.0, -0.35, 0, 6.0, 4.0, 0.0, 2.0, 1)
	show_hudmessage(iDamage, "Damage:%s^nHealth:%s", iDamage, iHealth)

	client_print(id, print_chat, "Damage:%s Health:%s", iDamage, iHealth)
}
RuRuRu612754 is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 12-26-2011 , 16:39   Re: Damage
Reply With Quote #2

PHP Code:
set_hudmessage(02550, -1.0, -0.3506.04.00.02.01)
    
show_hudmessage(iDamage"Damage:%i^nHealth:%i"iDamageiHealth)
 
    
client_print(idprint_chat"Damage:%i Health:%i"iDamageiHealth
i dont know why but you can also use %d
.Dare Devil. is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 12-26-2011 , 16:49   Re: Damage
Reply With Quote #3

Well first off the event doesnt have a parameter of ID. Also your hud message is trying to show the value of damage the message. Heres something using ham.

PHP Code:
#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("Damage Notifier""0.0.1""SavSin");
    
    
RegisterHam(Ham_TakeDamage"player""fwdHamTakeDamage"1);
}

public 
fwdHamTakeDamage(iVictimiInflictoriAttackerFloat:flDamageiDmgBits)
{
    new 
iHealth get_user_health(iVictim);
    
set_hudmessage(02550, -1.0, -0.3506.04.00.02.01);
    
show_hudmessage(iAttacker"Damage: %f ^n Health:%d"flDamageiHealth); //Shows message to attacker of damage and victims health
    
    
client_print(iAttacker"Damage: %f Health: %d"flDamageiHealth);

I dont remember the read datas for the damage event or i would use that. Just to show you using your existing code. Also %s is for Strings

%s = Strings
%i %d = Integers
%f = Float

Last edited by Doc-Holiday; 12-26-2011 at 16:52.
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-26-2011 , 17:02   Re: Damage
Reply With Quote #4

flDamage is not the real damage value, Damage event should be fine there.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 12-26-2011 , 19:21   Re: Damage
Reply With Quote #5

thanks all answer

.Dare Devil.

Code:
#include <amxmodx>

public plugin_init()
{
	register_plugin("PLUGIN", "VERSION", "AUTHOR")

	register_event("Damage", "event_damage", "b")
}

public event_damage(id)
{
	new iDamage = read_data(2)
	new iHealth = get_user_health(id)

	set_hudmessage(0, 255, 0, -1.0, -0.25, 0, 6.0, 2.0, 0.0, 1.0, 1)
	show_hudmessage(iDamage, "Damage:%i^nHealth:%i", iDamage, iHealth)

	client_print(id, print_chat, "Damage:%i Health:%i", iDamage, iHealth)
}
Although the work, I go wrong results.

results.
Damage: 3 Health:86
Damage:0 Health:

show_hudmessage
Will get two. First is the correct result will be erased in a second incorrect results

Last edited by RuRuRu612754; 12-26-2011 at 19:21.
RuRuRu612754 is offline
fmcTheKing
Member
Join Date: Feb 2011
Location: Brazil
Old 12-26-2011 , 20:44   Re: Damage
Reply With Quote #6

try this

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>

public plugin_init()
{
    
register_plugin(...);
    
    
RegisterHam(Ham_TakeDamage"player""TakeDamage"1);
}
public 
TakeDamage(iVictimiInflictoriAttackerFloat:flDamageiDmgBits)
{
    new 
iHealth get_user_health(iVictim);
    new 
iDamage pev(pev_dmg_take);
    
    
set_hudmessage(02550, -1.0, -0.3506.04.00.02.01);
    
show_hudmessage(iAttacker"Damage: %i^n Health:%i"iDamageiHealth);

fmcTheKing is offline
Send a message via MSN to fmcTheKing Send a message via Skype™ to fmcTheKing
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-26-2011 , 20:47   Re: Damage
Reply With Quote #7

new iDamage = pev(pev_dmg_take)

????

-> It doesn't compile
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 12-26-2011 at 20:47.
Devil259 is offline
fmcTheKing
Member
Join Date: Feb 2011
Location: Brazil
Old 12-26-2011 , 20:52   Re: Damage
Reply With Quote #8

sorry, pev(iVictim, pev_dmg_take)
__________________

fmcTheKing is offline
Send a message via MSN to fmcTheKing Send a message via Skype™ to fmcTheKing
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 12-27-2011 , 01:03   Re: Damage
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
flDamage is not the real damage value, Damage event should be fine there.
I thought that ham had the correct value of the damage in the post call of that? i guess i was wrong.

What are the read data's for the damage event?

1 = victim?
2 = damage?
3 = headshot?
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-27-2011 , 02:36   Re: Damage
Reply With Quote #10

Code:
/*
=========================================================
	UpdateClientData

resends any changed player HUD info to the client.
Called every frame by PlayerPreThink
Also called at start of demo recording and playback by
ForceClientDllUpdate to ensure the demo gets messages
reflecting all of the HUD state info.
=========================================================
*/
void CBasePlayer :: UpdateClientData( void )
{
	// [ .. ]
	if (pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType)
	{
		// Comes from inside me if not set
		Vector damageOrigin = pev->origin;
		// send "damage" message
		// causes screen to flash, and pain compass to show direction of damage
		edict_t *other = pev->dmg_inflictor;
		if ( other )
		{
			CBaseEntity *pEntity = CBaseEntity::Instance(other);
			if ( pEntity )
				damageOrigin = pEntity->Center();
		}

		// only send down damage type that have hud art
		int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD;

		MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev );
			WRITE_BYTE( pev->dmg_save );
			WRITE_BYTE( pev->dmg_take );
			WRITE_LONG( visibleDamageBits );
			WRITE_COORD( damageOrigin.x );
			WRITE_COORD( damageOrigin.y );
			WRITE_COORD( damageOrigin.z );
		MESSAGE_END();
	
		pev->dmg_take = 0;
		pev->dmg_save = 0;
		m_bitsHUDDamage = m_bitsDamageType;
		
		// Clear off non-time-based damage indicators
		m_bitsDamageType &= DMG_TIMEBASED;
	}
You may want to filter :
register_event("Damage", "Event_Damage", "b", "2!0", "3=0", "4!0")
This is the one for bullet damage.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-27-2011 at 02:41.
ConnorMcLeod is offline
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 04:38.


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