• surface.PlaySound Error | File Missing from Disk/Repository
    4 replies, posted
So im running a round based gamemode, and at the end of each round I want to play a .wav sound file. It has no errors but when the time comes for it to play the sound file it comes up with an error client side saying that the <file name>.wav is missing from the Disk/Repository. Not sure how to fix this, but here is the code im using in the lua/autorun/server/winsounds.lua [code] hook.Add( "OnRoundSet", "Round Set Example", function( round, winner ) if round == ROUND_ENDING then if winner == TEAM_RUNNER then BroadcastLua('surface.PlaySound("/netbreaking/runnerswin.wav")') elseif winner == TEAM_DEATH then BroadcastLua('surface.PlaySound("/netbreaking/deathswin.wav")') elseif winner == 123 then -- If the winner is the timelimit, it will be the number 123. BroadcastLua('surface.PlaySound("/netbreaking/deploy.wav")') end end end ) [/code] the files are just located in sound/netbreaking but they have been in /sound/ and they still didn't work there. If anyone could help me with this that would be amazing!
why do you have the first / in the file name?
[QUOTE=JetBoom;39534892]why do you have the first / in the file name?[/QUOTE] I've tried it both with and without, it does nothing different.
[QUOTE=Richtofen;39534901]I've tried it both with and without, it does nothing different.[/QUOTE] Try surface.PlaySound( Sound(sndpath) ) that'll precache the sound and may help against the problem.
How are your players downloading this, are you using Fast DL? You need to resource.AddFile all of the sounds. Example: [lua] resource.AddFile("sound/directory/WhateverYourSoundIs.mp3") hook.Add( "OnRoundSet", "Round Set Example", function( round, winner ) if round == ROUND_ENDING then if winner == TEAM_RUNNER then BroadcastLua('surface.PlaySound("/netbreaking/runnerswin.wav")') elseif winner == TEAM_DEATH then BroadcastLua('surface.PlaySound("/netbreaking/deathswin.wav")') elseif winner == 123 then -- If the winner is the timelimit, it will be the number 123. BroadcastLua('surface.PlaySound("/netbreaking/deploy.wav")') end end end ) [/lua] Use this for the surface.PlaySound (relative to the sound directory): [lua] BroadcastLua('surface.PlaySound(directory/WhateverYourSoundIs.mp3")') [/lua] In your case it would be: [lua] BroadcastLua('surface.PlaySound("netbreaking/runnerswin.wav")') BroadcastLua('surface.PlaySound("netbreaking/deathswin.wav")') BroadcastLua('surface.PlaySound("netbreaking/deploy.wav")') [/lua]
Sorry, you need to Log In to post a reply to this thread.