TTT End round music determines end round length?

How would I make it so that rather than having ttt_posttime_seconds determine how long the post round lasts, it is determined by the length of the endround songs.

Yet another person without lua skills asks in a DEVELOPER section which is there for DEVELOPERS in case they have issues with DEVELOPING their scripts.

I dont even understand what he is saying :v:

Oh, I’m sorry I thought I could ask a fucking question. How about you do something useful and help someone rather than be a condescending prick.

[editline]1st January 2014[/editline]

I have this:
[lua]-- Sounds played when the innocent win
local InnocentWinSounds = {
“saints/endroundmusic1.mp3”,
“saints/endroundmusic4.mp3”,
“saints/endroundmusic6.mp3”,
“saints/endroundmusic7.mp3”,
“saints/endroundmusic9.mp3”,
“saints/endroundmusic12.mp3”,
“saints/endroundmusic14.mp3”
}

– Sounds played when the traitors win
local TraitorWinSounds = {
“saints/endroundmusic2.mp3”,
“saints/endroundmusic3.mp3”,
“saints/endroundmusic5.mp3”,
“saints/endroundmusic8.mp3”,
“saints/endroundmusic11.mp3”,
“saints/endroundmusic13.mp3”,
“saints/endroundmusic15.mp3”
}

– Sounds played when time is up
local OutOfTimeSounds = {
“spoonendround/manson2.wav”
}

for k, v in pairs (InnocentWinSounds) do
resource.AddFile(“sound/”…v)
util.PrecacheSound(“sound/”…v)
end

for k, v in pairs (TraitorWinSounds) do
resource.AddFile(“sound/”…v)
util.PrecacheSound(“sound/”…v)
end

for k, v in pairs (OutOfTimeSounds) do
resource.AddFile(“sound/”…v)
util.PrecacheSound(“sound/”…v)
end

local function PlaySoundClip(win)
if win == WIN_INNOCENT then
BroadcastLua(‘surface.PlaySound("’…InnocentWinSounds[math.random(1, #InnocentWinSounds)]…’")’)
elseif win == WIN_TRAITOR then
BroadcastLua(‘surface.PlaySound("’…TraitorWinSounds[math.random(1, #TraitorWinSounds)]…’")’)
elseif win == WIN_TIMELIMIT then
BroadcastLua(‘surface.PlaySound("’…OutOfTimeSounds[math.random(1, #OutOfTimeSounds)]…’")’)
end
end
hook.Add(“TTTEndRound”, “SoundClipEndRound”, PlaySoundClip)[/lua] and want the post round time to be determined by the length of each song.

I would but what would you do with that information if you lack scripting skills?
If not then alright: You have to create a table or add another key to existing table, name it “SoundLenght” or something like that, then you would have to run the command you have mentioned using value from the table as an argument accordingly to the song that has been randomly chosen.

http://wiki.garrysmod.com/page/Global/SoundDuration ?

What I would do is choose the sound in the TTTBeginRound hook, then set the convar “ttt_posttime_seconds” to 5 + SoundDuration( snd )
Then when the round ends just play that sound

I’m trying to make it automatic, I have this:

[lua]-- Sounds played when the round ends
local EndRoundSounds = {
“saints/endroundmusic1.mp3”,
“saints/endroundmusic4.mp3”,
“saints/endroundmusic6.mp3”,
“saints/endroundmusic7.mp3”,
“saints/endroundmusic9.mp3”,
“saints/endroundmusic12.mp3”,
“saints/endroundmusic14.mp3”,
“saints/endroundmusic2.mp3”,
“saints/endroundmusic3.mp3”,
“saints/endroundmusic5.mp3”,
“saints/endroundmusic8.mp3”,
“saints/endroundmusic11.mp3”,
“saints/endroundmusic13.mp3”,
“saints/endroundmusic15.mp3”
}
BroadcastLua(‘surface.PlaySound("’…EndRoundSounds[math.random(1, #EndRoundSounds)]…’")’)

ttt_posttime_seconds SoundDuration( string #EndRoundSounds )[/lua]
and am getting this error:

[lua][ERROR] lua/autorun/ttt_end_of_round_music.lua:20: ‘=’ expected near ‘SoundDuration’

  1. unknown - lua/autorun/ttt_end_of_round_music.lua:0[/lua]

first method is dumb because i forgot you wouldnt know who won the round at the start of the round :v:
at the end round, you could use

[LUA]timer.Adjust(“end2prep”, 5 + SoundDuration( sound ), 1, PrepareRound)[/LUA]

I got the sounds playing, but I can’t get it to change how long the postround lasts

What’s your code now?

[lua]-- Sounds played when the round ends
local EndRoundSounds = {
“saints/endroundmusic1.mp3”,
“saints/endroundmusic4.mp3”,
“saints/endroundmusic6.mp3”,
“saints/endroundmusic7.mp3”,
“saints/endroundmusic9.mp3”,
“saints/endroundmusic12.mp3”,
“saints/endroundmusic14.mp3”,
“saints/endroundmusic2.mp3”,
“saints/endroundmusic3.mp3”,
“saints/endroundmusic5.mp3”,
“saints/endroundmusic8.mp3”,
“saints/endroundmusic11.mp3”,
“saints/endroundmusic13.mp3”,
“saints/endroundmusic15.mp3”
}

for k, v in pairs (EndRoundSounds) do
resource.AddFile(“sound/”…v)
util.PrecacheSound(“sound/”…v)
end

local function PlaySoundClip(win)
if win == WIN_INNOCENT then
BroadcastLua(‘surface.PlaySound("’…EndRoundSounds[math.random(1, #EndRoundSounds)]…’")’)
elseif win == WIN_TRAITOR then
BroadcastLua(‘surface.PlaySound("’…EndRoundSounds[math.random(1, #EndRoundSounds)]…’")’)
elseif win == WIN_TIMELIMIT then
BroadcastLua(‘surface.PlaySound("’…EndRoundSounds[math.random(1, #EndRoundSounds)]…’")’)
end
end
hook.Add(“TTTEndRound”, “SoundClipEndRound”, PlaySoundClip)

timer.Adjust(SoundDuration( #EndRoundSounds ))[/lua]

As you can tell, I’ve tried to make it so that it automatically chooses a song and the length of the end round process