diff --git a/apps/counterstrikesharp/src/FiveStack.Events/PlayerDamage.cs b/apps/counterstrikesharp/src/FiveStack.Events/PlayerDamage.cs index 71c0e273..14737852 100644 --- a/apps/counterstrikesharp/src/FiveStack.Events/PlayerDamage.cs +++ b/apps/counterstrikesharp/src/FiveStack.Events/PlayerDamage.cs @@ -67,7 +67,12 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event, GameEventInfo info) ? $"{Convert.ToInt32(attackerLocation.X)} {Convert.ToInt32(attackerLocation.Y)} {Convert.ToInt32(attackerLocation.Z)}" : "" }, - { "weapon", $"{(@event.Weapon.Length == 0 ? "worldent" : @event.Weapon)}" }, + { + "weapon", + @event.Weapon.Length == 0 + ? "worldent" + : CommunityWeapons.InHand(@event.Weapon, ActiveItemDefinitionIndex(attacker)) + }, { "damage", damageDealt }, { "damage_armor", @event.DmgArmor }, { "hitgroup", $"{DamageUtility.HitGroupToString(@event.Hitgroup)}" }, @@ -87,4 +92,16 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event, GameEventInfo info) return HookResult.Continue; } + + private static int? ActiveItemDefinitionIndex(CCSPlayerController? player) + { + CBasePlayerWeapon? weapon = player?.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value; + + if (weapon == null || !weapon.IsValid) + { + return null; + } + + return weapon.AttributeManager.Item.ItemDefinitionIndex; + } } diff --git a/apps/swiftly/src/FiveStack.Events/PlayerDamage.cs b/apps/swiftly/src/FiveStack.Events/PlayerDamage.cs index 5b0ebd49..2eb2e0f0 100644 --- a/apps/swiftly/src/FiveStack.Events/PlayerDamage.cs +++ b/apps/swiftly/src/FiveStack.Events/PlayerDamage.cs @@ -76,7 +76,12 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event) ? $"{Convert.ToInt32(attackerLocation.Value.X)} {Convert.ToInt32(attackerLocation.Value.Y)} {Convert.ToInt32(attackerLocation.Value.Z)}" : "" }, - { "weapon", @event.Weapon.Length == 0 ? "worldent" : @event.Weapon }, + { + "weapon", + @event.Weapon.Length == 0 + ? "worldent" + : CommunityWeapons.InHand(@event.Weapon, ActiveItemDefinitionIndex(attackerPawn)) + }, { "damage", damageDealt }, { "damage_armor", @event.DmgArmor }, { "hitgroup", DamageUtility.HitGroupToString((int)@event.ActualHitGroup) }, @@ -97,4 +102,16 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event) return HookResult.Continue; } #pragma warning restore CS0618 + + private static int? ActiveItemDefinitionIndex(CCSPlayerPawn? pawn) + { + CBasePlayerWeapon? weapon = pawn?.WeaponServices?.ActiveWeapon.Value; + + if (weapon == null || !weapon.IsValid) + { + return null; + } + + return weapon.AttributeManager.Item.ItemDefinitionIndex; + } }