Trying to make a wav sound file play when someone chats something
2 replies, posted
i'm 5 hours straight into doing this (i'm pretty new to everything related to programming) i made another post ,but i couldn't just explain everything
i want it to run on the server side,play it directly when someone says "scream" in chat and then the wav file plays to the entire server
these are the ones i'm trying to mess around with,but it always shows some errors
function Woah (ply, text, public)
if(string.lower(string.sub(text, 1, 5)) == "woah") then
PlaySound( "Woah.wav" )
return ""
end
end
hook.Add( "PlayerSay", "woah", Woah )
i litereally have no idea how to do this, i'd appreciate a lot if you guys can help me (this is just for fun sakes (among with friends)
hook.Add("PlayerSay", "CommandIdent", function ( ply, text, public )
if( text == "woah" ) then
surface.PlaySound( "murder/Woah.wav" )
return ""
end
end )
You can take a look about:
This will add a sound called chatmessage. You can play it with EmitSound... the v:EmitSound make it play for all connected player.
So You can use this small snippet for your PlayerSay hook.
sound.Add( {
name = "chatmessage",
channel = CHAN_STATIC,
volume = 1.0,
level = 0,
pitch = { 100, 100 },
sound = "murder/Woah.wav"
} )
for k,v in pairs (player.GetAll()) do
v:EmitSound("chatmessage")
end
Sorry, you need to Log In to post a reply to this thread.