• Multiple local sounds around the map
    1 replies, posted
Hey guys I'm trying to figure this out and have had no luck. I'm attempting to make radios around the map all play a locally heard sound around that map and can be heard from every radio regardless of which one you were closest to when it first played. Currently both codes make a sound that can be heard from the radio but only the one that you were closest to when the function was used. I'm hoping someone knows how to help me. Basically, make it so the player can run to any radio and hear the sound being emitted. This one emits a sound from the radio. [code] for k, v in pairs( ents.FindByClass( "en_radio" ) ) do v:EmitSound( "radio/radio4.wav", 75, 100, 1, CHAN_AUTO ) ) end [/code] This one plays a sound at the exact location of each radio. [code] sound.Play( "radio/radio4.wav", Vector( -1852.502319, -744.413269, 107.285957 ), 70, 100 ) --Spawn sound.Play( "radio/radio4.wav", Vector( 205.704163, -1407.802368, 160.667465 ), 70, 100 ) --Ghetto sound.Play( "radio/radio4.wav", Vector( -395.355255, 915.336365, 173.545135 ), 80, 100 ) --Warehouses [/code]
Either use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CreateSound]CreateSound[/url] combined with a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/RecipientFilter]RecipientFilter[/url], or execute your code on the client instead of from the server. Using the first method described would require you to do: [lua] local filter = RecipientFilter() filter:AddAllPlayers() for k, v in pairs(ents.FindByClass("en_radio")) do v.soundEmitter = CreateSound(v, "radio/radio4.wav", filter) v.soundEmitter:Play() end [/lua]
Sorry, you need to Log In to post a reply to this thread.