codeAPI Reference
s&box IKillSource: Kill feed attacker interface
IKillSource Interface API Reference
IKillSource is an interface for Components that can appear as an attacker in the kill feed. Implement on Player, Npc, explosive barrels, turrets, or any kill-capable entity.
Type Signature
CSHARP
public interface IKillSource
{
string DisplayName { get; }
long SteamId => default;
string Tags => "";
void OnKill(GameObject victim);
}Properties
- string DisplayName { get; } - Display name shown in the kill feed.
- long SteamId => default - Steam ID for local "is-me" highlight. Defaults to 0 (not a player).
- string Tags => "" - Entity-type tag passed as attackerTags. Return empty string for plain player kills. Examples: "npc".
Methods
OnKill(GameObject victim)
Called on the host when this source kills something. Credit kills, update stats, etc. Default is no-op.Usage
CSHARP
public class MyExplosiveBarrel : Component, IKillSource, IKillIcon
{
public string DisplayName => "Explosive Barrel";
public long SteamId => 0; // Not a player
public string Tags => "prop";
public void OnKill(GameObject victim)
{
// Credit the kill to the player who placed the barrel
var ownable = GetComponent<Ownable>();
if (ownable?.Owner.IsValid() == true)
{
// Update player stats
}
}
public Texture DisplayIcon { get; set; }
}Notes
- Used by the kill feed system to identify attackers
- SteamId highlights the attacker's name if it matches the local player
- Tags can be used for kill feed styling or filtering
- OnKill is only called on the host
- Often combined with IKillIcon for custom kill feed icons
Was this helpful?