Custom Sound questions

So I have a few questions about sound in Garrys mod, The first being is there any specific place in my custom gamemode’s folders where I can to put custom sound content?, Then how could I have it where everyone can hear the custom sound? and last if I wanted to use this sound would I have to put the sound directories in the name?

put it in sound?

and resource.AddFile(“path/ursound.wav”)
example: resource.AddFile(“sound/banned.wav”) <- put that in any serverside file

And if you want everyone to hear the sounds you can make a script that does that, or you can use lua_run, if only you want to hear it you can use play, e.g play banned.wav

resource.Addfile doesn’t seem to work when I put it in my init.lua file and where do I put my custom sound file?

It should work.

In my addon i have lua, resource, sound

I then put my sounds in sound, then in my resources.lua i have resource.AddFile(“sound/banned.wav”)

And i assume you put them in content/sound?

and for the record its not resource.Addfile its resource.AddFile, lua is case sensetive.

its not a addon… Its a gamemode

It works pretty much the same way?

I just gave you a few examples on how i do it with my addon, do you want me to give you 100% detailed drawn map on how 2 install sounds to your gamemode?

Here’s an example of an addon that includes sound in the addon folder, and resource.AddFiles it…
https://dl.dropboxusercontent.com/u/26074909/tutoring/_zipped_code/acecool_ttt_end_round_music.rar

You can put sound files in your gamemodes content folder ( make sure you resource.AddFile or resource.AddSingleFile each sound ): garrysmod/gamemodes/your_gm_name/content/sound/*

If you’re using FastDL ( or want to ): https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/fastdl_setup_instructions.lua.html

Alright It seems to have downloaded now but I can’t seem to get the sound plating here is my code:


ply:EmitSound(Sound("garrysmod/gamemodes/war/content/sound/celebrate.wav")

and in the client console it says:


 Failed to load sound "garrysmod\gamemodes\war\content\sound\celebrate.wav", file probably missing from disk/repository

Im pretty sure its because you aren’t suppose to put the entire path. for example:


ply:EmitSound(Sound("celebrate.wav")

If you had celebrate.wav in another folder in the sound folder then it would look like:


ply:EmitSound(Sound("partysounds/celebrate.wav")

Yea I have tried that and it comes up with same error, One thing that might be wrong is that im running this in a serverside file so could that be something?

You would have to use this instead: http://wiki.garrysmod.com/page/Global/EmitSound

just set the position of the sound to ply:GetPos(). I’m not quite sure if this will work though.

its still coming up with the same error

Don’t use Sound( ); just pass in the string of the sound location. sound/ and anything before it is omitted.

Example:
Entity:EmitSound( “vo/npc/female01/goodgod.wav” );

Try typing this in console: play vo/npc/female01/goodgod.wav

This is still not working so I will try to be very descriptive, The Sound is in Mygamemode/content/sound/celebrate.wav , This is my code in init.lua:


function Lifetimer(ply)
timer.Create("Alivetimer", 30, 1, function() umsg.Start("Life", ply)
	umsg.End() ply:Give("weapon_rpg") ply:EmitSound( "content/sound/celebrate.wav" ) end)
timer.Start("Alivetimer")
if ply:Alive() then return false 
	else timer.Stop("Alivetimer")
	end
end



resource.AddFile("garrysmod/gamemodes/war/content/sound/celebrate.wav")

And I get the same error:
Failed to load sound “content\sound\celebrate.wav”, file probably missing from disk/repository

You dont have to put content or sound in the file path.


ply:EmitSound( "celebrate.wav" )

If you use the play console command, you’ll find that “play celebrate.wav” will play, or give an error ( can’t find file, or file is not 41000Hz or so )

Yea I can’t play it through console I get this error:
Failed to load sound “celebrate.wav”, file probably missing from disk/repository

Then it didn’t download properly. If you use FastDL, it is possible to have the file download into a completely wrong directory. Make sure you follow this: https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/fastdl_setup_instructions.lua.html