• "Sound.Play" Help
    7 replies, posted
I'm trying to make a weapon which acts as a sound-transmitter, playing a sound to the players that are surrounding wherever you click. The problem is that only the player using the weapon can hear the sound, other players can't. The function I am using for this is: [CODE]function SoundGun(csound) local trace = self.Owner:GetEyeTraceNoCursor() local hpos = trace.HitPos local ppos = self.Owner:GetPos() if trace.HitNonWorld == false then if trace.Hit == true then sound.Play(csound, hpos) end end end[/CODE] The parameter "csound" is the path to the sound, and "hpos" is the entity that is hit. It would be amazing if someone could help me fix this problem! :)
Are you calling it serverside or clientside?
Use EmitSound instead. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9f87.html[/url]
[QUOTE=Winter;44200201]Use EmitSound instead. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9f87.html[/url][/QUOTE] In Entity/Emitsound cannot be set possition.
[QUOTE=predator cz;44200080]Are you calling it serverside or clientside?[/QUOTE] I'm calling it in my shared.lua If I need to call it serverside , how would I keep the HitPos value?
[QUOTE=predator cz;44200264]In Emitsound cannot be set possition.[/QUOTE] The entity calling it will be the origin, use G/EmitSound instead if you are playing with 5:1 or 7:2 and must have the sound origin from an exact vector
[QUOTE=Hoffa1337;44200391]The entity calling it will be the origin, use G/EmitSound instead if you are playing with 5:1 or 7:2 and must have the sound origin from an exact vector[/QUOTE] It doesn't seem to play anything, no errors in console either. [CODE] function SoundGun(csound) local trace = self.Owner:GetEyeTraceNoCursor() local hpos = trace.HitPos local ppos = self.Owner:GetPos() local mrowner = self.Owner if trace.HitNonWorld == false then if trace.Hit == true then EmitSound(csound, hpos, 1, 3, 1, 1, 1, 75) end end end[/CODE]
[QUOTE=C:\Windows;44204385]It doesn't seem to play anything, no errors in console either. [CODE] function SoundGun(csound) local trace = self.Owner:GetEyeTraceNoCursor() local hpos = trace.HitPos local ppos = self.Owner:GetPos() local mrowner = self.Owner if trace.HitNonWorld == false then if trace.Hit == true then EmitSound(csound, hpos, 1, 3, 1, 1, 1, 75) end end end[/CODE][/QUOTE] Change soundlevel and volume to something WAY higher. 1 is basically lowest possible, i think volume goes all the way up to 254 or 255 and soundlevel up to 511 or something. [url]http://wiki.garrysmod.com/page/Global/EmitSound[/url]
Sorry, you need to Log In to post a reply to this thread.