Need help getting End Round Music for Trouble in Terrorist Town
5 replies, posted
I'm trying to help out my friend with his TTT server and get him some end round music. Here is the script so far:
[CODE]resource.AddFile("sound/endround/burqa.wav")
resource.AddFile("sound/endround/fuckthepolice.wav")
resource.AddFile("sound/endround/noize.wav")
resource.AddFile("sound/endround/hardinthepaint.wav")
local function PlayMusic(wintype)
if wintype == WIN_INNOCENT then
BroadcastLua('surface.PlaySound("sound/endround/")')
elseif wintype == WIN_TRAITOR then
BroadcastLua('surface.PlaySound("sound/endround/")')
elseif wintype == WIN_TIMELIMIT then
BroadcastLua('surface.PlaySound("sound/endround/")')
end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)[/CODE]
We cant seem to get it to play any sounds at the end of the round. I'm not a lua coder or anything so im using common sense really to read through the code.
Here's the one that I give out to help people learn Lua:
[url]https://dl.dropboxusercontent.com/u/26074909/ttt_end_round.rar[/url]
It uses Net messages instead of BroadcastLua. You just need to fill in the sounds and put in to your addons folder.
Next up: for your script, make sure that it's loading SERVER side. You do NOT need to reference the sound directory when playing a sound. get rid of sound/ in the surface.PlaySound.
Additionally, you didn't finish the PlaySound line, it ends at endround/....
You need to add the actual sound files in there.
Example:
[lua]BroadcastLua('surface.PlaySound("endround/burga.wav")')[/lua]
Hope it helps, if that solves your issue please feel free to mark this topic as solved in the top left corner next to reply :-) otherwise feel free to respond with more questions!
So would this be suitable?:
[CODE]
//
// sv_end_round_music.lua by Josh 'Acecool' Moser
//
//
// Define your music here, end each line with a ,
// You can define 1 to many sounds. It will play 1 of the list randomly, or the single one every time.
//
END_OF_ROUND_WIN_INNOCENT_SOUNDS = {
"sound/endround/burqa.wav",
"sound/endround/fuckthepolice.wav"",
"sound/endround/noize.wav",
"sound/endround/hardinthepaint.wav",
}
END_OF_ROUND_WIN_TRAITOR_SOUNDS = {
"sound/endround/burqa.wav",
"sound/endround/fuckthepolice.wav"",
"sound/endround/noize.wav",
"sound/endround/hardinthepaint.wav",
}
END_OF_ROUND_WIN_TIMELIMIT_SOUNDS = {
"sound/endround/burqa.wav",
"sound/endround/fuckthepolice.wav"",
"sound/endround/noize.wav",
"sound/endround/hardinthepaint.wav",
}
// You must define a default sound to play if some of your lists above are empty.
END_OF_ROUND_WIN_DEFAULT_SOUND = "hardinthepaint.wav";
if ( SERVER ) then
util.AddNetworkString( "_ttt_end_round_music" );
for k, v in pairs( END_OF_ROUND_WIN_INNOCENT_SOUNDS ) do resource.AddFile( "sound/endround/hardinthepaint.wav" .. v ); end
do resource.AddFile( "sound/endround/burqa.wav" .. v ); end
do resource.AddFile( "sound/endround/noize.wav" .. v ); end
do resource.AddFile( "sound/endround/fuckthepolice.wav" .. v ); end
for k, v in pairs( END_OF_ROUND_WIN_TRAITOR_SOUNDS ) do resource.AddFile( "sound/endround/hardinthepaint.wav" .. v ); end
do resource.AddFile( "sound/endround/burqa.wav" .. v ); end
do resource.AddFile( "sound/endround/noize.wav" .. v ); end
do resource.AddFile( "sound/endround/fuckthepolice.wav" .. v ); end
for k, v in pairs( END_OF_ROUND_WIN_TIMELIMIT_SOUNDS )
do resource.AddFile( "sound/endround/hardinthepaint.wav" .. v ); end
do resource.AddFile( "sound/endround/burqa.wav" .. v ); end
do resource.AddFile( "sound/endround/noize.wav" .. v ); end
do resource.AddFile( "sound/endround/fuckthepolice.wav" .. v ); end
local function endofround( wintype )
// Default sound
local _sound = sound/endround/hardinthepaint.wav
if wintype == WIN_INNOCENT then
_sound = table.Random( END_OF_ROUND_WIN_INNOCENT_SOUNDS );
elseif wintype == WIN_TRAITOR then
_sound = table.Random( END_OF_ROUND_WIN_TRAITOR_SOUNDS );
elseif wintype == WIN_TIMELIMIT then
_sound = table.Random( END_OF_ROUND_WIN_TIMELIMIT_SOUNDS );
end
net.Start( "_ttt_end_round_music" );
net.WriteString( _sound );
net.Broadcast( );
end
hook.Add( "TTTEndRound", "Handymanendofround", endofround )
end[/CODE]
the for k, v in pairs for each of the categories AUTOMATICALLY does the resource.AddFile. So that part doesn't need to be modified.
Matt needs to stop harassing me. I have a broken back and broken neck, and am already in enough pain as it is. I'm already considering medical euthanasia, he needs to STOP HARASSING ME.
Still doesnt work. Every end round the console says:
[CODE]Failed to load sound "", file probably missing from disk/repository[/CODE]
Heres the addon with the edited scripts: [url]http://www.mediafire.com/?49pc8jj87i4cz2u[/url]
The owner of the server moved it into the addons folder for the server and moved the sounds into "sound/endround" but it still gives this error. he also copied the sounds to "disk/repository" or where ever that is. Still dont know why they wont play? We even changed the map several times to see if the sounds would work.
Here - note that for each in the arrays sound/ is not needed as when it gets played you don't have to reference that directory, but when you add the resource file you do ( which is why it's inserted before the sound name when it does the resource add file and not when it sends it to the client )
[lua]//
// sv_end_round_music.lua by Josh 'Acecool' Moser
//
//
// Define your music here, end each line with a ,
// You can define 1 to many sounds. It will play 1 of the list randomly, or the single one every time.
//
END_OF_ROUND_WIN_INNOCENT_SOUNDS = {
"endround/burqa.wav",
"endround/fuckthepolice.wav"",
"endround/noize.wav",
"endround/hardinthepaint.wav",
}
END_OF_ROUND_WIN_TRAITOR_SOUNDS = {
"endround/burqa.wav",
"endround/fuckthepolice.wav"",
"endround/noize.wav",
"endround/hardinthepaint.wav",
}
END_OF_ROUND_WIN_TIMELIMIT_SOUNDS = {
"endround/burqa.wav",
"endround/fuckthepolice.wav"",
"endround/noize.wav",
"endround/hardinthepaint.wav",
}
// You must define a default sound to play if some of your lists above are empty.
END_OF_ROUND_WIN_DEFAULT_SOUND = "endround/hardinthepaint.wav";
if ( SERVER ) then
util.AddNetworkString( "_ttt_end_round_music" );
for k, v in pairs( END_OF_ROUND_WIN_INNOCENT_SOUNDS ) do resource.AddFile( "sound/" .. v ); end
for k, v in pairs( END_OF_ROUND_WIN_TRAITOR_SOUNDS ) do resource.AddFile( "sound/" .. v ); end
for k, v in pairs( END_OF_ROUND_WIN_TIMELIMIT_SOUNDS ) do resource.AddFile( "sound/" .. v ); end
local function endofround( wintype )
// Default sound
local _sound = END_OF_ROUND_WIN_DEFAULT_SOUND
if wintype == WIN_INNOCENT then
_sound = table.Random( END_OF_ROUND_WIN_INNOCENT_SOUNDS );
elseif wintype == WIN_TRAITOR then
_sound = table.Random( END_OF_ROUND_WIN_TRAITOR_SOUNDS );
elseif wintype == WIN_TIMELIMIT then
_sound = table.Random( END_OF_ROUND_WIN_TIMELIMIT_SOUNDS );
end
net.Start( "_ttt_end_round_music" );
net.WriteString( _sound );
net.Broadcast( );
end
hook.Add( "TTTEndRound", "Handymanendofround", endofround )
end[/lua]
But, it seems as though you don't want different sounds for each team so this might be better
[lua]//
// sv_end_round_music.lua by Josh 'Acecool' Moser
//
//
// Define your music here, end each line with a ,
// You can define 1 to many sounds. It will play 1 of the list randomly, or the single one every time.
//
END_OF_ROUND_SOUNDS = {
"endround/burqa.wav",
"endround/fuckthepolice.wav"",
"endround/noize.wav",
"endround/hardinthepaint.wav",
}
// You must define a default sound to play if some of your lists above are empty.
END_OF_ROUND_WIN_DEFAULT_SOUND = "endround/hardinthepaint.wav";
if ( SERVER ) then
util.AddNetworkString( "_ttt_end_round_music" );
for k, v in pairs( END_OF_ROUND_SOUNDS ) do resource.AddFile( "sound/" .. v ); end
local function endofround( wintype )
local _sound = table.Random( END_OF_ROUND_SOUNDS ) or END_OF_ROUND_WIN_DEFAULT_SOUND;
net.Start( "_ttt_end_round_music" );
net.WriteString( _sound );
net.Broadcast( );
end
hook.Add( "TTTEndRound", "Handymanendofround", endofround )
end[/lua]
Sorry, you need to Log In to post a reply to this thread.