NoviceWithManyProblems Posted January 14, 2020 Posted January 14, 2020 Code: CLIENT: triggerServerEvent("musics", root) SERVER: addEvent("musics", true) addEventHandler("musics", root, function() triggerClientEvent("music", root) end) CLIENT: (...) addEvent("music", true) addEventHandler("music", root, function() local url = guiGetText(edit) sound = playSound3D(tostring(url), x, y, z, true) setSoundMaxDistance(sound, 100) exports.bone_attach:attachElementToBone(sound, player, 11, 0, 0, 0.4, 180) (...) after calling this code, play3DSound can be heard only by the person who called it. Please help to me.
Moderators IIYAMA Posted January 14, 2020 Moderators Posted January 14, 2020 55 minutes ago, NoviceWithManyProblems said: after calling this code, play3DSound can be heard only by the person who called it. local url = guiGetText(edit) triggerServerEvent("musics", resourceRoot, localPlayer, url ) addEvent("musics", true) addEventHandler("musics", resourceRoot, function(player, ...) if isElement(player) then triggerClientEvent("music", resourceRoot, player, ...) -- send to all players end end, false) addEvent("music", true) addEventHandler("music", resourceRoot, function(player, url) if isElement(player) then local x,y,z = getElementPosition(player) local sound = playSound3D(tostring(url), x, y, z, true) setSoundMaxDistance(sound, 100) exports.bone_attach:attachElementToBone(sound, player, 11, 0, 0, 0.4, 180) --[[ ... ]] Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
sacr1ficez Posted January 14, 2020 Posted January 14, 2020 58 minutes ago, NoviceWithManyProblems said: Code: CLIENT: triggerServerEvent("musics", root) SERVER: addEvent("musics", true) addEventHandler("musics", root, function() triggerClientEvent("music", root) end) CLIENT: (...) addEvent("music", true) addEventHandler("music", root, function() local url = guiGetText(edit) sound = playSound3D(tostring(url), x, y, z, true) setSoundMaxDistance(sound, 100) exports.bone_attach:attachElementToBone(sound, player, 11, 0, 0, 0.4, 180) (...) after calling this code, play3DSound can be heard only by the person who called it. Please help to me. By the way there's no need to attach sound by using bone attach. You can use attachElements instead - https://wiki.multitheftauto.com/wiki/AttachElements Script security
NoviceWithManyProblems Posted January 14, 2020 Author Posted January 14, 2020 2 hours ago, IIYAMA said: local url = guiGetText(edit) triggerServerEvent("musics", resourceRoot, localPlayer, url ) addEvent("musics", true) addEventHandler("musics", resourceRoot, function(player, ...) if isElement(player) then triggerClientEvent("music", resourceRoot, player, ...) -- send to all players end end, false) addEvent("music", true) addEventHandler("music", resourceRoot, function(player, url) if isElement(player) then local x,y,z = getElementPosition(player) local sound = playSound3D(tostring(url), x, y, z, true) setSoundMaxDistance(sound, 100) exports.bone_attach:attachElementToBone(sound, player, 11, 0, 0, 0.4, 180) --[[ ... ]] I did it 1: 1 as you specified, checked from another computer, the same does not work, someone play something - I can't hear, I play something - he can't hear
NoviceWithManyProblems Posted January 14, 2020 Author Posted January 14, 2020 @IIYAMA do you need more informations? please help to me. 1
Moderators Patrick Posted January 14, 2020 Moderators Posted January 14, 2020 (edited) guiGetText(edit) returns valid data? Edited January 14, 2020 by stPatrick 1 community profile | map converters | map images | pDownloader | pAttach | model encrypter
Moderators IIYAMA Posted January 14, 2020 Moderators Posted January 14, 2020 56 minutes ago, NoviceWithManyProblems said: @IIYAMA do you need more informations? please help to me. Add some more debug lines to the code. 1. So that it is clear which code is running and which code doesn't. 2. Also inspect some of the variable so that we don't have to gamble what values are used. If you give me enough of that, then yes I will be able to help you better. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
NoviceWithManyProblems Posted January 15, 2020 Author Posted January 15, 2020 17 hours ago, stPatrick said: guiGetText(edit) returns valid data? yes, music start play correctly but only person who start this can hear music. 16 hours ago, IIYAMA said: Add some more debug lines to the code. 1. So that it is clear which code is running and which code doesn't. 2. Also inspect some of the variable so that we don't have to gamble what values are used. If you give me enough of that, then yes I will be able to help you better. All works good, no problems in DB3 - music play correctly but I one person who can hear this music I want everyone to hear her
Moderators IIYAMA Posted January 15, 2020 Moderators Posted January 15, 2020 18 minutes ago, NoviceWithManyProblems said: All works good, no problems in DB3 - music play correctly but I one person who can hear this music I want everyone to hear her That is already added. If that is not happening, then you will have to follow my instructions in my previous reply. Which should contain a copy of the new code with debug lines + results. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators Patrick Posted January 15, 2020 Moderators Posted January 15, 2020 Paste the full code. community profile | map converters | map images | pDownloader | pAttach | model encrypter
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