Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SoundList = { }
- local Punctuation = {"", " ", ".", ",", "!", "\"", "'", "?", "~", "*", "-", "=", "+", "(", ")", ":", ";", "#", "_", "&", "^", "@"}
- local EndingOnlyPunctuation = {"s"}
- local MutedPlayers = { }
- -- HALF-LIFE 2, EPISODE 1, AND EPISODE 2 SOUNDS
- SoundList[ "%." ] = { {0.0001, ""} }
- SoundList[ "aah" ] = { {0.0002, "vo/k_lab/kl_ahhhh.wav"} }
- SoundList[ "this way" ] = { {1.1672109365463, "vo/npc/barney/ba_followme01.wav"} }
- SoundList[ "watch out" ] = { {0.72707492113113, "vo/npc/female01/watchout.wav"} }
- SoundList[ "welcome" ] = { {4, "vo/Breencast/br_welcome01.wav" } }
- -- PORTAL SOUNDS
- SoundList[ "goodbye" ] = { {0.8475056886673, "npc/turret_floor/turret_retire_1.wav"} }
- SoundList[ "excuse me" ] = { {1.161337852478, "npc/turret_floor/turret_collide_2.wav"} }
- -- TF2 SOUNDS
- SoundList[ "alert" ] = { {1.3508616685867, "vo/announcer_alert.mp3"} }
- SoundList[ "attention" ] = { {1.6730386018753, "vo/announcer_attention.mp3"} }
- SoundList[ "tf1" ] = { {1, "vo/announcer_ends_1sec.mp3"} }
- SoundList[ "tf2" ] = { {1, "vo/announcer_ends_2sec.mp3"} }
- SoundList[ "tf3" ] = { {1, "vo/announcer_ends_3sec.mp3"} }
- SoundList[ "tf4" ] = { {1, "vo/announcer_ends_4sec.mp3"} }
- SoundList[ "tf5" ] = { {1, "vo/announcer_ends_5sec.mp3"} }
- SoundList[ "tf6" ] = { {1, "vo/announcer_ends_6sec.mp3"} }
- SoundList[ "tf7" ] = { {1, "vo/announcer_ends_7sec.mp3"} }
- SoundList[ "tf8" ] = { {1, "vo/announcer_ends_8sec.mp3"} }
- SoundList[ "tf9" ] = { {1, "vo/announcer_ends_9sec.mp3"} }
- SoundList[ "nix da" ] = { {0.5, "vo/medic_no03.mp3"} }
- -- CS:S SOUNDS
- SoundList[ "ok let's go" ] = { {1.3682539463043, "radio/go.wav"} }
- SoundList[ "gogogo" ] = { {1.3292063474655, "radio/com_go.wav"} }
- SoundList[ "go go go" ] = { {1.3292063474655, "radio/com_go.wav"} }
- local soundkeys = { }
- for k,v in pairs(SoundList) do
- table.insert(soundkeys, k)
- end
- table.sort(soundkeys, function(a,b) return string.len(a) > string.len(b) end) -- Sort the list into size descending
- local function GetList(text)
- local TextList = { }
- for k,v in pairs(soundkeys) do
- if v ~= "" then
- local last_find = 0
- local incpos = 0
- while last_find ~= nil do
- local Find, FindEnd = string.find(string.lower(text), string.lower(v))
- if Find then
- local beforec = string.sub(text, Find-1, Find-1)
- local afterc = string.sub(text, FindEnd+1, FindEnd+1)--EndingOnlyPunctuation
- 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
- table.insert(TextList, {Find, v})
- text = string.sub(text, 1, Find-1) .. string.rep(" ", string.len(v)) .. string.sub(text, FindEnd+1)
- else
- FindEnd = nil
- end
- end
- last_find = FindEnd
- end
- end
- end
- return TextList
- end
- local function DoSound( ply, snd, num )
- if IsValid(ply) then
- if MutedPlayers[ply:UniqueID( )] then return; end
- num = num or 0
- local pitch = math.random( 94, 102 )
- for i = 1, num+1 do
- ply:EmitSound(Sound(snd), 90, pitch)
- end
- end
- end
- local function PlayerSay( ply, text )
- if MutedPlayers[ply:UniqueID( )] then return; end
- local TextList = GetList(text)
- if #TextList > 1 then
- table.sort(TextList, function(a, b) return a[1] < b[1] end)
- end
- local _, num = string.gsub(text, "[!]", "")
- local Time = 0
- for k,v in pairs(TextList) do
- local sound = SoundList[v[2]][math.random(#SoundList[v[2]])]
- if not sound then return; end
- if sound[2] and sound[2] ~= "" then
- local i
- timer.Simple(Time, function() DoSound(ply, sound[2], num) end)
- end
- Time = Time + sound[1]
- end
- end
- hook.Add("PlayerSay", "ChatSounds2", PlayerSay)
- local function PlaySound( ply, c, arg )
- PlayerSay( ply, table.concat(arg, " "))
- end
- concommand.Add("saysound", PlaySound)
- local function MutePlayer( ply, arg )
- if not ply:IsAdmin( ) then return; end
- if not arg[1] or not arg[2] then
- if CLIENT then
- ply:PrintMessage(3, "Usage: !chatmute name")
- end
- end
- local mutee
- if arg[1] == "!chatmute" then
- for k,v in pairs(player.GetAll( )) do
- if string.find(string.lower(v:GetName( )), string.lower(arg[1])) then mutee = v; break end
- end
- if not mutee then return end
- if arg[2] == "1" then
- ply:PrintMessage( HUD_PRINTTALK, "Muted player: " .. mutee:GetName( ) )
- MutedPlayers[mutee:UniqueID( )] = true;
- else
- ply:PrintMessage( HUD_PRINTTALK, "Unmuted player: " .. mutee:GetName( ) )
- MutedPlayers[mutee:UniqueID( )] = nil;
- end
- end
- end
- hook.Add( "PlayerSay", "chatcheckere", MutePlayer)
- local function FindSound( ply, c, arg )
- if not arg[1] then
- 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.")
- return;
- end
- for k, v in pairs(SoundList) do
- if string.find(v, arg[1]) then
- ply:PrintMessage(HUD_PRINTCONSOLE, v)
- end
- end
- end
- concommand.Add("chatsounds_find", FindSound)
- function print_sounds(p,c,a)
- for k,v in pairs(SoundList) do
- p:PrintMessage(HUD_PRINTCONSOLE, k )
- end
- end
- concommand.Add("print_sounds", print_sounds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement