• Playing Sound
    16 replies, posted
So, I am trying to play sound on when a round starts. The sound is located in garrysmod/sound/Welcome.wma Here is the code [CODE]ROUND_WAITING = 0 ROUND_PREPARING = 1 ROUND_ACTIVE = 2 ROUND_ENDING = 3 AddCSLuaFile() -- Send the file to the client. hook.Add( "OnRoundSet", "Round Set Example", function( round, winner ) if round == ROUND_WAITING then print( "We're waiting for the game to start!" ) elseif round == ROUND_PREPARING then print( "The round is preparing!" ) [B]surface.PlaySound( "/sound/Welcome.wma" )[/B] elseif round == ROUND_ACTIVE then print( "Let's play!" ) elseif round == ROUND_ENDING then print( "The winner is "..winner.."!" ) -- If the winner is the timelimit, it will be the number 123. if winner != 123 then print( team.GetName(winner).." is awesome!" ) end end end )[/CODE] But I get 'gmod surface a nil value' why do I get it? The file is sv_round.lua part of the Deathrun gamemode. I am starting to think /sound/Welcome.wma but were does PlaySound point to by default?
[QUOTE=Tehepicford;42063452]...[/QUOTE] Try without the first / in surface.PlaySound If that doesn't work, try wihout sound/
[QUOTE=MeepDarknessM;42063488]Try without the first / in surface.PlaySound If that doesn't work, try wihout sound/[/QUOTE] Nope don't work.
[QUOTE=Tehepicford;42063499]Nope don't work.[/QUOTE] I am not sure if wma file types are supported, would you try converting it to a wav or mp3?
[QUOTE=MeepDarknessM;42063599]I am not sure if wma file types are supported, would you try converting it to a wav or mp3?[/QUOTE] I've tried unconverted mp3's and wav's no luck...
Create a singleplayer server with that file in your garrysmod/garrysmod/sound folder, then in game type "sound <file>". See if that creates a suggestion. If not, try other names such as sound/<file> or /<file>
Can someone who knows what they are talking about help me?
Oh sorry, I thought sound was still in existance. The directory surface.PlaySound points at garrysmod/garrysmod/sound/. You want to use surface.PlaySound("Welcome.wma") If that doesn't work, it is probably one of three things: 1. Doesn't support wma / You don't have it downloaded 2. Didn't put it in the right folder 3. File is corrupt
[QUOTE=MeepDarknessM;42063952]Oh sorry, I thought sound was still in existance. The directory surface.PlaySound points at garrysmod/garrysmod/sound/. You want to use surface.PlaySound("Welcome.wma") If that doesn't work, it is probably one of three things: 1. Doesn't support wma / You don't have it downloaded 2. Didn't put it in the right folder 3. File is corrupt[/QUOTE] It makes a diference but [ERROR] gamemodes/deathrun/gamemode/sv_round.lua:15: attempt to index global 'surface' (a nil value)
[QUOTE=Tehepicford;42064122]It makes a diference but [ERROR] gamemodes/deathrun/gamemode/sv_round.lua:15: attempt to index global 'surface' (a nil value)[/QUOTE] You are trying to run a surface library function (client) on the server.
[QUOTE=MeepDarknessM;42064221]You are trying to run a surface library function (client) on the server.[/QUOTE] I'm a noob at Lua surface.PlaySound( "radioactive.mp3" ) fix?
[QUOTE=Tehepicford;42064229]I'm a noob at lua[/QUOTE] "Can someone who knows what their talking about help me?" Idiot
[QUOTE=Tehepicford;42064229]I'm a noob at Lua surface.PlaySound( "radioactive.mp3" ) fix?[/QUOTE] easiest way: [lua] for i, ply in ipairs(player.GetAll()) do ply:SendLua('surface.PlaySound("radioactive.mp3")'); end [/lua]
[QUOTE=MeepDarknessM;42064254]easiest way: [lua] for i, ply in ipairs(player.GetAll()) do ply:SendLua('surface.PlaySound("radioactive.mp3")'); end [/lua][/QUOTE] Console Error: Create Stream Failed error 41 Failed to load sound "radioactive.mp3", file probably missing from disk/repository R I tried putting it in 'gmod/garrysmod/sound', 'gmod/garrysmod', 'gmod' using [CODE] for i, ply in ipairs(player.GetAll()) do ply:SendLua('surface.PlaySound("radioactive.mp3")'); end[/CODE] full code [CODE]ROUND_WAITING = 0 ROUND_PREPARING = 1 ROUND_ACTIVE = 2 ROUND_ENDING = 3 AddCSLuaFile() -- Send the file to the client. hook.Add( "OnRoundSet", "Round Set Example", function( round, winner ) if round == ROUND_WAITING then print( "We're waiting for the game to start!" ) elseif round == ROUND_PREPARING then print( "The round is preparing!" ) for i, ply in ipairs(player.GetAll()) do ply:SendLua('surface.PlaySound("radioactive.mp3")'); end elseif round == ROUND_ACTIVE then print( "Let's play!" ) elseif round == ROUND_ENDING then print( "The winner is "..winner.."!" ) -- If the winner is the timelimit, it will be the number 123. if winner != 123 then print( team.GetName(winner).." is awesome!" ) end end end )[/CODE]
did you add the file to fastdl (ignore if you don't use fastdl), and resource.AddFile the file?
[QUOTE=MeepDarknessM;42064339]did you add the file to fastdl (ignore if you don't use fastdl), and resource.AddFile the file?[/QUOTE] Fon't have FastDL and how do I use resouce.Addfile? I know, I am very stupid.
[QUOTE=Tehepicford;42064361]Fon't have FastDL and how do I use resouce.Addfile? I know, I am very stupid.[/QUOTE] [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5809.html]resource.AddFile - maurits.tv[/url]
Sorry, you need to Log In to post a reply to this thread.