• Multiple music in post-round, how to?
    9 replies, posted
Hello, I have this code [CODE]if SERVER then resource.AddFile("sound/ttt/narwhalstttserver_iwin.mp3") resource.AddFile("sound/ttt/narwhalstttserver_iwin2.mp3") resource.AddFile("sound/ttt/narwhalstttserver_iwin3.mp3") resource.AddFile("sound/ttt/narwhalstttserver_twin.mp3") resource.AddFile("sound/ttt/narwhalstttserver_twin2.mp3") resource.AddFile("sound/ttt/narwhalstttserver_twin3.mp3") end local iwin = {"ttt/narwhalstttserver_iwin.mp3","ttt/narwhalstttserver_iwin2.mp3","ttt/narwhalstttserver_iwin3.mp3"} local twin = {"ttt/narwhalstttserver_twin.mp3","ttt/narwhalstttserver_twin2.mp3","ttt/narwhalstttserver_twin3.mp3"} local function PlayMusic(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("' ..table.Random(iwin).. '")') elseif wintype == WIN_TRAITOR then BroadcastLua('surface.PlaySound("' ..table.Random(twin).. '") ') elseif wintype == WIN_TIMELIMIT then BroadcastLua('surface.PlaySound("' ..table.Random(iwin).. '")') end end hook.Add("TTTEndRound", "MyMusic", PlayMusic)[/CODE] and I would like it not be random, I want it to be in order like on the frist, second and third time the traitors win it will play twin.mp3, twin2.mp3 and twin3.mp3. Same thing for the innocents. Thank you!
Bump
Because I'm lazy, I would do: [lua]if SERVER then resource.AddFile("sound/ttt/narwhalstttserver_iwin.mp3") resource.AddFile("sound/ttt/narwhalstttserver_iwin2.mp3") resource.AddFile("sound/ttt/narwhalstttserver_iwin3.mp3") resource.AddFile("sound/ttt/narwhalstttserver_twin.mp3") resource.AddFile("sound/ttt/narwhalstttserver_twin2.mp3") resource.AddFile("sound/ttt/narwhalstttserver_twin3.mp3") local iwinnum = 0 local twinnum = 0 local iwin = {"vo/k_lab/ba_geethanks.wav","vo/k_lab/ba_getamoveon.wav","vo/k_lab/ba_getitoff01.wav"} local twin = {"ttt/narwhalstttserver_twin.mp3","ttt/narwhalstttserver_twin2.mp3","ttt/narwhalstttserver_twin3.mp3"} local function PlayMusic(wintype) if wintype == WIN_INNOCENT or wintype == WIN_TIMELIMIT then BroadcastLua('surface.PlaySound("' ..iwin[iwinnum].. '")') iwinnum = iwinnum +1 elseif wintype == WIN_TRAITOR then BroadcastLua('surface.PlaySound("' ..twin[twinnum].. '") ') iwinnum = iwinnum +1 end end hook.Add("TTTEndRound", "MyMusic", PlayMusic) end [/lua] Make sure that you add in something to reset the variables once it exceeds the amount of songs you have.
What do I need to add specifically? I know nothing in lua... :\
[QUOTE=GummybearQc;41416775]What do I need to add specifically? I know nothing in lua... :\[/QUOTE] So you expect us to code the whole thing for you? So you can what? Copy and paste it in and call it yours? Learn LUA.
Did I say that? No. First of all the base code was released publicly and what I am asking is help to change it. If you don't want to help, fine but don't wander around and saying stuff that's not true. If I know nothing in LUA and I just want to know how to script one thing, I am not going to go completely learn it, sorry. Thanks for understanding.
[QUOTE=GummybearQc;41339980]Hello, I have this code [CODE]-snip-[/CODE] and I would like it not be random, I want it to be in order like on the frist, second and third time the traitors win it will play twin.mp3, twin2.mp3 and twin3.mp3. Same thing for the innocents. Thank you![/QUOTE] Translation: I have this code, change it so it works how I want it. Thanks! [QUOTE=GummybearQc;41421405]Did I say that? No. First of all the base code was released publicly and what I am asking is help to change it. If you don't want to help, fine but don't wander around and saying stuff that's not true. If I know nothing in LUA and I just want to know how to script one thing, I am not going to go completely learn it, sorry. Thanks for understanding.[/QUOTE] Considering you have a lack in the knowledge of LUA coding I would advise you go learn some before trying to change shit that you don't know how it works. You didn't ask "How do I.." you just said what I translated from above.
And what is the problem with that? I also fergot to mention that I learn at the same time with this. Now are you happy sir?
[code]iwinnum = (iwinnum + 1) % (#iwin)[/code] Should keep iwinnum within the table limits. Look up modulo.
Alright, thank you!
Sorry, you need to Log In to post a reply to this thread.