Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. local SoundList = { }
  2. local Punctuation = {"", " ", ".", ",", "!", "\"", "'", "?", "~", "*", "-", "=", "+", "(", ")", ":", ";", "#", "_", "&", "^", "@"}
  3. local EndingOnlyPunctuation = {"s"}
  4. local MutedPlayers = { }
  5.  
  6.  
  7. -- HALF-LIFE 2, EPISODE 1, AND EPISODE 2 SOUNDS
  8.  
  9.  
  10. SoundList[ "%." ] = { {0.0001, ""} }
  11.  
  12. SoundList[ "aah" ] = { {0.0002, "vo/k_lab/kl_ahhhh.wav"} }
  13. SoundList[ "this way" ] = { {1.1672109365463, "vo/npc/barney/ba_followme01.wav"} }
  14. SoundList[ "watch out" ] = { {0.72707492113113, "vo/npc/female01/watchout.wav"} }
  15. SoundList[ "welcome" ] = { {4, "vo/Breencast/br_welcome01.wav" } }
  16.  
  17.  
  18. -- PORTAL SOUNDS
  19.  
  20. SoundList[ "goodbye" ] = { {0.8475056886673, "npc/turret_floor/turret_retire_1.wav"} }
  21. SoundList[ "excuse me" ] = { {1.161337852478, "npc/turret_floor/turret_collide_2.wav"} }
  22.  
  23. -- TF2 SOUNDS
  24.  
  25. SoundList[ "alert" ] = { {1.3508616685867, "vo/announcer_alert.mp3"} }
  26. SoundList[ "attention" ] = { {1.6730386018753, "vo/announcer_attention.mp3"} }
  27.  
  28. SoundList[ "tf1" ] = { {1, "vo/announcer_ends_1sec.mp3"} }
  29. SoundList[ "tf2" ] = { {1, "vo/announcer_ends_2sec.mp3"} }
  30. SoundList[ "tf3" ] = { {1, "vo/announcer_ends_3sec.mp3"} }
  31. SoundList[ "tf4" ] = { {1, "vo/announcer_ends_4sec.mp3"} }
  32. SoundList[ "tf5" ] = { {1, "vo/announcer_ends_5sec.mp3"} }
  33. SoundList[ "tf6" ] = { {1, "vo/announcer_ends_6sec.mp3"} }
  34. SoundList[ "tf7" ] = { {1, "vo/announcer_ends_7sec.mp3"} }
  35. SoundList[ "tf8" ] = { {1, "vo/announcer_ends_8sec.mp3"} }
  36. SoundList[ "tf9" ] = { {1, "vo/announcer_ends_9sec.mp3"} }
  37. SoundList[ "nix da" ] = { {0.5, "vo/medic_no03.mp3"} }
  38.  
  39.  
  40.  
  41. -- CS:S SOUNDS
  42.  
  43.  
  44. SoundList[ "ok let's go" ] = { {1.3682539463043, "radio/go.wav"} }
  45. SoundList[ "gogogo" ] = { {1.3292063474655, "radio/com_go.wav"} }
  46. SoundList[ "go go go" ] = { {1.3292063474655, "radio/com_go.wav"} }
  47.  
  48.  
  49. local soundkeys = { }
  50. for k,v in pairs(SoundList) do
  51. table.insert(soundkeys, k)
  52. end
  53. table.sort(soundkeys, function(a,b) return string.len(a) > string.len(b) end) -- Sort the list into size descending
  54.  
  55.  
  56. local function GetList(text)
  57. local TextList = { }
  58. for k,v in pairs(soundkeys) do
  59. if v ~= "" then
  60. local last_find = 0
  61. local incpos = 0
  62. while last_find ~= nil do
  63. local Find, FindEnd = string.find(string.lower(text), string.lower(v))
  64. if Find then
  65. local beforec = string.sub(text, Find-1, Find-1)
  66. local afterc = string.sub(text, FindEnd+1, FindEnd+1)--EndingOnlyPunctuation
  67. if k == "%." or (table.HasValue(Punctuation, beforec) and ((table.HasValue(Punctuation, afterc) or table.HasValue(EndingOnlyPunctuation, afterc)) or afterc == string.sub(text, FindEnd, FindEnd))) then
  68. table.insert(TextList, {Find, v})
  69. text = string.sub(text, 1, Find-1) .. string.rep(" ", string.len(v)) .. string.sub(text, FindEnd+1)
  70. else
  71. FindEnd = nil
  72. end
  73. end
  74. last_find = FindEnd
  75. end
  76. end
  77. end
  78. return TextList
  79. end
  80.  
  81. local function DoSound( ply, snd, num )
  82. if IsValid(ply) then
  83. if MutedPlayers[ply:UniqueID( )] then return; end
  84. num = num or 0
  85. local pitch = math.random( 94, 102 )
  86. for i = 1, num+1 do
  87. ply:EmitSound(Sound(snd), 90, pitch)
  88. end
  89. end
  90. end
  91.  
  92. local function PlayerSay( ply, text )
  93. if MutedPlayers[ply:UniqueID( )] then return; end
  94. local TextList = GetList(text)
  95.  
  96. if #TextList > 1 then
  97. table.sort(TextList, function(a, b) return a[1] < b[1] end)
  98. end
  99.  
  100. local _, num = string.gsub(text, "[!]", "")
  101. local Time = 0
  102. for k,v in pairs(TextList) do
  103. local sound = SoundList[v[2]][math.random(#SoundList[v[2]])]
  104. if not sound then return; end
  105. if sound[2] and sound[2] ~= "" then
  106. local i
  107. timer.Simple(Time, function() DoSound(ply, sound[2], num) end)
  108. end
  109. Time = Time + sound[1]
  110. end
  111. end
  112. hook.Add("PlayerSay", "ChatSounds2", PlayerSay)
  113.  
  114. local function PlaySound( ply, c, arg )
  115. PlayerSay( ply, table.concat(arg, " "))
  116. end
  117. concommand.Add("saysound", PlaySound)
  118.  
  119.  
  120. local function MutePlayer( ply, arg )
  121. if not ply:IsAdmin( ) then return; end
  122. if not arg[1] or not arg[2] then
  123. if CLIENT then
  124. ply:PrintMessage(3, "Usage: !chatmute name")
  125. end
  126. end
  127. local mutee
  128. if arg[1] == "!chatmute" then
  129. for k,v in pairs(player.GetAll( )) do
  130. if string.find(string.lower(v:GetName( )), string.lower(arg[1])) then mutee = v; break end
  131. end
  132. if not mutee then return end
  133.  
  134. if arg[2] == "1" then
  135. ply:PrintMessage( HUD_PRINTTALK, "Muted player: " .. mutee:GetName( ) )
  136. MutedPlayers[mutee:UniqueID( )] = true;
  137. else
  138. ply:PrintMessage( HUD_PRINTTALK, "Unmuted player: " .. mutee:GetName( ) )
  139. MutedPlayers[mutee:UniqueID( )] = nil;
  140. end
  141. end
  142. end
  143.  
  144. hook.Add( "PlayerSay", "chatcheckere", MutePlayer)
  145.  
  146.  
  147. local function FindSound( ply, c, arg )
  148. if not arg[1] then
  149. ply:PrintMessage(HUD_PRINTCONSOLE, "Usage: chatsounds_find <pattern>\n\tPattern can be either a normal string or a regex pattern, escape char is %. Normal strings may need escaping.")
  150. return;
  151. end
  152. for k, v in pairs(SoundList) do
  153. if string.find(v, arg[1]) then
  154. ply:PrintMessage(HUD_PRINTCONSOLE, v)
  155. end
  156. end
  157. end
  158. concommand.Add("chatsounds_find", FindSound)
  159.  
  160. function print_sounds(p,c,a)
  161. for k,v in pairs(SoundList) do
  162. p:PrintMessage(HUD_PRINTCONSOLE, k )
  163. end
  164. end
  165. concommand.Add("print_sounds", print_sounds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement