Mr. Gash
Poster
Posts: 382
www.nonerdsjustgeeks.com
|
|
« on: August 26, 2010, 05:40:10 AM » |
|
I recently saw a thread that had a code that didn't work along with asking why it didn't. They wanted to know how to play a sound at the round start/end, well, I was wondering too. How would I go about making a sound play when the traitors win, when the innocents win, or just when the rounds end in general?
|
|
|
|
Meta-Stick
Poster
Posts: 481
it contains, a daisy box
|
|
« Reply #1 on: August 26, 2010, 09:00:13 AM » |
|
I don't know why you'd want that, make sure it isn't loud. I know on that chiefehs guys server it was fucking annoying to hear lincoln park when the traitors won, or whatever. Some this is my horse song. :| No one cares about his lemonade. No one. I forgot what I was talking about.
|
Just grab some bottles and stick them in girls...
|
|
|
Manmax75
Poster
Posts: 254
Programming Guy
|
|
« Reply #2 on: August 26, 2010, 09:02:44 AM » |
|
in the init theres a post round if statement called when somone wins, just put the sound code there
|
Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
|
|
|
Mr. Gash
Poster
Posts: 382
www.nonerdsjustgeeks.com
|
|
« Reply #3 on: August 26, 2010, 09:10:17 PM » |
|
k, thanks. And I'm not going to be putting Linkin park or This is my horse for that. :P
|
|
|
|
Bad King Urgrain
|
|
« Reply #4 on: August 27, 2010, 07:18:12 AM » |
|
I would recommend using hooks rather than modifying TTT files directly. Put this in a Lua script that runs on the server (not clients): resource.AddFile("/path/to/music/traitor_win.mp3") resource.AddFile("/path/to/music/inno_win.mp3")
local function PlayMusic(wintype) if wintype != WIN_TRAITOR then BroadcastLua('surface.PlaySound("/path/to/music/inno_win.mp3")') else BroadcastLua('surface.PlaySound("/path/to/music/traitor_win.mp3")') end end hook.Add("TTTEndRound", "MyMusic", PlayMusic)
This won't work yet in v12, because the EndRound hook didn't get the parameter specifying who won. I've added that in the SVN build.
|
|
« Last Edit: September 07, 2010, 09:15:34 PM by Bad King Urgrain »
|
|
|
|
Manmax75
Poster
Posts: 254
Programming Guy
|
|
« Reply #5 on: August 28, 2010, 09:51:02 AM » |
|
yea listen to BKU, unless your really know what your doing don't modify core files of TTT
|
Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
|
|
|
psiablo
Poster
Posts: 3
|
|
« Reply #6 on: September 07, 2010, 03:28:30 AM » |
|
I would recommend using hooks rather than modifying TTT files directly. Put this in a Lua script that runs on the server (not clients): resource.AddFile("/path/to/music/traitor_win.mp3") resource.AddFile("/path/to/music/inno_win.mp3")
local function PlayMusic(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("/path/to/music/inno_win.mp3")') else BroadcastLua('surface.PlaySound("/path/to/music/traitor_win.mp3")') end end hook.Add("TTTEndRound", "MyMusic", PlayMusic)
This won't work yet in v12, because the EndRound hook didn't get the parameter specifying who won. I've added that in the SVN build. When can we expect an update on the the EndRound parameter being available so we can use it in hooks?
|
|
|
|
Bad King Urgrain
|
|
« Reply #7 on: September 07, 2010, 07:38:28 AM » |
|
Only a psychic could predict when garry will do a release, but there should be one today that will include v13 (and therefore the parameter).
|
|
|
|
Mr. Gash
Poster
Posts: 382
www.nonerdsjustgeeks.com
|
|
« Reply #8 on: September 07, 2010, 08:43:29 PM » |
|
Running v10 on my server until v13 is out and stable (not svn, har har har), so we have to wait until v13 comes out for that to work?
|
|
|
|
Bad King Urgrain
|
|
« Reply #9 on: September 07, 2010, 09:14:46 PM » |
|
Yes.
v13 is out right now.
|
|
|
|
psiablo
Poster
Posts: 3
|
|
« Reply #10 on: September 08, 2010, 03:03:28 AM » |
|
Someone correct me if I'm wrong... which I assume I am seeing as how its not working; server is updated to v13 and I have the following code in a ttt_hooks.lua file in lua/autorun resource.AddFile("sound/ttt/iswin.mp3") resource.AddFile("sound/ttt/tswin.mp3")
// End of Round Sound NOT MUSIC local function PlaySound(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("sound/ttt/iswin.mp3")') else BroadcastLua('surface.PlaySound("sound/ttt/tswin.mp3")') end end hook.Add("TTTEndRound", "PlaySound", PlaySound)
obviously this file is hosted on the server, and the sound files are also hosted on the server. The sound however does not play at the end of the round. Any help is appreciated.
|
|
|
|
Mr. Gash
Poster
Posts: 382
www.nonerdsjustgeeks.com
|
|
« Reply #11 on: September 08, 2010, 05:32:18 PM » |
|
resource.AddFile("sound/ttt/iswin.mp3") resource.AddFile("sound/ttt/tswin.mp3")
// End of Round Sound NOT MUSIC local function PlaySound(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("ttt/iswin.mp3")') else BroadcastLua('surface.PlaySound("ttt/tswin.mp3")') end end hook.Add("TTTEndRound", "PlaySound", PlaySound)
It doesn't need the sound/ part for it to play the sound. So if you have sound/ttt/tswin.mp3, it tries to read the sound from sound/sound/ttt/tswin.mp3.
|
|
|
|
psiablo
Poster
Posts: 3
|
|
« Reply #12 on: September 09, 2010, 03:24:50 AM » |
|
Ugh... I know I was missing something easy. I should have reviewed the surface.PlaySound on the wiki... Anyways, thanks for the help. I noticed looking through the gamemode files cl_init.lua I found there is a TTTBeginRound... so I assume I could create another hook to play so sort of beginning of round sound? I also noticed the: GetConVar("ttt_cl_soundcues"):GetBool() then
code which is for the new variable to enable sounds... is it possible for me to overwrite those variables and functions in my ttt_hooks.lua with my own data. I'd like to have the sound option default to "1" instead of "0" so the sound is on by default, but can be turned off if the user goes into the menu. Then I want to overwrite the function with my own data for the end of round sound. So I was hoping that could be done in my own file without modifying the gamemode file which gets updated all the time when a new ttt update comes out. Again thanks for all the help
|
|
|
|
Bad King Urgrain
|
|
« Reply #13 on: September 09, 2010, 07:20:51 AM » |
|
You need to hook the clientside TTTBeginRound and TTTEndRound hooks and make them return true. Then it will no longer play the sound cues, whether they are disabled or not. You could then check the convar yourself in your hooks and play your own sound.
|
|
|
|