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

Knife Distance [Problem with names]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SomewhereLost
AlliedModders Donor
Join Date: Mar 2014
Location: Tomorrowland
Old 01-06-2017 , 16:28   Knife Distance [Problem with names]
Reply With Quote #1

I got a little problem with names

[Knife Distance] stabbed Mehh within 31.277442 units (Head)!
[Knife Distance] stabbed within 31.172189 units (Left Arm)!

It simply removes the names of the victim/attacker in chat
So if somebody could fix it, please do. thanks
And also, sometimes you can't hear the sound GODLIKE/WICKED SICK mostly when you're already dead.

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

#pragma semicolon 1

enum AttackType
{
    
STAB 0,
    
SLASH
};

enum TraceType
{
    
TRACELINE 0,
    
TRACEHULL
};

enum Sound 
{
    
WICKEDSICK 0,
    
GODLIKE
};

enum HitData
{
    
AttackType:iAttack,
    
Float:flDistance,
    
iHitgroup,
    
iAttacker,
    
iVictim
};

new 
g_szTraceType[TraceType][] =
{
    
"TraceLine",
    
"TraceHull"
};

new 
g_szSound[Sound][] =
{
    
"misc/wickedsick.wav",
    
"misc/godlike.wav"
};

new 
g_HitData[HitData];

new 
g_szHitgroup[8][] =
{
    
"Full Body",
    
"Head",
    
"Chest",
    
"Stomach",
    
"Left Arm",
    
"Right Arm",
    
"Left Leg",
    
"Right Leg"
};

new 
bool:g_bKnifeHit;

new 
g_szNickname[33][32];

new 
g_pCVarFriendlyFire;

new 
g_pCVarSoundWickedSickStab;
new 
g_pCVarSoundGodlikeStab;
new 
g_pCVarSoundWickedSickSlash;
new 
g_pCVarSoundGodlikeSlash;

new 
g_pCVarHudColor;
new 
g_pCVarHudCoords;
new 
g_pCVarHudHoldtime;

public 
plugin_precache( )
{
    
precache_soundg_szSound[WICKEDSICK] );
    
precache_soundg_szSound[GODLIKE] );
}

public 
plugin_init( )
{
    
register_plugin"Knife Distance""0.4""SchlumPF" );
    
    
g_pCVarSoundWickedSickStab register_cvar"kd_sound_wickedsick_stab""30" );
    
g_pCVarSoundGodlikeStab register_cvar"kd_sound_godlike_stab""31" );
    
g_pCVarSoundWickedSickSlash register_cvar"kd_sound_wickedsick_slash""46" );
    
g_pCVarSoundGodlikeSlash register_cvar"kd_sound_godlike_slash""47" );
    
    
g_pCVarHudColor register_cvar"kd_hud_color""0 250 150" );
    
g_pCVarHudCoords register_cvar"kd_hud_coords""-0.75 -1.0" );
    
g_pCVarHudHoldtime register_cvar"kd_hud_holdtime""2.0" );
    
    
register_forwardFM_TraceLine"FM_TraceLine_Post");
    
register_forwardFM_TraceHull"FM_TraceHull_Post");
    
    
register_event"Damage""eventDamage""b" );
    
    
g_pCVarFriendlyFire get_cvar_pointer"mp_friendlyfire" );
}

public 
FM_TraceLine_PostFloat:vecSrc[3], Float:vecEnd[3], noMonstersskipEnttr )

    if( !
is_user_aliveskipEnt ) )
    {
        return 
FMRES_IGNORED;
    }
    
    if( 
get_user_weaponskipEnt ) != CSW_KNIFE )
    {
        return 
FMRES_IGNORED;
    }
    
    static 
button;
    
button pevskipEntpev_button );
    
    if( !( 
button IN_ATTACK ) && !( button IN_ATTACK2 ) )
    {
        return 
FMRES_IGNORED;
    }
    
    static 
Float:flFraction;
    
get_tr2trTR_flFractionflFraction );
    
    if( 
flFraction >= 1.0 )
    {
        return 
FMRES_IGNORED;
    }
    
    static 
pHit;
    
pHit get_tr2trTR_pHit );
    
    if( 
get_user_teamskipEnt ) == get_user_teampHit ) && !get_pcvar_numg_pCVarFriendlyFire ) )
    {
        return 
FMRES_IGNORED;
    }

    static 
Float:vecEndPos[3];
    
get_tr2trTR_vecEndPosvecEndPos );

    static 
Float:distance;
    
distance vector_distancevecSrcvecEndPos );
    
    static 
Float:range;
    
range distance flFraction// vector_distance( vecSrc, vecEnd )
    
    
if( 31.89 range 32.1 )
    {
        
GetTraceDatatrskipEntpHitdistanceSTAB );
    }
    else if( 
47.89 range 48.1 )
    {
        
GetTraceDatatrskipEntpHit,  distanceSLASH );
    }
    
    return 
FMRES_IGNORED;
}

public 
FM_TraceHull_PostFloat:vecSrc[3], Float:vecEnd[3], noMonstershullskipEnttr )
{
    if( !
is_user_aliveskipEnt ) )
    {
        return 
FMRES_IGNORED;
    }
    
    if( 
get_user_weaponskipEnt ) != CSW_KNIFE )
    {
        return 
FMRES_IGNORED;
    }
    
    static 
Float:flFraction;
    
get_tr2trTR_flFractionflFraction );
    
    if( 
flFraction >= 1.0 )
    {
        return 
FMRES_IGNORED;
    }
    
    static 
pHit;
    
pHit get_tr2trTR_pHit );
    
    if( 
get_user_teamskipEnt ) == get_user_teampHit ) && !get_pcvar_numg_pCVarFriendlyFire ) )
    {
        return 
FMRES_IGNORED;
    }
    
    static 
Float:vecEndPos[3];
    
get_tr2trTR_vecEndPosvecEndPos );

    static 
Float:distance;
    
distance vector_distancevecSrcvecEndPos );
    
    static 
Float:range;
    
range distance flFraction// vector_distance( vecSrc, vecEnd )
    
    
if( 31.89 range 32.1 )
    {
        
GetTraceDatatrskipEntpHitdistanceSTAB );
    }
    else if( 
47.89 range 48.1 )
    {
        
GetTraceDatatrskipEntpHitdistanceSLASH );
    }
    
    return 
FMRES_IGNORED;
}

public 
GetTraceDatatrattackervictimFloat:distanceAttackType:attack )
{
    
g_HitData[iAttack] = any:attack;
    
g_HitData[flDistance] = any:distance;
    
g_HitData[iHitgroup] = get_tr2trTR_iHitgroup );
    
g_HitData[iAttacker] = attacker;
    
g_HitData[iVictim] = victim;
    
    
g_bKnifeHit true;
}

public 
eventDamage( )
{
    if( 
g_bKnifeHit )
    {
        
g_bKnifeHit false;
        
        static 
victim;
        
victim g_HitData[iVictim];
        
        if( !( 
<= victim <= 32 ) )
        {
            return 
PLUGIN_CONTINUE;
        }
        
        static 
attacker;
        
attacker g_HitData[iAttacker];
        
        static 
Float:distance;
        
distance g_HitData[flDistance];
        
        static 
Float:health;
        
pevvictimpev_healthhealth );
        
        static 
rgb;
        
GetHudColorrg);
        
        static 
Float:xFloat:y;
        
GetHudCoordsx);
        
        
set_hudmessagergbxy00.0get_pcvar_floatg_pCVarHudHoldtime ), 0.00.0);
        
        if( 
g_HitData[iAttack] == STAB )
        {
            
show_hudmessageattacker"Stab Stats (%s)^nDistance: %f (max: 32.0)^nHit: %s (%s)^nDamage: %i"\
                , 
g_szTraceType[TraceType:!g_HitData[iHitgroup]],\
                
distanceg_szNickname[victim],\
                
g_szHitgroup[g_HitData[iHitgroup]], pevvictimpev_dmg_take ) );
        
            if( 
health 0.0 )
            {
                
ColorChatvictimBLUE"[Knife Distance] %s stabbed you within %f units (%s)!",\
                    
g_szNickname[attacker],\
                    
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                
                if( 
distance >= get_pcvar_floatg_pCVarSoundGodlikeStab ) )
                {
                    
ColorChat0RED"[Knife Distance] %s stabbed %s within %f units (%s)!",\
                        
g_szNickname[attacker], g_szNickname[victim],\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[GODLIKE] );
                        
                }
                else if( 
distance >= get_pcvar_floatg_pCVarSoundWickedSickStab ) )
                {
                    
ColorChat0GREEN"[Knife Distance] %s stabbed %s within %f units (%s)!",\
                        
g_szNickname[attacker], g_szNickname[victim],\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[WICKEDSICK] );
                }
            }
        }
        else
        {
            
show_hudmessageattacker"Slash Stats (%s)^nDistance: %f (max: 48.0)^nHit: %s (%s)^nDamage: %i"\
                , 
g_szTraceType[TraceType:!g_HitData[iHitgroup]],\
                
distanceg_szNickname[victim],\
                
g_szHitgroup[g_HitData[iHitgroup]], pevvictimpev_dmg_take ) );
            
            if( 
health 0.0 )
            {
                
ColorChatvictimBLUE"[Knife Distance] %s slashed you within %f units (%s)!",\
                    
g_szNickname[attacker],\
                    
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                
                if( 
distance >= get_pcvar_floatg_pCVarSoundGodlikeSlash ) )
                {
                    
ColorChat0RED"[Knife Distance] %s slashed %s within %f units (%s)!",\
                        
g_szNickname[attacker], g_szNickname[victim],\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[GODLIKE] );
                }
                else if( 
distance >= get_pcvar_floatg_pCVarSoundWickedSickSlash ) )
                {
                    
ColorChat0GREEN"[Knife Distance] %s slashed %s within %f units (%s)!",\
                        
g_szNickname[attacker], g_szNickname[victim],\
                        
distanceg_szHitgroup[g_HitData[iHitgroup]] );
                    
client_cmd0"spk %s"g_szSound[WICKEDSICK] );
                }
            }
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
client_infochangedplr )
{
    static 
curName[32], newName[32];
    
get_user_nameplrcurName31 );
    
get_user_infoplr"name"newName31 );
    
    if( !
equalnewNamecurName ) )
    {
        
copyg_szNickname[plr], 31newName );
    }
}

public 
GetHudColor( &r, &g, &)
{
    static 
color[16], piece[5];
    
get_pcvar_stringg_pCVarHudColorcolor15 );
    
    
strbreakcolorpiece4color15 );
    
str_to_numpiece );
    
    
strbreakcolorpiece4color15 );
    
str_to_numpiece );
    
str_to_numcolor );
}

public 
GetHudCoords( &Float:x, &Float:)
{
    static 
coords[16], piece[10];
    
get_pcvar_stringg_pCVarHudCoordscoords15 );
    
    
strbreakcoordspiece9coords15 );
    
str_to_floatpiece );
    
str_to_floatcoords );

__________________

Last edited by SomewhereLost; 01-06-2017 at 16:57.
SomewhereLost is offline
Send a message via Skype™ to SomewhereLost
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 01:38.


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