benwilkins Posted February 11, 2012 Share Posted February 11, 2012 I am trying to attach a sound to someone, so when they /play there is a sound that will play to all players from around the player. Its working, but it freezes the postion, and wont attach to the player when he moves: client: function play (x,y,z) play = playSound3D('http://stream.electroradio.ch:26630/listen.pls', x,y,z) setSoundVolume(play, 10) setSoundMaxDistance(play, 100) end addEvent("play", true) addEventHandler("play", getRootElement(), play) server: function play2 (thePlayer) local x,y,z = getElementPosition(thePlayer) triggerClientEvent ( "play", getRootElement(), x,y,z ) end addCommandHandler("play", play2) Link to comment
Kenix Posted February 11, 2012 Share Posted February 11, 2012 Client addEvent( "play", true ) local sound function play ( ) local x,y,z = getElementPosition( source ) if isElement( sound ) then setElementPosition( sound,x,y,z ) else sound = playSound3D( 'http://stream.electroradio.ch:26630/listen.pls', x,y,z ) setSoundVolume( sound, 1.0 ) -- max 1.0 not 10 setSoundMaxDistance( sound, 100 ) end end addEventHandler( "play",root, play ) Server local timer = { } function play2 ( thePlayer ) if isTimer( timer[ thePlayer ] ) then killTimer( timer[ thePlayer ] ) end timer[ thePlayer ] = setTimer( function( player ) triggerClientEvent ( "play", player ) end, 1000, 0 ,thePlayer ) end addCommandHandler( "play", play2 ) addEventHandler( 'onPlayerQuit',root, function( ) timer[ source ] = nil end ) Updated again. Link to comment
Al3grab Posted February 11, 2012 Share Posted February 11, 2012 or you could function play (x,y,z,thePlayer) play = playSound3D('http://stream.electroradio.ch:26630/listen.pls', x,y,z) attachElements(play,thePlayer) setSoundVolume(play, 10) setSoundMaxDistance(play, 100) end addEvent("play", true) addEventHandler("play", getRootElement(), play) server: function play2 (thePlayer) local x,y,z = getElementPosition(thePlayer) triggerClientEvent ( "play", getRootElement(), x,y,z ,thePlayer) end addCommandHandler("play", play2) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now