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(0, true))
{
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 String: weapon[64];
new String: weapons[64]; //this is only for testing
GetClientWeapon(attacker, weapons, 64); //this is only for testing
GetEventString(event, "weapon", weapon, sizeof(weapon));
PrintToChatAll("Hurt = GetEventString weapon %s - GetClientWeapon %s", weapon, weapons); //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(0, true))
{
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 String: weapon[64];
new String: weapons[64]; //this is only for testing
GetEventString(event, "weapon", weapon, sizeof(weapon));
GetClientWeapon(attacker, weapons, 64); //this is only for testing
PrintToChatAll("Death = GetEventString weapon %s - GetClientWeapon %s", weapon, weapons); //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(0, true))
{
return;
}
// stats
if (GetConVarBool(g_h_stats_enabled))
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client > 0)
{
new String: weapon[64];
new String: weapons[64]; //this is only for testing
GetEventString(event, "weapon", weapon, sizeof(weapon));
GetClientWeapon(client, weapons, 64); //this is only for testing
PrintToChatAll("Fire = GetEventString weapon %s - GetClientWeapon %s", weapon, weapons); //this is only for testing
new weapon_index = GetWeaponIndex(weapon);
if (weapon_index > -1)
{
weapon_stats[client][weapon_index][LOG_HIT_SHOTS]++;
}
}
}
}
__________________