Tony Brand Posted September 12, 2018 Posted September 12, 2018 Hi, i made a function called syncSong it works like this: addEvent("syncSong", true) addEventHandler("syncSong", root, function( ) local song = playSound("data/sound.mp3", false) setSoundVolume(song, 0.9) setSoundMaxDistance(song, 2) end) as you see i setSoundMaxDistance(song, 2) so now sound must be played in a short range!but problem is when players use that command thats trigger this event,sound plays for whole server in every place! also here is the CommandHandler addCommandHandler( "alarm", triggerClientEvent("syncSong", getRootElement()) etc(another codes under this line...)
Tony Brand Posted September 12, 2018 Author Posted September 12, 2018 (edited) so it must change to local song = playSound3D("data/sound.mp3", false) Edited September 12, 2018 by Tony Brand
MIKI785 Posted September 12, 2018 Posted September 12, 2018 46 minutes ago, Tony Brand said: so it must change to local song = playSound3D("data/sound.mp3", false) Check the arguments on the wiki... you have to specify the X, Y and Z co-ordinates.
Tony Brand Posted September 12, 2018 Author Posted September 12, 2018 1 minute ago, MIKI785 said: Check the arguments on the wiki... you have to specify the X, Y and Z co-ordinates. yes i saw it, i need to get player x y z ! can you help me?
MIKI785 Posted September 12, 2018 Posted September 12, 2018 Just now, Tony Brand said: yes i saw it, i need to get player x y z ! can you help me? Use getPlayerPosition and pass the returned values to playSound3D
Tony Brand Posted September 12, 2018 Author Posted September 12, 2018 Just now, MIKI785 said: Use getPlayerPosition and pass the returned values to playSound3D There is currently no text in this page , it is what i see in getPlayerPosition
Tony Brand Posted September 12, 2018 Author Posted September 12, 2018 addEvent("syncSong", true) addEventHandler("syncSong", root, function( ) local x,y,z = getElementPosition( ) local song = playSound3D("data/sound.mp3", x, y, z, false) setSoundVolume(song, 0.9) setSoundMaxDistance( song, 100 ) end) where i did wrong?
Dimos7 Posted September 12, 2018 Posted September 12, 2018 addEvent("syncSong", true) addEventHandler("syncSong", root, function( ) local x,y,z = getElementPosition(localPlayer) local song = playSound3D("data/sound.mp3", x, y, z, false) setSoundVolume(song, 0.9) setSoundMaxDistance( song, 100 ) end)
Tony Brand Posted September 12, 2018 Author Posted September 12, 2018 5 minutes ago, Dimos7 said: addEvent("syncSong", true) addEventHandler("syncSong", root, function( ) local x,y,z = getElementPosition(localPlayer) local song = playSound3D("data/sound.mp3", x, y, z, false) setSoundVolume(song, 0.9) setSoundMaxDistance( song, 100 ) end) it has no error but again whole the server can hear the sound
Addlibs Posted September 12, 2018 Posted September 12, 2018 (edited) local x,y,z = getElementPosition(source) And make sure when you trigger that event on the server, that the source of the event is the player who played the song. I.e. triggerClientEvent(root, "syncSong", thePlayerWhoPlayedTheSong) -- ^ who will hear the song ^ event source Edited September 12, 2018 by MrTasty 1
Tony Brand Posted September 12, 2018 Author Posted September 12, 2018 5 minutes ago, MrTasty said: local x,y,z = getElementPosition(source) And make sure when you trigger that event on the server, that the source of the event is the player who played the song. I.e. triggerClientEvent(root, "syncSong", thePlayerWhoPlayedTheSong) tnx fixed
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