cl_playertitle.lua
Replace the code in this file with this
//Config
// Names enabled?
local enablenames = true
// Titles enabled?
local enabletitles = true
// How to align the text?
// 0 = left
// 1 = center
// 2 = right
local textalign = 1
// Distance multiplier. The higher this number, the further away you'll see names and titles.
local distancemulti = 2
////////////////////////////////////////////////////////////////////
// Don't edit below this point unless you know what you're doing. //
////////////////////////////////////////////////////////////////////
function DrawNameTitle()
local vStart = LocalPlayer():GetPos()
local vEnd
for k, v in pairs(player.GetAll()) do
if not v:Alive() then continue end
local vStart = LocalPlayer():GetPos()
local vEnd = v:GetPos() + Vector(0,0,40)
local trace = {}
trace.start = vStart
trace.endpos = vEnd
local trace = util.TraceLine( trace )
if trace.HitWorld then
--Do nothing!
else
local mepos = LocalPlayer():GetPos()
local tpos = v:GetPos()
local tdist = mepos:Distance(tpos)
if tdist <= 3000 then
local zadj = 0.03334 * tdist
local pos = v:GetPos() + Vector(0,0,v:OBBMaxs().z + 5 + zadj)
pos = pos:ToScreen()
local alphavalue = (600 * distancemulti) - (tdist/1.5)
alphavalue = math.Clamp(alphavalue, 0, 255)
local outlinealpha = (450 * distancemulti) - (tdist/2)
outlinealpha = math.Clamp(outlinealpha, 0, 255)
local playercolour = team.GetColor(v:Team())
local playertitle = v:GetNetworkedString("title")
if ( (v != LocalPlayer()) and (v:GetNWBool("exclusivestatus") == false) ) then
if (enablenames == true) then
draw.SimpleTextOutlined(v:Name(), "TargetID", pos.x, pos.y - 10, Color(playercolour.r, playercolour.g, playercolour.b, alphavalue),textalign,1,2,Color(0,0,0,outlinealpha))
end
if (not (playertitle == "")) and (enabletitles == true) then
draw.SimpleTextOutlined(playertitle, "Trebuchet18", pos.x, pos.y + 6, Color(255,255,255,alphavalue),textalign,1,1,Color(0,0,0,outlinealpha))
end
end
end
end
end
end
hook.Add("HUDPaint", "DrawNameTitle", DrawNameTitle)
All I did was add an alive check to the player to decide if the title should be drawn above their head. 1 line of code.
if not v:Alive() the continue end