Killbox on the top right?

Well, I’m not deriving from sandbox so I don’t see kills and deaths on the top right of the screen.

Is there any way to activate them?

If not, what would be a good simple way to make a custom one that actually works? (I.e; lines don’t overlap, scroll upwards accordingly, etc)

Take it from sandbox.

Ahh, that’s a good idea. I’ve looked around but can’t seem to find it. Can you hint me towards what keywords I’m looking for?

I think I mentioned to you that I tried it and it’s actually in base gamemode, something of yours is overwriting it.

I don’t think it’s in the base gamemode. Isn’t it coded in C++? Included in the sourcecode. Like CS:S has it too. So it’s something in source.

I did see it in base, Freze.

Check cl_deathnotice.lua

I tried copying the WHOLE code in my gamemode and adjusting it and it still didn’t work. Something’s pretty odd.

What I meant was, you don’t have to derive from sandbox to get that. :slight_smile:

[editline]11th March 2011[/editline]

Looking in base gamemode, check it:

[lua]
/---------------------------------------------------------
Name: gamemode:PlayerDeath( )
Desc: Called when a player dies.
---------------------------------------------------------
/
function GM:PlayerDeath( Victim, Inflictor, Attacker )

// Don't spawn for at least 2 seconds
Victim.NextSpawnTime = CurTime() + 2
Victim.DeathTime = CurTime()

// Convert the inflictor to the weapon that they're holding if we can.
// This can be right or wrong with NPCs since combine can be holding a 
// pistol but kill you by hitting you with their arm.
if ( Inflictor && Inflictor == Attacker && (Inflictor:IsPlayer() || Inflictor:IsNPC()) ) then

	Inflictor = Inflictor:GetActiveWeapon()
	if ( !Inflictor || Inflictor == NULL ) then Inflictor = Attacker end

end

if (Attacker == Victim) then

	umsg.Start( "PlayerKilledSelf" )
		umsg.Entity( Victim )
	umsg.End()
	
	MsgAll( Attacker:Nick() .. " suicided!

" )

return end

if ( Attacker:IsPlayer() ) then

	umsg.Start( "PlayerKilledByPlayer" )
	
		umsg.Entity( Victim )
		umsg.String( Inflictor:GetClass() )
		umsg.Entity( Attacker )
	
	umsg.End()
	
	MsgAll( Attacker:Nick() .. " killed " .. Victim:Nick() .. " using " .. Inflictor:GetClass() .. "

" )

return end

umsg.Start( "PlayerKilled" )

	umsg.Entity( Victim )
	umsg.String( Inflictor:GetClass() )
	umsg.String( Attacker:GetClass() )

umsg.End()

MsgAll( Victim:Nick() .. " was killed by " .. Attacker:GetClass() .. "

" )

end
[/lua]

And here’s cl_deathnotice:

[lua]

local hud_deathnotice_time = CreateConVar( “hud_deathnotice_time”, “6”, FCVAR_REPLICATED, “Amount of time to show death notice” )

// These are our kill icons
local Color_Icon = Color( 255, 80, 0, 255 )
local NPC_Color = Color( 250, 50, 50, 255 )

killicon.AddFont( “prop_physics”, “HL2MPTypeDeath”, “9”, Color_Icon )
killicon.AddFont( “weapon_smg1”, “HL2MPTypeDeath”, “/”, Color_Icon )
killicon.AddFont( “weapon_357”, “HL2MPTypeDeath”, “.”, Color_Icon )
killicon.AddFont( “weapon_ar2”, “HL2MPTypeDeath”, “2”, Color_Icon )
killicon.AddFont( “crossbow_bolt”, “HL2MPTypeDeath”, “1”, Color_Icon )
killicon.AddFont( “weapon_shotgun”, “HL2MPTypeDeath”, “0”, Color_Icon )
killicon.AddFont( “rpg_missile”, “HL2MPTypeDeath”, “3”, Color_Icon )
killicon.AddFont( “npc_grenade_frag”, “HL2MPTypeDeath”, “4”, Color_Icon )
killicon.AddFont( “weapon_pistol”, “HL2MPTypeDeath”, “-”, Color_Icon )
killicon.AddFont( “prop_combine_ball”, “HL2MPTypeDeath”, “8”, Color_Icon )
killicon.AddFont( “grenade_ar2”, “HL2MPTypeDeath”, “7”, Color_Icon )
killicon.AddFont( “weapon_stunstick”, “HL2MPTypeDeath”, “!”, Color_Icon )
killicon.AddFont( “weapon_slam”, “HL2MPTypeDeath”, “*”, Color_Icon )
killicon.AddFont( “weapon_crowbar”, “HL2MPTypeDeath”, “6”, Color_Icon )

local Deaths = {}

local function PlayerIDOrNameToString( var )

if ( type( var ) == "string" ) then 
	if ( var == "" ) then return "" end
	return "#"..var 
end

local ply = Entity( var )

if (ply == NULL) then return "NULL!" end

return ply:Name()

end

local function RecvPlayerKilledByPlayer( message )

local victim 	= message:ReadEntity();
local inflictor	= message:ReadString();
local attacker 	= message:ReadEntity();
		
GAMEMODE:AddDeathNotice( attacker:Name(), attacker:Team(), inflictor, victim:Name(), victim:Team() )

end

usermessage.Hook( “PlayerKilledByPlayer”, RecvPlayerKilledByPlayer )

local function RecvPlayerKilledSelf( message )

local victim 	= message:ReadEntity();
if ( !IsValid( victim ) ) then return end	
GAMEMODE:AddDeathNotice( nil, 0, "suicide", victim:Name(), victim:Team() )

end

usermessage.Hook( “PlayerKilledSelf”, RecvPlayerKilledSelf )

local function RecvPlayerKilled( message )

local victim 	= message:ReadEntity();
local inflictor	= message:ReadString();
local attacker 	= "#" .. message:ReadString();
		
GAMEMODE:AddDeathNotice( attacker, -1, inflictor, victim:Name(), victim:Team() )

end

usermessage.Hook( “PlayerKilled”, RecvPlayerKilled )

local function RecvPlayerKilledNPC( message )

local victimtype = message:ReadString();
local victim 	= "#" .. victimtype;
local inflictor	= message:ReadString();
local attacker 	= message:ReadEntity();
		
GAMEMODE:AddDeathNotice( attacker:Name(), attacker:Team(), inflictor, victim, -1 )

local bIsLocalPlayer = (IsValid(attacker) && attacker == LocalPlayer())

local bIsEnemy = IsEnemyEntityName( victimtype )
local bIsFriend = IsFriendEntityName( victimtype )

if ( bIsLocalPlayer && bIsEnemy ) then
	achievements.IncBaddies();
end

if ( bIsLocalPlayer && bIsFriend ) then
	achievements.IncGoodies();
end

if ( bIsLocalPlayer && (!bIsFriend && !bIsEnemy) ) then
	achievements.IncBystander();
end

end

usermessage.Hook( “PlayerKilledNPC”, RecvPlayerKilledNPC )

local function RecvNPCKilledNPC( message )

local victim 	= "#" .. message:ReadString();
local inflictor	= message:ReadString();
local attacker 	= "#" .. message:ReadString();
		
GAMEMODE:AddDeathNotice( attacker, -1, inflictor, victim, -1 )

end

usermessage.Hook( “NPCKilledNPC”, RecvNPCKilledNPC )

/---------------------------------------------------------
Name: gamemode:AddDeathNotice( Victim, Attacker, Weapon )
Desc: Adds an death notice entry
---------------------------------------------------------
/
function GM:AddDeathNotice( Victim, team1, Inflictor, Attacker, team2 )

local Death = {}
Death.victim 	= 	Victim
Death.attacker	=	Attacker
Death.time		=	CurTime()

Death.left		= 	Victim
Death.right		= 	Attacker
Death.icon		=	Inflictor

if ( team1 == -1 ) then Death.color1 = table.Copy( NPC_Color ) 
else Death.color1 = table.Copy( team.GetColor( team1 ) ) end
	
if ( team2 == -1 ) then Death.color2 = table.Copy( NPC_Color ) 
else Death.color2 = table.Copy( team.GetColor( team2 ) ) end

if (Death.left == Death.right) then
	Death.left = nil
	Death.icon = "suicide"
end

table.insert( Deaths, Death )

end

local function DrawDeath( x, y, death, hud_deathnotice_time )

local w, h = killicon.GetSize( death.icon )

local fadeout = ( death.time + hud_deathnotice_time ) - CurTime()

local alpha = math.Clamp( fadeout * 255, 0, 255 )
death.color1.a = alpha
death.color2.a = alpha

// Draw Icon
killicon.Draw( x, y, death.icon, alpha )
	
// Draw KILLER
if (death.left) then
	draw.SimpleText( death.left, 	"ChatFont", x - (w/2) - 16, y, 		death.color1, 	TEXT_ALIGN_RIGHT )
end

// Draw VICTIM
draw.SimpleText( death.right, 		"ChatFont", x + (w/2) + 16, y, 		death.color2, 	TEXT_ALIGN_LEFT )

return (y + h*0.70)

end

function GM:DrawDeathNotice( x, y )

local hud_deathnotice_time = hud_deathnotice_time:GetFloat()

x = x * ScrW()
y = y * ScrH()

// Draw
for k, Death in pairs( Deaths ) do

	if (Death.time + hud_deathnotice_time > CurTime()) then

		if (Death.lerp) then
			x = x * 0.3 + Death.lerp.x * 0.7
			y = y * 0.3 + Death.lerp.y * 0.7
		end
		
		Death.lerp = Death.lerp or {}
		Death.lerp.x = x
		Death.lerp.y = y
	
		y = DrawDeath( x, y, Death, hud_deathnotice_time )
	
	end
	
end

// We want to maintain the order of the table so instead of removing
// expired entries one by one we will just clear the entire table
// once everything is expired.
for k, Death in pairs( Deaths ) do
	if (Death.time + hud_deathnotice_time > CurTime()) then
		return
	end
end

Deaths = {}

end
[/lua]

Okay touché. I wasn’t aware ;).

I fixed it for him, he was overriding HUDPaint, and he wasn’t sending the usermessage. =D

Well that wasn’t good :smiley:

Drew is a god