• TTT end round Music. Help!
    14 replies, posted
I worked up this code. resource.AddFile("sounds/SOLACE - Average things.mp3") resource.AddFile("sounds/shadows_of_mind.mp3") // End of Round Sound NOT MUSIC local function PlaySound(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("SOLACE - Average things.mp3")') else BroadcastLua('surface.PlaySound("shadows_of_mind.mp3")') end end hook.Add("TTTEndRound", "PlaySound", PlaySound) So my question is, where do I put it, and will it work? If not, can you point me in the right direction?
make the sound files more readable?, like a1 and a2, also, put it in lua/autorun/server, or lua/autorun and it should work, also next time use code tags, edit: [code]local function PlaySound(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("SOLACE - Average things.mp3")') or BroadcastLua('surface.PlaySound("shadows_of_mind.m p3")') end end hook.Add("TTTEndRound", "PlaySound", PlaySound)[/code] like that,
The first block of code you had was correct, pantera's is the wrong syntax. It's probably not working because you have "m p3".
Niether worked. I really want this to work!
[lua] // Initialize the tables local im, tm, km = {}, {}, {} // Inno music for u,i in pairs(file.Find("sound/tttend/inno/*","MOD")) do resource.AddFile(i) table.insert(im, i) end print("im: " .. #im) //Traitor music for r,t in pairs(file.Find("sound/tttend/trait/*","MOD")) do resource.AddFile(t) table.insert(tm, t) end print("tm: " .. #tm) //Time out for j,k in pairs(file.Find("sound/tttend/time/*","MOD")) do resource.AddFile(k) table.insert(km, k) end print("km: " .. #km) //Plays music depending on wintype, and it's randomized local function wDMX(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("' .. table.Random(im) .. '")') elseif wintype == WIN_TRAITOR then BroadcastLua('surface.PlaySound("' .. table.Random(tm) .. '")') elseif wintype == WIN_TIMELIMIT then BroadcastLua('surface.PlaySound("' .. table.Random(km) .. '")') end end hook.Add("TTTEndRound", "wDMx", wDMX)[/lua] place your sound files in the directory sound/tttend/whatever end it is accordingly. Confirmed working, if it doesnt work for you, you did something wrong.
Where do I put the script?
[QUOTE=brandonj4;42524440]The first block of code you had was correct, pantera's is the wrong syntax. It's probably not working because you have "m p3".[/QUOTE] didnt bother with fixing syntax
[QUOTE=Pokenav;42525106]Where do I put the script?[/QUOTE] /autorun/server
Didn't work. Could we Skype or somthing? I put the music in garrysmod/sound/tttend/inno (Or trait or time). I put it in fastdl too. It is not working. I really need this to work... [editline]14th October 2013[/editline] Do you think it is a config problem between FastDL and the server? Players are saying its not even saying its downloading when they do in... [editline]14th October 2013[/editline] Bump
If you're not able to do it, it's probably not meant to be. resource.AddFile the file, then broadcastlua surface.PlaySound(path/to/sou.nd) Not very complicated. EDIT: Sometimes fastdl has issues with files with spaces and caps, rename the file accordingly: ex. before: SoUnD FiLe.mp3 after: soundfile.mp3
I made a script for this, if you want it. Go ahead and slap this into addons. [url]https://www.dropbox.com/s/utq3wikp58001qv/RoundSounds.rar[/url] However, if you just want to use your code, I believe you need that to run serverside, and the sound directory is just 'sound/', not 'sounds/'. Make sure you have the path correct down to the last letter. Also, what kind of error are you getting in console, if any?
[QUOTE=Pokenav;42525302]Didn't work. Could we Skype or somthing? I put the music in garrysmod/sound/tttend/inno (Or trait or time). I put it in fastdl too. It is not working. I really need this to work... [editline]14th October 2013[/editline] Do you think it is a config problem between FastDL and the server? Players are saying its not even saying its downloading when they do in... [editline]14th October 2013[/editline] Bump[/QUOTE] its the fastdl then, there is no way it's not working if you created the directories, put the mp3/wav in, and restarted server. I've confirmed this on my own server local + dedicated multiple times before. Contact your host.
[QUOTE=zerothefallen;42527829]its the fastdl then, there is no way it's not working if you created the directories, put the mp3/wav in, and restarted server. I've confirmed this on my own server local + dedicated multiple times before. Contact your host.[/QUOTE] "I put the music in garrysmod/sound/tttend/inno" "[lua]resource.AddFile("sounds/SOLACE - Average things.mp3") -- Wot resource.AddFile("sounds/shadows_of_mind.mp3") --Wot BroadcastLua('surface.PlaySound("SOLACE - Average things.mp3")') -- Wot BroadcastLua('surface.PlaySound("shadows_of_mind.m p3")') -- Wot end[/lua] It's not the FastDL. He has paths messed up.
[QUOTE=Ghost_Sailor;42527953]"I put the music in garrysmod/sound/tttend/inno" "[lua]resource.AddFile("sounds/SOLACE - Average things.mp3") -- Wot resource.AddFile("sounds/shadows_of_mind.mp3") --Wot BroadcastLua('surface.PlaySound("SOLACE - Average things.mp3")') -- Wot BroadcastLua('surface.PlaySound("shadows_of_mind.m p3")') -- Wot end[/lua] It's not the FastDL. He has paths messed up.[/QUOTE] for u,i in pairs(file.Find("sound/tttend/inno/*","MOD")) do no, sound/tttend/inno is the correct path.
[QUOTE=zerothefallen;42528116]for u,i in pairs(file.Find("sound/tttend/inno/*","MOD")) do no, sound/tttend/inno is the correct path.[/QUOTE] I have no idea how, but I totally skipped over your post when I read this.
Sorry, you need to Log In to post a reply to this thread.