Advertisement
Guest User

Untitled

a guest
Aug 17th, 2016
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. if not engine.IsPlayingDemo() then return end
  2.  
  3. talkingPlayers = {}
  4.  
  5. function OnVoiceStarted( ply )
  6. if not table.HasValue( talkingPlayers, ply:Name()) then
  7. table.insert( talkingPlayers, ply:Name() )
  8. end
  9. --PrintTable( talkingPlayers )
  10. end
  11.  
  12. function OnVoiceEnd( ply )
  13. if vgui.GetWorldPanel():Find( ply:Name() ) != nil then
  14. vgui.GetWorldPanel():Find( ply:Name() ):Remove()
  15. end
  16. table.RemoveByValue( talkingPlayers, ply:Name())
  17. end
  18.  
  19. function getProfilePicture( ply )
  20. if vgui.GetWorldPanel():Find( ply:Name() ) != nil then
  21. return vgui.GetWorldPanel():Find( ply:Name() )
  22. end
  23. return nil
  24. end
  25.  
  26. function removeProfilePicture( ply )
  27. if vgui.GetWorldPanel():Find( ply:Name() ) != nil then
  28. vgui.GetWorldPanel():Find( ply:Name() ):Remove()
  29. end
  30. end
  31.  
  32.  
  33. function getPlayerByName( name )
  34. for k,v in pairs( player.GetAll() ) do
  35. if name == v:Name() then
  36. return v
  37. end
  38. end
  39. return nil
  40. end
  41.  
  42.  
  43. hook.Add( "PlayerStartVoice", "OnVoiceStarted", function(ply)
  44. OnVoiceStarted( ply )
  45. end)
  46.  
  47. hook.Add( "PlayerEndVoice", "OnVoiceEnd", function(ply)
  48. OnVoiceEnd( ply )
  49. end)
  50.  
  51. hook.Add( "HUDPaint", "DrawVoiceBoxes", function()
  52. if #talkingPlayers != 0 then
  53. local baseW = ScrW()-310
  54. local baseH = (ScrH()/2)+385
  55. local hIncrement = 0
  56. for i,name in ipairs( talkingPlayers ) do
  57. local ply = getPlayerByName( name )
  58. local profilepicture = getProfilePicture( ply )
  59. if profilepicture == nil then
  60. profilepicture = vgui.Create( "AvatarImage", self, ply:Name())
  61. profilepicture:SetSize( 32, 32 )
  62. profilepicture:SetPos( baseW+4, (baseH+4)-hIncrement )
  63. profilepicture:SetPlayer( ply, 32 )
  64. else
  65. profilepicture:SetPos( baseW+4, (baseH+4)-hIncrement )
  66. end
  67. draw.RoundedBox( 4, baseW, baseH-hIncrement, 246, 40, Color( 0, ply:VoiceVolume() * 255, 0, 240 ) )
  68. draw.DrawText( talkingPlayers[i], "GModNotify", baseW+45, (baseH+10)-hIncrement, Color( 255, 255, 255, 255 ), 0 )
  69. hIncrement = hIncrement + 45
  70. end
  71. end
  72. end)
  73.  
  74. print( "==============================================================" )
  75. print( "GMod Demo Voice Fix Script Loaded " )
  76. print( "Version: 1.0 " )
  77. print( "Created by youtube.com/videooven " )
  78. print( "==============================================================" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement