Baseplate Posted December 6, 2013 Share Posted December 6, 2013 addEvent("startSound", true) addEventHandler("startSound", root, function(url) destroyElement(sound) local x, y, z = getElementPosition(source) sound = playSound(tostring(url), x, y, z) end ) addEventHandler("onClientGUIClick", root, function() if (source == playButton) then if (not guiGetText(linkEdit) == "") then triggerServerEvent("setCustomStream", root, guiGetText(linkEdit)) else local radioUrl = guiGridListGetItemText(radioGrid, guiGridListGetSelectedItem(radioGrid), 2) triggerServerEvent("setCustomStream", root, radioUrl) end end end ) addEvent("setCustomStream", true) addEventHandler("setCustomStream", root, function(radio, p) if (p == source) then local x, y, z = getElementPosition(p) destroyElement(speaker) speaker = createObject(2229, x, y, z) triggerClientEvent(root, "startSound", root, radio) local vehicle = getPedOccupiedVehicle(p) attachElements(speaker, vehicle) end end ) Not working, nothing happens, no errors on debug. Link to comment
Tete omar Posted December 6, 2013 Share Posted December 6, 2013 Replace line 6 with: sound = playSound3D ( tostring ( url ), x, y, z ) P.S. In my opinion, i don't like this way to create a speakers script Link to comment
Baseplate Posted December 7, 2013 Author Share Posted December 7, 2013 Can you suggest me a better way if possible? Link to comment
TAPL Posted December 7, 2013 Share Posted December 7, 2013 Replace line 17 with: triggerServerEvent("setCustomStream", root, radioUrl, localPlayer) And remove this with one 'end'. if (p == source) then And change this: triggerClientEvent(root, "startSound", root, radio) To: triggerClientEvent(root, "startSound", p, radio) Link to comment
Baseplate Posted December 7, 2013 Author Share Posted December 7, 2013 I'm trying to play the music everywhere, like everyone can listen to it. Link to comment
TAPL Posted December 7, 2013 Share Posted December 7, 2013 addEvent("startSound", true) addEventHandler("startSound", root, function(url, speaker) if isElement(sound) then destroyElement(sound) end local x, y, z = getElementPosition(speaker) sound = playSound3D(url, x, y, z) attachElements(sound, speaker) end) addEventHandler("onClientGUIClick", root, function() if (source == playButton) then local link = guiGetText(linkEdit) if (link ~=) then triggerServerEvent("setCustomStream", root, link) else local radioUrl = guiGridListGetItemText(radioGrid, guiGridListGetSelectedItem(radioGrid), 2) if (radioUrl ~= "") then triggerServerEvent("setCustomStream", localPlayer, radioUrl) end end end end) addEvent("setCustomStream", true) addEventHandler("setCustomStream", root, function(radio) if isElement(speaker) then destroyElement(speaker) end local vehicle = getPedOccupiedVehicle(source) if vehicle then local x, y, z = getElementPosition(source) speaker = createObject(2229, x, y, z) triggerClientEvent(root, "startSound", root, radio, speaker) attachElements(speaker, vehicle) end end) Link to comment
Baseplate Posted December 7, 2013 Author Share Posted December 7, 2013 sound = playSound(url, x, y, z) setSoundMaxDistance(sound, 2) Well, everyone at the server can hear it. Link to comment
Tete omar Posted December 7, 2013 Share Posted December 7, 2013 You said you want every player can hear the sound already, what's the problem now? Link to comment
Baseplate Posted December 7, 2013 Author Share Posted December 7, 2013 Didn't mean that, lol my English is getting worse.. I meant like, the people close to you (the streamer) and I apologize for any disturbing. Link to comment
Tete omar Posted December 7, 2013 Share Posted December 7, 2013 Then use: playSound3D Link to comment
Baseplate Posted December 7, 2013 Author Share Posted December 7, 2013 playSound3D is somehow not working, playSound works. EDIT: Never mind! works! lmao, thanks. 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