[QUOTE=InfernalCookie;30808354]Everytime the round ends.[/QUOTE]
This has been a real brain buster, and having to run the console command at the end of every round is a bit much.. there must be another way.
[editline]30th June 2011[/editline]
[QUOTE=RetTurtl3;30808802]Shall I code it for him or let him figure it out himself. :v:[/QUOTE]
If you think you can get it to work! that would be awesome :))
RetTurtl3 i think he should try to code it cuz it's only a forloop and a single command repeated in each ifstatement.
And it won't take much to run a console command at the end of each round.
The plain code would be very much appreciated, but alright.. :)
*sigh* it's only for your greater good, but,
[lua]
local function PlayMusic(type)
for k, v in pairs( player.GetAll() ) do
GetRandomSong = table.Random(music)
if type == WIN_INNOCENT then
v:RunConsoleCommand( "play " .. GetRandomSong )
elseif type == WIN_TRAITOR then
v:RunConsoleCommand( "play " .. GetRandomSong )
elseif type == WIN_TIMELIMIT then
v:RunConsoleCommand( "play " .. GetRandomSong )
end
end
end
[/lua]
Thanks a bunch!!! C: I'll test it when I get back from the store.
Np, just glad I'm helping people and helping myself improve the same time. And if it doesn't work... then idk but that would be just wierd as I don't see any problems with it now.
[QUOTE=InfernalCookie;30813433]*sigh* it's only for your greater good, but,
local function PlayMusic(type)
for k, v in pairs( player.GetAll() ) do
GetRandomSong = table.Random(music)
if type == WIN_INNOCENT then
v:RunConsoleCommand( "play " .. GetRandomSong )
elseif type == WIN_TRAITOR then
v:RunConsoleCommand( "play " .. GetRandomSong )
elseif type == WIN_TIMELIMIT then
v:RunConsoleCommand( "play " .. GetRandomSong )
end
end
end
[/QUOTE]
I'm very sorry to say, but it did not work. I replaced your script with mine, and It doesn't seem to want to work:(. I typed in the console "play" before and after the round was over (2 different rounds). Did RetTurtl3 have any ideas for the code?
any errors, ingame or server side?
No errors ingame or server side. Whenever I put play into the console, nothing appeared or happened.
Are you all out of ideas as to why it won't work?
Are you sure this is being ran? is it included in the init.lua or something?
I put the finished script in Server>Autorun.
I think I found the problem - I'll check in soon.
While I was searching through some threads, I came upon this:
[lua]
// LLAMA YOU FAG LOOK HERE ADD FILE PATHS BELOW.
local randomsoundsTraitor = {
Sound('LmaoLlama\TraitorWin\LeeroyJ.mp3'),
Sound('LmaoLlama\TraitorWin\godsgonnacutudown.mp3'),
Sound('LmaoLlama\TraitorWin\whenthemancomesround.mp3')
}
local randomsoundsInnocent = {
Sound('LmaoLlama\InnocentWin\ImnotaterroristInnocentWin.mp3'),
Sound('LmaoLlama\InnocentWin\lovehateInnocentWin.mp3')
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
// STOP SCROLLING
if e.win == WIN_TRAITOR then
surface.PlaySound( randomSoundTraitor )
return "The traitors won the round!"
elseif e.win == WIN_INNOCENT then
surface.PlaySound( randomsoundInnocent )
return "The pure and innocent terrorists won the round!"
elseif e.win == WIN_TIMELIMIT then
surface.PlaySound( randomsoundInnocent )
return "The traitors lost when the timelimit was reached!"
else
return "The round ended"
end
end
[/lua]
Would this work? If not what would we need to change?
EDIT: I see a shitload of stuff wrong with this already
Uhm. Yah it should work, but I'm curious what the e is...
[editline]3rd July 2011[/editline]
And if you want the sounds to be all 1 table and it to be completely random no matter who won and the sounds all work for each win type, then just make it one table and make one randomSound variable.
[QUOTE=InfernalCookie;30859665]Uhm. Yah it should work, but I'm curious what the e is...
[editline]3rd July 2011[/editline]
And if you want the sounds to be all 1 table and it to be completely random no matter who won and the sounds all work for each win type, then just make it one table and make one randomSound variable.[/QUOTE]
I'll test this right now, give you all my feedback :) I'll make an edit saying if this worked or not.
EDIT: Did not work :( Can anyone check for errors?
[lua]
local randomsoundsTraitor = {
Sound('ttt/pwnsong.mp3'),
Sound('ttt/pwnedftw.wav'),
Sound('ttt/trollface.mp3')
}
local randomsoundsInnocent = {
Sound('ttt/horse.mp3'),
Sound('ttt/snakeeater.mp3')
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
// STOP SCROLLING
if e.win == WIN_TRAITOR then
surface.PlaySound( randomSoundTraitor )
return "The traitors won the round!"
elseif e.win == WIN_INNOCENT then
surface.PlaySound( randomSoundInnocent )
return "The pure and innocent terrorists won the round!"
elseif e.win == WIN_TIMELIMIT then
surface.PlaySound( randomSoundInnocent )
return "The traitors lost when the timelimit was reached!"
else
return "The round ended"
end
end
[/lua]
ServerSide Code.
lua/autorun/server
[lua]local music = {
"ambient/music/country_rock_am_radio_loop.wav",
"music/ravenholm_1.mp3",
"music/hl2_song15.mp3",
"ambient/music/cubanmusic1.wav",
"ambient/music/flamenco.wav",
"ambient/music/latin.wav",
"ambient/music/looping_radio_mix.wav",
"ambient/music/mirame_radio_thru_wall.wav",
"ambient/music/dustmusic2.wav",
"ambient/music/dustmusic3.wav"
};
local function PlayMusic(ttype)
if ttype == 1 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
elseif ttype == 2 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
elseif ttype == 3 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)[/lua]
[QUOTE=RetTurtl3;30877117]ServerSide Code.
lua/autorun/server
[lua]local music = {
"ambient/music/country_rock_am_radio_loop.wav",
"music/ravenholm_1.mp3",
"music/hl2_song15.mp3",
"ambient/music/cubanmusic1.wav",
"ambient/music/flamenco.wav",
"ambient/music/latin.wav",
"ambient/music/looping_radio_mix.wav",
"ambient/music/mirame_radio_thru_wall.wav",
"ambient/music/dustmusic2.wav",
"ambient/music/dustmusic3.wav"
};
local function PlayMusic(ttype)
if ttype == 1 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
elseif ttype == 2 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
elseif ttype == 3 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)[/lua][/QUOTE]
Holy fuck it worked! You're a GENIOUS!! Thank you sooo very much!
I have one final question, RetTurtl3,
How could I make this a random song based on who won? Example:
[lua]
local randomsoundsTraitor = {
Sound('ttt/pwnsong.mp3'),
Sound('ttt/pwnedftw.wav'),
Sound('ttt/trollface.mp3')
}
local randomsoundsInnocent = {
Sound('ttt/horse.mp3'),
Sound('ttt/snakeeater.mp3')
[/lua]
That's my final question :) You are the BEST.
make 2 tables and I believe ttype 2 is traitors win, so make it do traitorwintable[math.random(1,#traitorwintable)]
[editline]3rd July 2011[/editline]
oh and that was my fault with the type, it shoulda been ttype or something different.
[QUOTE=InfernalCookie;30879049]make 2 tables and I believe ttype 2 is traitors win, so make it do traitorwintable[math.random(1,#traitorwintable)][/QUOTE]
Correct!
[QUOTE=InfernalCookie;30879049]oh and that was my fault with the type, it shoulda been ttype or something different.[/QUOTE]
Nope wasn't your fault! :wink:
[lua]
local random = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/horse.mp3",
"ttt/snakeeater.mp3",
"ttt/thisfire.mp3"
}
local innowintable = {
"ttt/snakeeater.mp3",
"ttt/horse.mp3"
}
local traitorwintable = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/thisfire.mp3"
};
local function PlayMusic(ttype)
if ttype == 1 then
BroadcastLua([[LocalPlayer():EmitSound(']]..innowintable[math.random(1,#innowintable)]..[[')]])
elseif ttype == 2 then
BroadcastLua([[LocalPlayer():EmitSound(']]..traitorwintable[math.random(1,#traitorwintable)]..[[')]])
elseif ttype == 3 then
BroadcastLua([[LocalPlayer():EmitSound(']]..music[math.random(1,#music)]..[[')]])
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)
[/lua]
I probably made a careless mistake.. anyone know how to fix? :/
Well for one don't put a "," after the last thing in your tables.
[QUOTE=MayorBee;30880683]Well for one don't put a "," after the last thing in your tables.[/QUOTE]
Fixed, still doesn't work. Thanks though.
[code]
function PlayMusic(result)
local randomsoundsStaleMate = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/horse.mp3",
"ttt/snakeeater.mp3",
"ttt/thisfire.mp3"
}
local randomsoundsInnocent = {
"ttt/snakeeater.mp3",
"ttt/horse.mp3"
}
local randomsoundsTraitor = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/thisfire.mp3"
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
local randomSoundStaleMate = table.Random(randomsoundsStaleMate)
if result==WIN_TRAITOR then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play".. randomSoundTraitor)
end
end
if result==WIN_INNOCENT then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play".. randomSoundInnocent)
end
end
if result==WIN_TIMELIMIT then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play".. randomSoundStaleMate)
end
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)
[/code]
If you get an error tell me.
[QUOTE=Llamalord;30881209][code]
function PlayMusic(result)
local randomsoundsStaleMate = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/horse.mp3",
"ttt/snakeeater.mp3",
"ttt/thisfire.mp3"
}
local randomsoundsInnocent = {
"ttt/snakeeater.mp3",
"ttt/horse.mp3"
}
local randomsoundsTraitor = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/thisfire.mp3"
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
local randomSoundStaleMate = table.Random(randomsoundsStaleMate)
if result==WIN_TRAITOR then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play".. randomSoundTraitor)
end
end
if result==WIN_INNOCENT then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play".. randomSoundInnocent)
end
end
if result==WIN_TIMELIMIT then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play".. randomSoundStaleMate)
end
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)
[/code]
If you get an error tell me.[/QUOTE]
Error: Unknown command: playttt/pwnsong.mp3
[QUOTE=Llamalord;30881209][code]
function PlayMusic(result)
local randomsoundsStaleMate = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/horse.mp3",
"ttt/snakeeater.mp3",
"ttt/thisfire.mp3"
}
local randomsoundsInnocent = {
"ttt/snakeeater.mp3",
"ttt/horse.mp3"
}
local randomsoundsTraitor = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/thisfire.mp3"
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
local randomSoundStaleMate = table.Random(randomsoundsStaleMate)
if result==WIN_TRAITOR then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play ".. randomSoundTraitor)
end
end
if result==WIN_INNOCENT then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play ".. randomSoundInnocent)
end
end
if result==WIN_TIMELIMIT then
for k, v in pairs(player.GetAll()) do
v:ConCommand("play ".. randomSoundStaleMate)
end
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)
[/code]
If you get an error tell me.[/QUOTE]
I forgot to add the space to the right of play
PS this is llamalords on his stepbrother's account
Also, if it can't find the sound still, add "sound/" to everything.
[QUOTE=samdamana;30881808]I forgot to add the space to the right of play
PS this is llamalords on his stepbrother's account
Also, if it can't find the sound still, add "sound/" to everything.[/QUOTE]
Thanks for Everything! It works :)
No problem.
Hello, everyone, again,
I asked LlamaLord if he could also make it play a "ttt/traitor_win.mp3" or "ttt/inno_win.mp3"
and he was very kind to give me one.
Well, here's the code:
[lua]
function PlayMusic(result)
local randomsoundsStaleMate = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/horse.mp3",
"ttt/snakeeater.mp3",
"ttt/thisfire.mp3"
}
local randomsoundsInnocent = {
"ttt/snakeeater.mp3",
"ttt/horse.mp3"
}
local randomsoundsTraitor = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/thisfire.mp3"
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
local randomSoundStaleMate = table.Random(randomsoundsStaleMate)
if result==WIN_TRAITOR then
for k, v in pairs(player.GetAll()) do
local sounddur = SoundDuration("ttt/traitor_win.mp3")
v:ConCommand("play traitor_win.mp3")
timer.Create( "traitor_timer", sounddur, 0, function() v:ConCommand("play ".. randomSoundTraitor) end )
end
end
if result==WIN_INNOCENT then
for k, v in pairs(player.GetAll()) do
local sounddur = SoundDuration("ttt/inno_win.mp3")
v:ConCommand("play inno_win.mp3")
timer.Create( "inno_timer", sounddur, 0, function() v:ConCommand("play ".. randomSoundInnocent) end )
end
end
if result==WIN_TIMELIMIT then
for k, v in pairs(player.GetAll()) do
local sounddur = SoundDuration("ttt/inno_win.mp3")
v:ConCommand("play inno_win.mp3")
timer.Create( "stale_timer", sounddur, 0, function() v:ConCommand("play ".. randomSoundStaleMate) end )
end
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)
[/lua]
It doesn't even play my "inno/traitor" sound, it plays a completely
random sound "One that's not even in my sounds folder",
and then it loops the first second of the song that comes
after. Here's a video to explain my problem:
[url]http://www.youtube.com/watch?v=G9HFt5pz6t8[/url]
I'd appreciate some help, thanks :)
[QUOTE=Apozen;30887881]Hello, everyone, again,
I asked LlamaLord if he could also make it play a "ttt/traitor_win.mp3" or "ttt/inno_win.mp3"
and he was very kind to give me one.
Well, here's the code:
[lua]
function PlayMusic(result)
local randomsoundsStaleMate = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/horse.mp3",
"ttt/snakeeater.mp3",
"ttt/thisfire.mp3"
}
local randomsoundsInnocent = {
"ttt/snakeeater.mp3",
"ttt/horse.mp3"
}
local randomsoundsTraitor = {
"ttt/pwnedftw.wav",
"ttt/pwnsong.mp3",
"ttt/thisfire.mp3"
}
local randomSoundTraitor = table.Random(randomsoundsTraitor)
local randomSoundInnocent = table.Random(randomsoundsInnocent)
local randomSoundStaleMate = table.Random(randomsoundsStaleMate)
if result==WIN_TRAITOR then
for k, v in pairs(player.GetAll()) do
local sounddur = SoundDuration("ttt/traitor_win.mp3")
v:ConCommand("play traitor_win.mp3")
timer.Create( "traitor_timer", sounddur, 0, function() v:ConCommand("play ".. randomSoundTraitor) end )
end
end
if result==WIN_INNOCENT then
for k, v in pairs(player.GetAll()) do
local sounddur = SoundDuration("ttt/inno_win.mp3")
v:ConCommand("play inno_win.mp3")
timer.Create( "inno_timer", sounddur, 0, function() v:ConCommand("play ".. randomSoundInnocent) end )
end
end
if result==WIN_TIMELIMIT then
for k, v in pairs(player.GetAll()) do
local sounddur = SoundDuration("ttt/inno_win.mp3")
v:ConCommand("play inno_win.mp3")
timer.Create( "stale_timer", sounddur, 0, function() v:ConCommand("play ".. randomSoundStaleMate) end )
end
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)
[/lua]
It doesn't even play my "inno/traitor" sound, it plays a completely
random sound "One that's not even in my sounds folder",
and then it loops the first second of the song that comes
after. Here's a video to explain my problem:
[url]http://www.youtube.com/watch?v=G9HFt5pz6t8[/url]
I'd appreciate some help, thanks :)[/QUOTE]
Pro tip: Learn how to read code and troubleshoot simple problems yourself without constant assistance from others.
Sorry, you need to Log In to post a reply to this thread.