Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1.  
  2. CreateConVar('talkicon_computablecolor', 1, FCVAR_ARCHIVE + FCVAR_REPLICATED + FCVAR_SERVER_CAN_EXECUTE, 'Compute color from location brightness.')
  3. CreateConVar('talkicon_showtextchat', 1, FCVAR_ARCHIVE + FCVAR_REPLICATED + FCVAR_SERVER_CAN_EXECUTE, 'Show icon on using text chat.')
  4. CreateConVar('talkicon_ignoreteamchat', 1, FCVAR_ARCHIVE + FCVAR_REPLICATED + FCVAR_SERVER_CAN_EXECUTE, 'Disable over-head icon on using team chat.')
  5.  
  6. if (SERVER) then
  7.  
  8. RunConsoleCommand('mp_show_voice_icons', '0')
  9.  
  10. resource.AddFile('materials/talkicon/voice.png')
  11. resource.AddFile('materials/talkicon/text.png')
  12.  
  13. util.AddNetworkString('TalkIconChat')
  14.  
  15. net.Receive('TalkIconChat', function(_, ply)
  16. local bool = net.ReadBool()
  17. ply:SetNW2Bool('ti_istyping', (bool ~= nil) and bool or false)
  18. end)
  19.  
  20. elseif (CLIENT) then
  21.  
  22. local computecolor = GetConVar('talkicon_computablecolor')
  23. local showtextchat = GetConVar('talkicon_showtextchat')
  24. local noteamchat = GetConVar('talkicon_ignoreteamchat')
  25.  
  26. local voice_mat = Material('talkicon/voice.png')
  27. local text_mat = Material('talkicon/text.png')
  28.  
  29. hook.Add('PostPlayerDraw', 'TalkIcon', function(ply)
  30. if ply == LocalPlayer() and GetViewEntity() == LocalPlayer()
  31. and (GetConVar('thirdperson') and GetConVar('thirdperson'):GetInt() != 0) then return end
  32. if not ply:Alive() then return end
  33. if not ply:IsSpeaking() and not (showtextchat:GetBool() and ply:GetNW2Bool('ti_istyping')) then return end
  34.  
  35. local pos = ply:GetPos() + Vector(0, 0, ply:GetModelRadius() + 25)
  36.  
  37. local attachment = ply:GetAttachment(ply:LookupAttachment('eyes'))
  38. if attachment then
  39. pos = ply:GetAttachment(ply:LookupAttachment('eyes')).Pos + Vector(0, 0, 25)
  40. end
  41.  
  42. render.SetMaterial(ply:IsSpeaking() and voice_mat or text_mat)
  43.  
  44. local color_var = 255
  45.  
  46. if computecolor:GetBool() then
  47. local computed_color = render.ComputeLighting(ply:GetPos(), Vector(0, 0, 1))
  48. local max = math.max(computed_color.x, computed_color.y, computed_color.z)
  49. color_var = math.Clamp(max * 255 * 1.11, 0, 255)
  50. end
  51.  
  52. render.DrawSprite(pos, 12, 12, Color(color_var, color_var, color_var, 255))
  53. end)
  54.  
  55. hook.Add('StartChat', 'TalkIcon', function(isteam)
  56. if isteam and noteamchat:GetBool() then return end
  57. net.Start('TalkIconChat')
  58. net.WriteBool(true)
  59. net.SendToServer()
  60. end)
  61.  
  62. hook.Add('FinishChat', 'TalkIcon', function()
  63. net.Start('TalkIconChat')
  64. net.WriteBool(false)
  65. net.SendToServer()
  66. end)
  67.  
  68. hook.Add("InitPostEntity", "RemoveChatBubble", function()
  69. hook.Remove("StartChat", "StartChatIndicator")
  70. hook.Remove("FinishChat", "EndChatIndicator")
  71. end)
  72.  
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement