Initial commit
This commit is contained in:
59
gamemodes/base/gamemode/cl_targetid.lua
Normal file
59
gamemodes/base/gamemode/cl_targetid.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: gamemode:HUDDrawTargetID( )
|
||||
Desc: Draw the target id (the name of the player you're currently looking at)
|
||||
-----------------------------------------------------------]]
|
||||
function GM:HUDDrawTargetID()
|
||||
|
||||
local trace = LocalPlayer():GetEyeTrace()
|
||||
if ( !trace.Hit ) then return end
|
||||
if ( !trace.HitNonWorld ) then return end
|
||||
|
||||
local text = "ERROR"
|
||||
local font = "TargetID"
|
||||
|
||||
if ( trace.Entity:IsPlayer() ) then
|
||||
text = trace.Entity:Nick()
|
||||
else
|
||||
--text = trace.Entity:GetClass()
|
||||
return
|
||||
end
|
||||
|
||||
surface.SetFont( font )
|
||||
local w, h = surface.GetTextSize( text )
|
||||
|
||||
local MouseX, MouseY = input.GetCursorPos()
|
||||
|
||||
if ( MouseX == 0 && MouseY == 0 || !vgui.CursorVisible() ) then
|
||||
|
||||
MouseX = ScrW() / 2
|
||||
MouseY = ScrH() / 2
|
||||
|
||||
end
|
||||
|
||||
local x = MouseX
|
||||
local y = MouseY
|
||||
|
||||
x = x - w / 2
|
||||
y = y + 30
|
||||
|
||||
-- The fonts internal drop shadow looks lousy with AA on
|
||||
draw.SimpleText( text, font, x + 1, y + 1, Color( 0, 0, 0, 120 ) )
|
||||
draw.SimpleText( text, font, x + 2, y + 2, Color( 0, 0, 0, 50 ) )
|
||||
draw.SimpleText( text, font, x, y, self:GetTeamColor( trace.Entity ) )
|
||||
|
||||
y = y + h + 5
|
||||
|
||||
-- Draw the health
|
||||
text = trace.Entity:Health() .. "%"
|
||||
font = "TargetIDSmall"
|
||||
|
||||
surface.SetFont( font )
|
||||
w, h = surface.GetTextSize( text )
|
||||
x = MouseX - w / 2
|
||||
|
||||
draw.SimpleText( text, font, x + 1, y + 1, Color( 0, 0, 0, 120 ) )
|
||||
draw.SimpleText( text, font, x + 2, y + 2, Color( 0, 0, 0, 50 ) )
|
||||
draw.SimpleText( text, font, x, y, self:GetTeamColor( trace.Entity ) )
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user