This will show the attacker his cumulative damage, reverting back to 0 if the attack occurs greater than or requal to 10 seconds from the last attack.
The victim sees the current attack damage.
Not sure how you determine which player is a zombie.
10 second interval is controlled by cvar.
PHP Code:
#include <amxmodx>
new const Version[] = "0.1";
#define MAX_PLAYERS 32
enum HUDSyncObj
{
hsVictim,
hsAttacker
}
new hsHUDObj[ HUDSyncObj ];
enum DamageInfo
{
LastDamage,
TotalDamage,
LastDamageTime
}
new diDamageInfo[ MAX_PLAYERS + 1 ][ DamageInfo ];
new g_pResetSeconds;
public plugin_init()
{
register_plugin( "Damage HUD" , Version , "bugsy" );
register_event( "Damage" , "xOnDamage" , "b" , "2!0" , "3=0" , "4!0" );
g_pResetSeconds = register_cvar( "dh_resetseconds" , "10" );
hsHUDObj[ hsVictim ] = CreateHudSyncObj();
hsHUDObj[ hsAttacker ] = CreateHudSyncObj();
}
public xOnDamage( id )
{
static xAttacker , bool:bTimeThresholdExceeded;
xAttacker = get_user_attacker( id );
bTimeThresholdExceeded = bool:( ( get_systime() - diDamageInfo[ xAttacker ][ LastDamageTime ] ) >= get_pcvar_num( g_pResetSeconds ) );
diDamageInfo[ xAttacker ][ LastDamage ] = read_data( 2 );
diDamageInfo[ xAttacker ][ TotalDamage ] = diDamageInfo[ xAttacker ][ LastDamage ] + ( bTimeThresholdExceeded ? 0 : diDamageInfo[ xAttacker ][ TotalDamage ] );
diDamageInfo[ xAttacker ][ LastDamageTime ] = get_systime();
set_hudmessage( 255 , 0 , 0 , 0.45 , 0.50 , 0 , 0.1 , 3.0 , 0.1 , 0.1 );
ShowSyncHudMsg( id , hsHUDObj[ hsVictim ] , "%i" , diDamageInfo[ xAttacker ][ LastDamage ] );
if ( is_user_connected( xAttacker ) )
{
set_hudmessage( 0 , 100 , 200 , -1.0 , 0.55 , 0 , 0.1 , 3.0 , 0.02 , 0.02 );
ShowSyncHudMsg( xAttacker , hsHUDObj[ hsAttacker ] , "%i" , diDamageInfo[ xAttacker ][ TotalDamage ] );
}
}
__________________