• My Custom TTT Sounds Won't Play
    6 replies, posted
[code] resource.AddFile("sound/ttt/tators.wav") resource.AddFile("sound/ttt/roundstart.mp3") local function PlayMusic(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("ttt/thump01e.mp3")') else BroadcastLua('surface.PlaySound("ttt/tators.wav")') end end hook.Add("TTTEndRound", "MyMusic", PlayMusic) local function PlayStartMusic() if ROUND_BEGIN then BroadcastLua('surface.PlaySound("ttt/roundstart.mp3")') end hook.Add("TTTBeginRound", "MyStartMusic", PlayStartMusic) [/code] That is the code for it. It is located in lua/autorun/server . The sounds won't play. I get no error also.
1) .mp3s Wont play. 2) Filepaths?
You're missing an end. [QUOTE=DrJenkins;34663652]1) .mp3s Wont play.[/QUOTE] Mp3s work fine for me, even default hl2 sounds use the mp3 extension occasionally.
-snip- I use: [lua] BroadcastLua([[LocalPlayer():EmitSound(']].. soundhere ..[[')]]) [/lua]
[QUOTE=leiftiger;34664470]You're missing an end. Mp3s work fine for me, even default hl2 sounds use the mp3 extension occasionally.[/QUOTE] Well I fixed it but took out htat if statement so iwasnt missing the end
[QUOTE=InfernalCookie;34673492]I use: [lua] BroadcastLua([[LocalPlayer():EmitSound(']].. soundhere ..[[')]]) [/lua][/QUOTE] surface.PlaySound is better, imo Personally, I'd use usermessages instead of BroadcastLua [lua]--Server side umsg.Start("TTTPlayCustomSound") umsg.String( SoundPath ) umsg.End() --Client Side usermessage.Hook("TTTPlayCustomSound", function( um ) local str = um:ReadString() surface.PlaySound( str ) end)[/lua] But it shouldn't make a real difference to functionality As for the problem, if this code doesn't work: [lua]local function PlayMusic(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("ttt/thump01e.mp3")') else BroadcastLua('surface.PlaySound("ttt/tators.wav")') end end hook.Add("TTTEndRound", "MyMusic", PlayMusic) local function PlayStartMusic() BroadcastLua('surface.PlaySound("ttt/roundstart.mp3")') end hook.Add("TTTBeginRound", "MyStartMusic", PlayStartMusic)[/lua] First thing I'd look for is lua errors Make sure there's no client-side error saying you're missing the sound, something along the lines of: Failed to load sound "ttt/tators.wav", file probably missing from disk/repository If that shows, your clients aren't downloading the sound properly, make sure it's on your server, and your fastdl if you're using one If not, make sure your script is actually running A simple msg like [lua]MsgN([[ ******************** A very obvious Msg! This script runs! ******************** ]])[/lua] should make it obvious
If you llook above i have fixed it xD
Sorry, you need to Log In to post a reply to this thread.