Ulysses

General => Off-Topic => Topic started by: WW3D on November 20, 2008, 09:31:51 PM

Title: Say (chat ) Sounds in Gmod 10
Post by: WW3D on November 20, 2008, 09:31:51 PM
Is there a way to get say (chat) sounds in Gmod 10?  In other words a player types 'hi' in chat, and the server sends a command to all clients to play the sound hi.wav for example.  I am pushing the sounds to the client using ULX, and I can trigger a sound to play by typing this is console "ulx playsound folderx/soundx.wav".  I'm currently running ULX 3.31 and Assmod, but am unable to find a way to do this.  I also tried installing Metamod 1.62 (hoping to be able to get Mani's running on top of it), which I've done before on other servers, but no luck with Gmod 10.  I've searched these forums pretty thoroughly and found references to a way to do it under legacy versions of ULX and Ulib.  But when I try what is suggested in those posts, nothing happens, no sound is triggered.

So to sum up the above, can someone recommend a way to accomplish chat sounds whether it be in ULX or any other Admin mod that works with current Gmod 10 dedicated server running on Windows.

Appreciate any insights you can offer.
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: jay209015 on November 21, 2008, 09:35:27 AM
Here you go :D
Code: [Select]
USay = {}

USay.WordList = {
["hi"] = "sound/hi.wav";
}

function USay.ChatFunction( ply, text )
if ply:IsValid() then
for k,v in pairs(USay.WordList) do
if string.find( text, k ) then
game.ConsoleCommand("ulx playsound " ..USay.WordList[k].. "\n")
return text
end
end
end
end
hook.Add("PlayerSay", "USay.ChatFunction_Hook", USay.ChatFunction)

For the word list, just insert a ["word"] = "sound location";

Not tested yet, let me know if it works. Save as USay.lua and place it in your servers' lua/autorun

[[EDIT - JamminR] - Fixed syntax error
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: WW3D on November 21, 2008, 01:54:39 PM
Hi,

Thanks for the quick reply!  OK, if I place it in lua/autorun I don't see anything in console to show that it loaded, and it doesn't seem to work.  If I place it lua/autorun/server or addons/ulx/lua/modules/ it does try to load it, but then I get this when server starts up. 

Code: [Select]
autorun/server/USay.lua:8: function arguments expected near 'then'
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: JamminR on November 21, 2008, 07:19:48 PM
Simple syntax mistake.
ply:IsValid should be ply:IsValid()
I've edited the original post.
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: WW3D on November 22, 2008, 09:26:38 AM
Thanks guys!  I will try this out tonight when I have some time to dig in.   :)

Edit: Ok I tried out the updated corrected syntax JamminR posted, but now I'm getting this.

Code: [Select]
Error, bad server command ulx playsound sound/ww3d/what1.wav/n
Btw, I tried out the Exosounds plugin I found today, and it is pretty much doing what I was looking for, so no biggie if this doesn't work out, though I certainly appreciate the effort!  It's not perfect as the admin only sounds can still be triggered by anyone, but at least it gets the job done.
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: JamminR on November 22, 2008, 04:05:53 PM
hahaha. Another syntax error I didn't even see before.
That /n at end of console command in the script should be \n
Again, edited Jay's post.
/me sticks his tongue out at Jay for simple syntax errors.
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: JamminR on November 22, 2008, 04:08:35 PM
Jay, Megiddo, any other Lua coders, in Jay's script, the text is returned.
Shouldn't that just be 'return'.
I thought returning anything at all would break other hooks for the same.
Or did Garry change that? Or am I misundertanding?
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: WW3D on November 22, 2008, 04:26:59 PM
Ok, good deal, its working.   :)

This is great, thanks alot guys for the quick response!

I hesistate to ask, but what would it take to make a subset of the sound list only triggerable by admin?  That and the ability for players to toggle the sounds on and off would make for a complete solution.  Something to think about if you guys get bored one day.   ;D 
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: jay209015 on November 22, 2008, 09:42:38 PM
Quote
* JamminR sticks his tongue out at Jay for simple syntax errors.
     - Did this during school :P
Quote
Jay, Megiddo, any other Lua coders, in Jay's script, the text is returned.
Shouldn't that just be 'return'.
I thought returning anything at all would break other hooks for the same.
Or did Garry change that? Or am I misundertanding?
     - I just returned text, so that any other script will be able to continue reading it, but it may not be necessary to return at all.
Quote
I hesistate to ask, but what would it take to make a subset of the sound list only triggerable by admin?  That and the ability for players to toggle the sounds on and off would make for a complete solution.  Something to think about if you guys get bored one day. 
     - No need to hesitate, you have a good idea, and I or another coder will work on it. Probably me if no-one has one done when I get off work.
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: JamminR on November 23, 2008, 12:57:57 AM
Folks, before 'totally' re-inventing the wheel, may want to have a look at FacePunch lua releases.
http://forums.facepunchstudios.com/showthread.php?t=630682
*shudder* I know. It's FP. Still, some gifted talent actually hang out there.
They just get hidden by the masses.
Title: Re: Say (chat ) Sounds in Gmod 10
Post by: WW3D on November 23, 2008, 09:13:24 PM
That's a nice script JamminR.  I don't know how I missed it when I was searching around facepunch last couple weeks.  Played around with it, then went to cleaning it up.  The 600+ sounds are great because no download is needed if you own those games, but alot of them not that interesting.  Great for how little effort it takes to enable it.  Still lacks Admin triggerable sounds and voting.  Doh   :-X