Luizinho Posted July 5, 2021 Share Posted July 5, 2021 Se alguém puder me ajudar eu agradeço. Estou com um script de DJ, só que eu queria colocar em outros pontos para reproduzir uma música, minha ideia seria de colocar um objeto de caixa de som em vários postes e assim estaria reproduzindo uma música do painel DJ. Link to comment
Tekken Posted July 5, 2021 Share Posted July 5, 2021 I've moved your topic to the appropriate section for the best results! (Mudei seu tópico para a seção apropriada para obter os melhores resultados!) Greetings! 1 Link to comment
Other Languages Moderators androksi Posted July 5, 2021 Other Languages Moderators Share Posted July 5, 2021 Olá. Seja bem-vindo(a) ao fórum. É totalmente possível. Você deve obter as posições X, Y e Z, dos locais cujo a música será reproduzida. Uma vez com elas, ao criar o som, usando a função playSound3D, você iria fazer um loop for naquelas posições e criar o som para cada ponto. Exemplo: Spoiler local sounds = {} local pointsOfSound = { {0, 0, 3}, {10, 20, 3}, {0, -10, 3}, {-30, 20, 3} } function createSounds() for i = 1, #pointsOfSound do local x, y, z = unpack(pointsOfSound[i]) sounds[i] = playSound3D("seu_som.mp3", x, y, z) end end function destroySounds() if #sounds > 0 then for i = 1, #sounds do if isElement(sounds[i]) then destroyElement(sounds[i]) end end sounds = {} end end function toggleSound(command) if command == "mstart" then createSounds() elseif command == "mstop" then destroySounds() end end addCommandHandler("mstart", toggleSound) addCommandHandler("mstop", toggleSound) Com o comando /mstart você inicia a música. Vá até a posição 0, 0, 3 (centro de SA), terá vários pontos tocando música. Pode usar o comando /mstop pra encerrar a execução da música. Link to comment
Luizinho Posted July 5, 2021 Author Share Posted July 5, 2021 4 hours ago, andr0xy said: Olá. Seja bem-vindo(a) ao fórum. É totalmente possível. Você deve obter as posições X, Y e Z, dos locais cujo a música será reproduzida. Uma vez com elas, ao criar o som, usando a função playSound3D, você iria fazer um loop for naquelas posições e criar o som para cada ponto. Exemplo: Hide contents local sounds = {} local pointsOfSound = { {0, 0, 3}, {10, 20, 3}, {0, -10, 3}, {-30, 20, 3} } function createSounds() for i = 1, #pointsOfSound do local x, y, z = unpack(pointsOfSound[i]) sounds[i] = playSound3D("seu_som.mp3", x, y, z) end end function destroySounds() if #sounds > 0 then for i = 1, #sounds do if isElement(sounds[i]) then destroyElement(sounds[i]) end end sounds = {} end end function toggleSound(command) if command == "mstart" then createSounds() elseif command == "mstop" then destroySounds() end end addCommandHandler("mstart", toggleSound) addCommandHandler("mstop", toggleSound) Com o comando /mstart você inicia a música. Vá até a posição 0, 0, 3 (centro de SA), terá vários pontos tocando música. Pode usar o comando /mstop pra encerrar a execução da mús Ahh sim obrigado, mas precisa necessariamente ter esse comando /mstart e /mstop ? Link to comment
Other Languages Moderators androksi Posted July 5, 2021 Other Languages Moderators Share Posted July 5, 2021 Não precisa, foi só um exemplo. Link to comment
Luizinho Posted July 5, 2021 Author Share Posted July 5, 2021 10 minutes ago, andr0xy said: Não precisa, foi só um exemplo. Ahh blz, vou testar aqui obrigado. testei aqui e não deu certo. Onde eu posso encaixar essa função pra funcionar? client local screenW,screenH = guiGetScreenSize() local resW, resH = 1280, 1024 local x, y = (screenW/resW), (screenH/resH) local root = getRootElement() local volume_menos = 0.1 local volume_mais = 0.1 stream = {} dj = false animON = false info = false addEventHandler("onClientResourceStart", resourceRoot, function() Link = guiCreateEdit(x*411, y*374, x*408, y*46, "Cole o link aqui...", false) guiSetVisible ( Link, false ) end ) function dx () local alpha,alpha2,alpha3= interpolateBetween(0, 0, 0, 255, 136, 200, ((getTickCount() - djt) / 2000), "Linear") local meta = getSoundMetaTags(stream) dxDrawRectangle(x*346, y*198, x*537, y*550, tocolor(0, 0, 0, alpha2), false) dxDrawRectangle(x*346, y*198, x*537, y*74, tocolor(5, 239, 5, alpha2), false) dxDrawText("PAINEL DJ", x*500, y*220, x*732, y*252, tocolor(255, 255, 255, alpha), x*2.00, "default-bold", "center", "top", false, false, false, false, false) dxDrawText("X", x*831, y*220, x*864, y*252, tocolor(255, 255, 255, alpha), 2.00, "default-bold", "center", "center", false, false, false, false, false) if ismouseinposition (x*411, y*435, x*88, y*35) then dxDrawRectangle(x*411, y*435, x*88, y*35, tocolor(5, 239, 5, alpha3), false) else dxDrawRectangle(x*411, y*435, x*88, y*35, tocolor(5, 239, 5, alpha2), false) end if ismouseinposition (x*518, y*435, x*88, y*35) then dxDrawRectangle(x*518, y*435, x*88, y*35, tocolor(5, 239, 5, alpha3), false) else dxDrawRectangle(x*518, y*435, x*88, y*35, tocolor(5, 239, 5, alpha2), false) end if ismouseinposition (x*624, y*435, x*88, y*35) then dxDrawRectangle(x*624, y*435, x*88, y*35, tocolor(5, 239, 5, alpha3), false) else dxDrawRectangle(x*624, y*435, x*88, y*35, tocolor(5, 239, 5, alpha2), false) end if ismouseinposition (x*731, y*435, x*88, y*35) then dxDrawRectangle(x*731, y*435, x*88, y*35, tocolor(5, 239, 5, alpha3), false) else dxDrawRectangle(x*731, y*435, x*88, y*35, tocolor(5, 239, 5, alpha2), false) end dxDrawText("Volume -", x*411, y*435, x*499, y*470, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Volume +", x*518, y*435, x*606, y*470, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Tocar", x*624, y*435, x*712, y*470, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Parar", x*731, y*435, x*819, y*470, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawRectangle(x*411, y*496, x*408, y*230, tocolor(0, 0, 0, alpha2), false) if not meta then dxDrawText("Duração: N/A", x*411, y*336, x*615, y*364, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "left", "center", false, false, false, false, false) dxDrawText("Tocando agora: N/A", x*411, y*283, x*819, y*308, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "left", "center", false, false, false, false, false) dxDrawText("Adicionado por: N/A", x*411, y*308, x*615, y*336, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "left", "center", false, false, false, false, false) dxDrawText("Volume: 00%", x*615, y*336, x*819, y*364, tocolor(255, 255, 255, alpha), x*1.00, "default-bold", "left", "center", false, false, false, false, false) end end function dx_2 () local meta = getSoundMetaTags(stream) if not meta then return end local duracao_musica = getSoundLength(stream) local anim = getSoundFFTData(stream, 8192, 30) local titulo = meta.title or meta.stream_title or "N/A" local msecs = duracao_musica*1000 local secs = msecs/1000 local duracao = string.format("%.2d:%.2d:%.2d",secs/(60*60),secs/60%60,secs%60) local volume = math.round ( getSoundVolume ( stream ), 2 ) if animON == true then dxDrawText("Tocando agora: "..titulo, x*411, y*283, x*819, y*308, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", true, false, false, false, false) dxDrawText("Duração: "..duracao, x*411, y*336, x*615, y*364, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, false, false) dxDrawText("Adicionado por: "..nome, x*411, y*308, x*615, y*336, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false) dxDrawText("Volume: "..math.floor ( volume * 100 ).."%", x*615, y*336, x*819, y*364, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, false, false) for i,v in pairs(anim) do tamanho = math.round((v*320),0)>100 and 100 or math.round((v*320),0) largura = 13 dxDrawRectangle(x*418+(i*x*largura), y*720, x*largura-1, y*2*tamanho*-1, tocolor(5, 239, 5, 136), false) end end end -------------------------------- PLAYSOUND 3D addEvent ( "DestruiDJ", true ) addEventHandler ( "DestruiDJ", root, function ( who ) if ( isElement ( stream ) ) then destroyElement ( stream ) end end ) addEvent ( "VolumeDJ", true ) addEventHandler ( "VolumeDJ", root, function ( who, vol ) if ( isElement ( stream ) ) then setSoundVolume ( stream, tonumber ( vol ) ) end end ) addEvent ( "CrioDJ", true ) addEventHandler ( "CrioDJ", root, function ( who, Link, isCar ) if ( isElement ( stream ) ) then destroyElement ( stream ) end local x, y, z = getElementPosition ( who ) stream = playSound3D ( Link, x, y, z, true ) setSoundVolume ( stream, 1 ) setSoundMinDistance (stream, 17 ) setSoundMaxDistance ( stream, 250 ) end ) function tocar(_,estado) if dj == true then if estado == "down" then if ismouseinposition(x*624, y*435, x*88, y*35) then setTimer ( function() local meta = getSoundMetaTags(stream) local duracao_musica = getSoundLength(stream) local titulo = meta.title or meta.stream_title or "N/A" local msecs = duracao_musica*1000 local secs = msecs/1000 local duracao = string.format("%.2d:%.2d:%.2d",secs/(60*60),secs/60%60,secs%60) outputChatBox ( "#FFFFFF==> #00FF00Música#FFFFFF: "..titulo.." = #00FF00Duração: #FFFFFF"..duracao..".", 255, 255, 255 ,true) end, 2000, 1 ) triggerServerEvent ( "CrioDJ", localPlayer, guiGetText ( Link )) addEventHandler("onClientRender",root,dx_2) playSoundFrontEnd(1) isSound = true animON = true end end end end addEventHandler("onClientClick",root,tocar) function Parar(_,estado) if dj == true then if estado == "down" then if ismouseinposition(x*731, y*435, x*88, y*35) then triggerServerEvent ( "DestruiDJ", localPlayer ) outputChatBox ( "#FFFFFF==> #00FF00Você cancelo a repodrução da musica atual.", 255, 255, 255 ,true) removeEventHandler ("onClientRender", root, dx_2) playSoundFrontEnd(2) isSound = false animON = false end end end end addEventHandler("onClientClick",root,Parar) function Volumemenos(_,estado) if dj == true then if estado == "down" then if ismouseinposition(x*411, y*435, x*88, y*35) then playSoundFrontEnd(3) if ( isSound ) then local volume = math.round ( getSoundVolume ( stream ) - volume_menos, 2 ) if ( volume > 0.0 ) then triggerServerEvent ( "VolumealteradoDJ", localPlayer, volume ) --outputChatBox ( "#FFFFFF==> #00FF00Volume alterado para "..math.floor ( volume * 100 ).."%.", 0, 255, 255 ,true) else outputChatBox ( "#FFFFFF==> #00FF00DJ está no volume minimo.", 0, 255, 255 ,true) end end end end end end addEventHandler("onClientClick",root,Volumemenos) function Volumemais(_,estado) if dj == true then if estado == "down" then if ismouseinposition(x*518, y*435, x*88, y*35) then playSoundFrontEnd(3) if ( isSound ) then local volume = math.round ( getSoundVolume ( stream ) + volume_mais, 2 ) if ( volume < 1.1 ) then triggerServerEvent ( "VolumealteradoDJ", localPlayer, volume ) --outputChatBox ( "#FFFFFF==> #00FF00Volume alterado para "..math.floor ( volume * 100 ).."%.", 0, 255, 255 ,true) else outputChatBox ( "#FFFFFF==> #00FF00DJ está no volume maximo.", 0, 255, 255 ,true) end end end end end end addEventHandler("onClientClick",root,Volumemais) function fechar(_,estado) if dj == true then if estado == "down" then if ismouseinposition(x*831, y*220, x*53, y*37) then playSoundFrontEnd(5) showCursor(false) removeEventHandler("onClientRender",root,dx) removeEventHandler ("onClientRender", root, dx_2) guiSetVisible ( Link, false ) dj = false animON = false end end end end addEventHandler("onClientClick",root,fechar) function dj_add (djay_painel) nome=djay_painel; end addEvent ("Djay",true) addEventHandler ("Djay",root,dj_add) function mostrarpainelDJ () if dj == false then addEventHandler ("onClientRender", root, dx) djt = getTickCount() guiSetVisible ( Link, true ) addEventHandler("onClientRender",root,dx_2) animON = true showCursor (true) dj = true else removeEventHandler ("onClientRender", root, dx) guiSetVisible ( Link, false ) showCursor (false) dj = false animON = false end end addEvent ("Dj",true) addEventHandler ("Dj",root,mostrarpainelDJ) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"format(number)) end end function ismouseinposition ( x, y, width, height ) if ( not isCursorShowing ( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end server Audio = {} local abrirpainel = createMarker(1399.1379394531,-1999.8752441406,56.180889129639 -1,"cylinder", 2, 0, 255, 0, 100) --- PRAIA function mostrarpainel(thePlayer) triggerClientEvent(thePlayer, "Dj", getRootElement() ) end addEventHandler("onMarkerHit", abrirpainel, mostrarpainel) addEvent ( "CrioDJ", true ) addEventHandler ( "CrioDJ", root, function ( Link ) if ( Link ) then if ( isElement ( Audio [ source ] ) ) then local x, y, z = getElementPosition ( Audio [ source ] ) destroyElement ( Audio [ source ] ) end local x, y, z = getElementPosition ( source ) Audio [ source ] = createMarker(x-0.5, y+0.5, z - 1,"cylinder", 1, 0, 255, 255, 0) triggerClientEvent ( root, "CrioDJ", source, source, Link ) triggerClientEvent(root, "Djay", root, getPlayerName( source ) ) end end) addEvent ( "VolumealteradoDJ", true ) addEventHandler ( "VolumealteradoDJ", root, function ( to ) triggerClientEvent ( root, "VolumeDJ", source, source, to ) end ) addEvent ( "DestruiDJ", true ) addEventHandler ( "DestruiDJ", root, function ( ) if ( isElement ( Audio [ source ] ) ) then destroyElement ( Audio [ source ] ) triggerClientEvent ( root, "DestruiDJ", source, source ) end end ) 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