Guest User

Untitled

a guest
Nov 23rd, 2012
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function drawtrainhealth()
  2.     for k, v in pairs( ents.FindByClass("func_tracktrain") ) do
  3.  
  4.    
  5.         -- check if it's really a func_tracktrain
  6.         if v:GetClass( ) == "func_tracktrain" then
  7.             -- change the Vector in LocalToWorld to change
  8.             -- where the text should appear in relation to the ent
  9.             local pos = v:LocalToWorld(Vector(0, 0, 100)):ToScreen()
  10.             -- check we can actually see this part of the entity
  11.             if pos.visible then
  12.             -- what info to draw
  13.                
  14.                 draw.DrawText( tostring( v:Health() ),
  15.                     -- what font to draw it in
  16.                     "Default",
  17.                     -- where to draw it
  18.                     pos.x, pos.y,
  19.                     -- what colour it must be
  20.                     Color(255, 255, 255),
  21.                     -- how to align the text
  22.                     TEXT_ALIGN_CENTER
  23.                 )
  24.                
  25.                
  26.             end
  27.         end
  28.     end
  29.    
  30.  
  31.  
  32. end
  33. hook.Add("HUDPaint", "ShowHealthAboveEnt", drawtrainhealth )
RAW Paste Data