Help!: Adding music to end of round. (TTT)

I have this lua code in ‘./garrysmod/lua/autorun/’ folder for my server:


-- You can add up to 3 sounds for this. Add or delete resource.addfile as you need
resource.AddFile("sound/cakeisgone.mp3")

-- Remember to change the name of the sounds to the sound you want from above
function PlayMusic(wintype)
     BroadcastLua('surface.PlaySound("cakeisgone.mp3")')
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)

Every time I join my server it downloads cakeisgone.mp3 and then I can’t find it anywhere in MY garrysmod files.
Why won’t it download properly and reuse it?

Then I go into to my server and after the round ends, no music it played and in the console it says it can’t find the cakeisgone.mp3.

I think the problem is that it cannot download the file? Any ideas would help! Thanks.

You using fastdl?

No, is that required? I know their has to be a certain size of file that it uses?

No it’s not required at all, however it can cause problems with people downloading the files. So don’t worry about that.

I did a look up of FastDL:
So what I did was I didn’t realize that I had a site already set up with my host and was already set up in the server.cfg file. Added cakeisgone.mp3 to a folder called sound on the site and now it downloads the song and doesn’t ask for it again :smiley:

But it still doesn’t play the song and say the same error again above in picture 2.

On the clientside lua (cl_init), try using
[LUA]
util.PrecacheSound(“cakeisgone.mp3”)
[/LUA]
since it will be playing there.

If the above post doesn’t work, try adding sound/ to your file directory.
Like so:



BroadcastLua('surface.PlaySound("sound/cakeisgone.mp3")')


As that’s what I use and it works :stuck_out_tongue:

Wouldn’t putting sound there adversely effect the path, since PlaySound defaults in the sound folder?

I was not sure where to place

so I placed it at the top of the file and did not change anything, Not sure what that does either, tbh.

I was thinking the same thing but I tried it anyways, it didn’t work either. :confused:

That’ll try to play garrysmod/sound/sound/cakeisgone.mp3

Any other ideas to fix this?

I’m not sure if related but do I want Pure Server disabled or enabled?

Does the file exist in garrysmod/downloads/sound/ or garrysmod/sound/ after you’ve entered the server?

In garrysmod/sound/ it does.

Does it give you the same error if you type “play cakeisgone.mp3” in console?

It does give the same error.

I’d recommend getting FastDL first off, just because it makes it x2 as easier.

[lua]resource.AddFile(“sound/cakeisgone.mp3”)[/lua]

Then put this
[lua]
local function PlayMusic(wintype)
– Play sounds when a team wins
if wintype != WIN_TRAITOR then
BroadcastLua(‘surface.PlaySound(“sound/cakeisgone.mp3”)’)
else
BroadcastLua(‘surface.PlaySound(“sound/cakeisgone.mp3”)’)
end

end
hook.Add(“TTTEndRound”, “MyMusic”, PlayMusic)
[/lua]

I might be totally misreading the problem here though…

I have all that setup.
Good News:
Not sure what changed but it started working ><
Everyone on the server could hear the music

But thanks everyone for the help! :smiley: