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
[CODE]Surface.PlaySound("startup.mp3")[/CODE]
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
[CODE]resource.AddFile("sound/ayylmao.mp3")[/CODE]
to make the client download it and make sure sv_allowdownloads is set to 1.
[QUOTE=YaYaBinks3;48606621]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
[CODE]resource.AddFile("sound/ayylmao.mp3")[/CODE]
to make the client download it and make sure sv_allowdownloads is set to 1.[/QUOTE]
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
[IMG]http://i.imgur.com/Kz5nyVd.png[/IMG]
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
[CODE]Surface.PlaySound ("sound/startup.mp3")[/CODE]
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
[CODE]Failed to load sound "/garrysmod/sound/startup.mp3", file probably missing from disk/repository[/CODE]
I don't know what I'm doing wrong.
I've tried both doing
[CODE]surface.PlaySound("sound/startup.mp3")[/CODE]
And
[CODE]surface.PlaySound("/garrysmod/sound/startup.mp3")[/CODE]
Both result in
[CODE]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
[/CODE]
With play sound, "garrysmod/sound" is implied because thats where it looks for the sounds. Try just putting the file name and extension
[CODE]surface.PlaySound("startup.mp3")[/CODE]
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
[CODE]surface.PlaySound("startup.mp3")[/CODE]
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")
[QUOTE=Exho;48607890]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")[/QUOTE]
Thanks guys, I tried to do this but it doesn't seem to be working still hmm...
[QUOTE=serverwatch;48609624]Thanks guys, I tried to do this but it doesn't seem to be working still hmm...[/QUOTE]
Are you sure the sound exists on your client?
Sorry, you need to Log In to post a reply to this thread.