Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawtrainhealth()
- for k, v in pairs( ents.FindByClass("func_tracktrain") ) do
- -- check if it's really a func_tracktrain
- if v:GetClass( ) == "func_tracktrain" then
- -- change the Vector in LocalToWorld to change
- -- where the text should appear in relation to the ent
- local pos = v:LocalToWorld(Vector(0, 0, 100)):ToScreen()
- -- check we can actually see this part of the entity
- if pos.visible then
- -- what info to draw
- draw.DrawText( tostring( v:Health() ),
- -- what font to draw it in
- "Default",
- -- where to draw it
- pos.x, pos.y,
- -- what colour it must be
- Color(255, 255, 255),
- -- how to align the text
- TEXT_ALIGN_CENTER
- )
- end
- end
- end
- end
- hook.Add("HUDPaint", "ShowHealthAboveEnt", drawtrainhealth )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement