Advertisement
VXP

ExpAdv2 - Draw text above head

VXP
Jun 10th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. client
  2. {
  3. function void drawAboveHead( string text )
  4. {
  5. setDrawColor(color(0, 0, 255))
  6. //drawBox(vec2(-150,-150),vec2(300,300))
  7. setFont("default", 50)
  8. drawTextCentered(vec2(0, -160), text)
  9. }
  10.  
  11. string headtext = "Who's there?"
  12.  
  13. event playerChat( player ply, string str, bool isTeam )
  14. {
  15. if( ply == owner() && !isTeam )
  16. {
  17. if( str.find("!draw ") != 0 )
  18. {
  19. number t = 6
  20.  
  21. // Stupid workaround for getting a string length
  22. table tempArr = str.explode("")
  23. number stringLength = tempArr.count()
  24.  
  25. headtext = str.sub( t + 1, stringLength )
  26. //print(stringLength, ",", headtext)
  27. printColor(color( 0, 255, 0 ), "Setting your head text to ", color( 255, 255, 255 ), headtext)
  28. }
  29. }
  30. }
  31.  
  32. event draw3D( )
  33. {
  34. //vector pos = entity().toWorld(vec(0, 0 ,0))
  35. //angle ang = entity().toWorld(ang(0,90,90))
  36. vector pos = owner().pos()
  37. angle angle = ang(0, owner().ang().getYaw() + 90, 90)
  38. //string text = "Who's there?"
  39.  
  40. start3D2D(pos, angle, 0.5)
  41. drawAboveHead(headtext)
  42. end3D2D()
  43. start3D2D(pos, angle + ang(0, 180, 0), 0.5)
  44. drawAboveHead(headtext)
  45. end3D2D()
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement