Advertisement
Guest User

Untitled

a guest
Apr 13th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. --[[
  2. Name: "sh_typing.lua".
  3. Author: "Chessnut".
  4. ]]--
  5.  
  6. if ( SERVER ) then
  7. --A console command for when the player starts typing.
  8. concommand.Add("player_type_start", function(player, command, arguments)
  9. if ( player:IsValid() ) then
  10. player:SetNetworkedBool("shTyping", true);
  11. end;
  12. end;
  13.  
  14. --A console command for when the player has stopped typing.
  15. concommand.Add("player_type_stop", function(player, command, arguments)
  16. if ( playerIsValid() ) then
  17. player:SetNetworkedBool("shTyping", false);
  18. end;
  19. end;
  20. else
  21. --A hook for when the player starts typing.
  22. hook.Add("StartChat", "chatStart", function()
  23. RunConsoleCommand("player_type_start");
  24. end);
  25.  
  26. --A hook for when the player is done typing.
  27. hook.Add("FinishChat", "chatStop", function()
  28. RunConsoleCommand("player_type_stop");
  29. end);
  30.  
  31. --A function to draw the typing display.
  32. hook.Add("HUDPaint", function(player)
  33. if ( LocalPlayer():Alive() and LocalPlayer():Alive() ) then
  34. local fadeDistance = 128;
  35.  
  36. -- Check if the player is alive.
  37. if ( player:Alive() ) then
  38. if ( player != LocalPlayer() ) then
  39. if (!player._KnockedOut) then
  40. if ( player:GetNetworkedBool("isTyping") ) then
  41. local alpha = math.Clamp(255 - ( (255 / fadeDistance) * player:GetShootPos():Distance( LocalPlayer():GetShootPos() ) ), 0, 255);
  42.  
  43. -- Define the x and y position.
  44. local x = player:GetShootPos():ToScreen().x;
  45. local y = player:GetShootPos():ToScreen().y - 64;
  46.  
  47. -- Check if the position is visible.
  48. if (player:GetShootPos():ToScreen().visible) then
  49. y = y + (32 * (LocalPlayer():GetShootPos():Distance( player:GetShootPos() ) / fadeDistance)) * 0.5;
  50.  
  51.  
  52. -- Draw the information.
  53. draw.SimpleTextOutlined("TEST", "ChatFont", x, y + math.sin( CurTime() ) * 8, Color(0, 0, 0, alpha), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 5, Color(255, 255, 255, alpha);
  54. end;
  55. end;
  56. end;
  57. end;
  58. end;
  59. end;
  60. end);
  61. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement