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

Name above damage hud


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 10-16-2020 , 06:58   Name above damage hud
Reply With Quote #1

So i was wondering if anyone could help me make a name appear WHO you shoot and who shoots you above the damage gets shown?
Like

PHP Code:
Kappa
 49 
And when you shoot someone it appears like that too...

If anyone knows how to do this, could you help me thanks in advance!

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

#pragma semicolon 1

#define USE_CHECK_VISIBLE_ENT // Закомментируйте эту строку, если не хотите использовать проверку видимости игрока перед отображением урона

#if !defined USE_CHECK_VISIBLE_ENT
    #define CONSIDER_MEAT_MAPS // Закомментируйте эту строку, если не хотите принудительно активировать проверку видимости игрока на "мясных" картах
    
    
new bool:g_bMeatMap;
#endif

new g_pHudSyncObj1;
new 
g_pHudSyncObj2;

public 
plugin_init()
{
    
register_plugin("Damager""0.1b""Subb98");
    
register_event("Damage""EventDamage""b""2!0""3=0""4!0");
    
g_pHudSyncObj1 CreateHudSyncObj();
    
g_pHudSyncObj2 CreateHudSyncObj();
}

#if defined CONSIDER_MEAT_MAPS
public plugin_cfg()
{
    new const 
szMapTypes[][] = {"aim_""awp_""fy_"}; // Типы карт, которые будут считаться "мясными" (по умолчанию "aim_", "awp_", "fy_")
    
new szMapname[32];
    
get_mapname(szMapnamecharsmax(szMapname));
    for(new 
isizeof szMapTypesi++)
    {
        if(
equali(szMapnameszMapTypes[i], strlen(szMapTypes[i])))
        {
            
g_bMeatMap true;
            break;
        }
    }
}
#endif

public EventDamage(const id)
{
    static 
pAttackeriDamage;
    
pAttacker get_user_attacker(id), iDamage read_data(2);
    
#if defined USE_CHECK_VISIBLE_ENT
    
if(is_user_connected(pAttacker) && pAttacker != id && get_user_flags(pAttacker) & ADMIN_LEVEL_H && fm_is_ent_visible(pAttackerid))
    
#else
    
if(is_user_connected(pAttacker) && pAttacker != id && get_user_flags(pAttacker) & ADMIN_LEVEL_H && g_bMeatMap fm_is_ent_visible(pAttackerid) : 1>0)
    
#endif
    
{
        
set_hudmessage(0_200_0.55__1.0_0.0, -1);
        
ShowSyncHudMsg(pAttackerg_pHudSyncObj1"%d"iDamage);
    }
    if(
is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL_H)
    {
        
set_hudmessage(2550_0.45, -1.0__1.0_0.0, -1);
        
ShowSyncHudMsg(idg_pHudSyncObj2"%s%d"id == pAttacker "-" ""iDamage);
    }
}

// Thanks to ConnorMcLeod (https://forums.alliedmods.net/showpost.php?p=1580992&postcount=10)
stock bool:fm_is_ent_visible(const id, const pEnt, const bool:bIgnoreMonsters false)
{
    new 
Float:fStart[3], Float:fDestination[3], Float:fFraction;
    
pev(idpev_originfStart);
    
pev(idpev_view_ofsfDestination);
    
fStart[0] += fDestination[0];
    
fStart[1] += fDestination[1];
    
fStart[2] += fDestination[2];
    
pev(pEntpev_originfDestination);
    
engfunc(EngFunc_TraceLinefStartfDestinationbIgnoreMonstersid0);
    
get_tr2(0TR_flFractionfFraction);
    if(
fFraction 0.97)
    {
        return 
true;
    }
    return 
false;


Last edited by HowToRuski; 10-16-2020 at 07:05.
HowToRuski is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-16-2020 , 08:43   Re: Name above damage hud
Reply With Quote #2

Try this...if position of hudmessage is not good, then change this line:
set_hudmessage(0, _, 200, _, 0.55 to maybe: set_hudmessage(0, _, 200, _, 0.52

Code:
#include <amxmodx>
#include <fakemeta>

#pragma semicolon 1

#define USE_CHECK_VISIBLE_ENT // Закомментируйте эту строку, если не хотите использовать проверку видимости игрока перед отображением урона

#if !defined USE_CHECK_VISIBLE_ENT
    #define CONSIDER_MEAT_MAPS // Закомментируйте эту строку, если не хотите принудительно активировать проверку видимости игрока на "мясных" картах
    
    new bool:g_bMeatMap;
#endif

new g_pHudSyncObj1;
new g_pHudSyncObj2;

public plugin_init()
{
    register_plugin("Damager", "0.1b", "Subb98");
    register_event("Damage", "EventDamage", "b", "2!0", "3=0", "4!0");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
}

#if defined CONSIDER_MEAT_MAPS
public plugin_cfg()
{
    new const szMapTypes[][] = {"aim_", "awp_", "fy_"}; // Типы карт, которые будут считаться "мясными" (по умолчанию "aim_", "awp_", "fy_")
    new szMapname[32];
    get_mapname(szMapname, charsmax(szMapname));
    for(new i; i < sizeof szMapTypes; i++)
    {
        if(equali(szMapname, szMapTypes[i], strlen(szMapTypes[i])))
        {
            g_bMeatMap = true;
            break;
        }
    }
}
#endif

public EventDamage(const id)
{
    static pAttacker, iDamage, szName[ 32 ]
    pAttacker = get_user_attacker(id), iDamage = read_data(2);
    #if defined USE_CHECK_VISIBLE_ENT
    if(is_user_connected(pAttacker) && pAttacker != id && get_user_flags(pAttacker) & ADMIN_LEVEL_H && fm_is_ent_visible(pAttacker, id))
    #else
    if(is_user_connected(pAttacker) && pAttacker != id && get_user_flags(pAttacker) & ADMIN_LEVEL_H && g_bMeatMap ? fm_is_ent_visible(pAttacker, id) : 1>0)
    #endif
    {
        get_user_name( id, szName, charsmax( szName ) )
        set_hudmessage(0, _, 200, _, 0.55, _, _, 1.0, _, 0.0, -1);
        ShowSyncHudMsg(pAttacker, g_pHudSyncObj1, "%s^n%d", szName, iDamage);
    }
    if(is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL_H)
    {
        get_user_name( pAttacker, szName, charsmax( szName ) )
        set_hudmessage(255, 0, _, 0.45, -1.0, _, _, 1.0, _, 0.0, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "%s^n%s%d", szName, id == pAttacker ? "-" : "", iDamage);
    }
}

// Thanks to ConnorMcLeod (https://forums.alliedmods.net/showpo...2&postcount=10)
stock bool:fm_is_ent_visible(const id, const pEnt, const bool:bIgnoreMonsters = false)
{
    new Float:fStart[3], Float:fDestination[3], Float:fFraction;
    pev(id, pev_origin, fStart);
    pev(id, pev_view_ofs, fDestination);
    fStart[0] += fDestination[0];
    fStart[1] += fDestination[1];
    fStart[2] += fDestination[2];
    pev(pEnt, pev_origin, fDestination);
    engfunc(EngFunc_TraceLine, fStart, fDestination, bIgnoreMonsters, id, 0);
    get_tr2(0, TR_flFraction, fFraction);
    if(fFraction > 0.97)
    {
        return true;
    }
    return false;
}
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 10-17-2020 , 06:39   Re: Name above damage hud
Reply With Quote #3

https://prnt.sc/v13fn0

Whats this? I couldnt fix that
HowToRuski is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 10-17-2020 , 06:50   Re: Name above damage hud
Reply With Quote #4

Quote:
Originally Posted by HowToRuski View Post
https://prnt.sc/v13fn0

Whats this? I couldnt fix that
Disable this line "#pragma semicolon 1" or Put ; at the end of the code..
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 10-17-2020 , 09:04   Re: Name above damage hud
Reply With Quote #5

Quote:
Originally Posted by Supremache View Post
Disable this line "#pragma semicolon 1" or Put ; at the end of the code..
Thanks, worked. But as far as i tested this script with throwing a HE on enemy, it does not show the dealt damage... Any fixes? :/
HowToRuski 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 13:28.


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