ULX

Author Topic: Say (chat ) Sounds in Gmod 10  (Read 13358 times)

0 Members and 1 Guest are viewing this topic.

Offline WW3D

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Say (chat ) Sounds in Gmod 10
« 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.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Say (chat ) Sounds in Gmod 10
« Reply #1 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
« Last Edit: November 22, 2008, 04:06:23 PM by JamminR »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline WW3D

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Say (chat ) Sounds in Gmod 10
« Reply #2 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'

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Say (chat ) Sounds in Gmod 10
« Reply #3 on: November 21, 2008, 07:19:48 PM »
Simple syntax mistake.
ply:IsValid should be ply:IsValid()
I've edited the original post.
« Last Edit: November 21, 2008, 07:21:35 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline WW3D

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Say (chat ) Sounds in Gmod 10
« Reply #4 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.
« Last Edit: November 22, 2008, 03:44:14 PM by WW3D »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Say (chat ) Sounds in Gmod 10
« Reply #5 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.
* JamminR sticks his tongue out at Jay for simple syntax errors.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Say (chat ) Sounds in Gmod 10
« Reply #6 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?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline WW3D

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Say (chat ) Sounds in Gmod 10
« Reply #7 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 
« Last Edit: November 22, 2008, 04:28:56 PM by WW3D »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Say (chat ) Sounds in Gmod 10
« Reply #8 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.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Say (chat ) Sounds in Gmod 10
« Reply #9 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline WW3D

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Say (chat ) Sounds in Gmod 10
« Reply #10 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