View Single Post
Author Message
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 02-01-2014 , 00:31   [CSGO] player_hurt & player_death
Reply With Quote #1

Hey,

I'm having a problem with the player_hurt event returning the wrong weapon name so does Weapon_Fire but the player_death event returns the right one.

hkp2000 is returned instead of usp_silencer or usp_silencer_off
same with m4a1 is returned instead of m4a1_silencer or m4a1_silencer_off

GetClientWeapon() also returns the wrong weapon name

Anyone know a fix for this?

Sourcemod 1.5.2 & MetaMod 1.10.0 being used.

here is a image of what I mean


PHP Code:
HookEvent("player_hurt",  Event_Player_Hurt);
HookEvent("player_death",  Event_Player_Death);
HookEvent("weapon_fire"Event_Weapon_Fire);

public 
Event_Player_Hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
IsActive(0true))
    {
        return;
    }
    
    
// stats
    
if (GetConVarBool(g_h_stats_enabled))
    {
        new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
        new 
victim GetClientOfUserId(GetEventInt(event"userid"));
        new 
damage GetEventInt(event"dmg_health");
        new 
damage_armor GetEventInt(event"dmg_armor");
        new 
hitgroup GetEventInt(event"hitgroup");
        new 
Stringweapon[64];
        new 
Stringweapons[64];  //this is only for testing
        
GetClientWeapon(attackerweapons64);    //this is only for testing
        
GetEventString(event"weapon"weaponsizeof(weapon));
        
PrintToChatAll("Hurt = GetEventString weapon %s - GetClientWeapon %s"weaponweapons);    //this is only for testing
[more code here but not needed for this problem]
    }
}

public 
Event_Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
IsActive(0true))
    {
        return;
    }
    
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
assister GetClientOfUserId(GetEventInt(event"assister"));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
bool:headshot GetEventBool(event"headshot");
    new 
Stringweapon[64];
    new 
Stringweapons[64];  //this is only for testing
    
GetEventString(event"weapon"weaponsizeof(weapon));
    
GetClientWeapon(attackerweapons64);  //this is only for testing
    
PrintToChatAll("Death = GetEventString weapon %s - GetClientWeapon %s"weaponweapons);  //this is only for testing
    
new victim_team GetClientTeam(victim);
[
there is more code here but not needed for this problem]
}

public 
Event_Weapon_Fire(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
IsActive(0true))
    {
        return;
    }
    
    
// stats
    
if (GetConVarBool(g_h_stats_enabled))
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        if (
client 0)
        {
            new 
Stringweapon[64];
            new 
Stringweapons[64];  //this is only for testing
            
GetEventString(event"weapon"weaponsizeof(weapon));
            
GetClientWeapon(clientweapons64);  //this is only for testing
            
PrintToChatAll("Fire = GetEventString weapon %s - GetClientWeapon %s"weaponweapons);  //this is only for testing
            
new weapon_index GetWeaponIndex(weapon);
            if (
weapon_index > -1)
            {
                
weapon_stats[client][weapon_index][LOG_HIT_SHOTS]++;
            }
        }
    }

__________________

Last edited by versatile_bfg; 02-01-2014 at 01:00.
versatile_bfg is offline