playing custom sounds.

Hi.

I have been working on an update to my script and I’m trying to get custom sounds to play, The problem is I don’t know which directory to put the custom MP3s into to play them. Do I put them in the same directory as where my script is (Lua folder) Or do I make a new folder and put the path to it.
E.G


Surface.PlaySound("startup.mp3")

Another problem I am going to have I think is if I have to make a new folder or something similar where would I put this when I upload the updated script with custom sounds to the workshop?

Thank you.

If your addon is in the addons folder, place it in /addons/<youraddon>/sound.
Also, if you are on a server you need to add it to /sound/
You’ll also need to use


resource.AddFile("sound/ayylmao.mp3")

to make the client download it and make sure sv_allowdownloads is set to 1.

Thanks for the help.

The issue is that it is a Clientside addon that you open with lua_openscript_cl for a gamemode called PK (propkill) where we use clientside addons to aid gameplay. The server itself would not run the addon, just the client.

I assume this would make saving things different? When I uploaded my script to the workshop, this is the process I did it in

Inside the lua folder was the addon you would open with lua_openscript_cl

Should I make a sound folder in the same place, and then do


Surface.PlaySound ("sound/startup.mp3")

In the code?

Apologies for this fairly simple query I just don’t want to get this wrong I’ve only ever worked with files that are in the same folder as the other in lua.

[editline]3rd September 2015[/editline]

Here is the error I am getting now.

I made a new folder in garrysmod/garrysmod called “Sound”.
Now I get this error


Failed to load sound "/garrysmod/sound/startup.mp3", file probably missing from disk/repository

I don’t know what I’m doing wrong.
I’ve tried both doing


surface.PlaySound("sound/startup.mp3")

And


surface.PlaySound("/garrysmod/sound/startup.mp3")

Both result in


Create Stream Failed error 41
Failed to load sound "\garrysmod\sound\startup.mp3", file probably missing from disk/repository
Create Stream Failed error 41
Failed to load sound "sound\startup.mp3", file probably missing from disk/repository


With play sound, “garrysmod/sound” is implied because thats where it looks for the sounds. Try just putting the file name and extension


surface.PlaySound("startup.mp3")

surface.PlaySound plays sounds directly from the sound/ directory.

I’ve made a folder called “sound” in this directory
C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod
then put startup.mp3 in it. I still get an error.

I tried making one in here as well with the file
C:\Program Files (x86)\Steam\steamapps\common\GarrysMod
and still receive the error.

when using


surface.PlaySound("startup.mp3")

C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\sound\startup.mp3

Or

C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\addons\myAddon\sound\startup.mp3

and then surface.PlaySound(“startup.mp3”)

Thanks guys, I tried to do this but it doesn’t seem to be working still hmm…

Are you sure the sound exists on your client?