Jump to content

AJUDA PAINEL DJ


Recommended Posts

Posted

Boa noite, bom queria uma ajuda, tenho um painel de DJ, o player entra no Marker e logo aparece um painel para que ele cole o link da musica, e começar a tocar, ate ai tudo bem, sendo que quero por esse painel de DJ, em mais lugares e sempre que mudo de lugar as musica duplica, ou seja, eu coloco ele em um determinado lugar, e logo em seguida eu pego o mesmo script mudo o nome, funções e posições, e mesmo assim as musica duplica, alguem poderia me ajudar?

Posted

Sem ter o código do resource ninguém vai poder ajudar. Mostre o código aqui.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)

SERVER

 

Audio = {}

local abrirpainel = createMarker(299.12530517578, -1816.7014160156, 4.3,"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 )

CLIENTE

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, 50 )
    setSoundMaxDistance ( stream, 50 )
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

 

Edited by DNL291
Código adicionado com a formatação Lua
Posted
Audio = {}

local merkers = {
    createMarker(299.12530517578, -1816.7014160156, 4.3,"cylinder", 2, 0, 255, 0, 100), --- PRAIA
    createMarker(299.12530517578, -1816.7014160156, 4.3,"cylinder", 2, 0, 255, 0, 100),
}

for i=1, #merkers do
    setElementData( merkers[i], "tocarSom_marker", true, false )
end

function mostrarpainel(thePlayer)
    if not getElementData(source, "tocarSom_marker") or getElementType(thePlayer) ~= "player" then return end

    if not Audio[thePlayer] then
        triggerClientEvent( thePlayer, "Dj", getRootElement() )
    end
end
addEventHandler("onMarkerHit", resourceRoot, 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 )

Tenta isso

  • Like 1

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)

Teste lá, duplique os resources (não é o melhor jeito) e mude as posições, acho que agora os eventos/triggers de um não influenciarão no outro.

Audio = {}

local abrirpainel = createMarker(299.12530517578, -1816.7014160156, 4.3,"cylinder", 2, 0, 255, 0, 100) --- PRAIA
function mostrarpainel(thePlayer)
    triggerClientEvent(thePlayer, "Dj", resourceRoot )
end
addEventHandler("onMarkerHit", abrirpainel, mostrarpainel)

addEvent ( "CrioDJ", true )
addEventHandler ( "CrioDJ", root, function ( Link ) 
    if ( Link ) then
        if ( isElement ( Audio [ client ] ) ) then
            local x, y, z = getElementPosition ( Audio [ client ] ) 
            destroyElement ( Audio [ client ] )
        end
        local x, y, z = getElementPosition ( client )
        Audio [ client ] = createMarker(x-0.5, y+0.5, z - 1,"cylinder", 1, 0, 255, 255, 0)
        triggerClientEvent ( root, "CrioDJ", resourceRoot, client, Link )
        triggerClientEvent(root, "Djay", resourceRoot, getPlayerName( client ) )
    end
end)

addEvent ( "VolumealteradoDJ", true ) 
addEventHandler ( "VolumealteradoDJ", root, function ( to )
    triggerClientEvent ( root, "VolumeDJ", resourceRoot, client, to )
end )

addEvent ( "DestruiDJ", true )
addEventHandler ( "DestruiDJ", root, function ( )
    if ( isElement ( Audio [ client ] ) ) then
        destroyElement ( Audio [ client ] )
        triggerClientEvent ( root, "DestruiDJ", resourceRoot, client )
    end
end )
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", resourceRoot, function ( who ) 
    if ( isElement ( stream ) ) then 
        destroyElement ( stream  ) 
    end
end )

addEvent ( "VolumeDJ", true )
addEventHandler ( "VolumeDJ", resourceRoot, function ( who, vol ) 
    if ( isElement ( stream ) ) then
        setSoundVolume ( stream, tonumber ( vol ) )
    end
end )

addEvent ( "CrioDJ", true )
addEventHandler ( "CrioDJ", resourceRoot, 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, 50 )
    setSoundMaxDistance ( stream, 50 )
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", resourceRoot, 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", resourceRoot )
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", resourceRoot, 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", resourceRoot, 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",resourceRoot,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",resourceRoot,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

 

Edited by MaligNos
  • Like 1
Posted

Eu testei aqui e não teve nenhuma duplicação. playSound3D foi chamada 1x como esperado. 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Ele quer dois "ambientes" de DJ, no seu código no caso você permite vários markers para abrir o painel, porém a criação do som em um substituirá a de outro, porque não tratou no lado cliente.

Posted

Fiquei confuso pois ele disse duplicar as músicas, acho que não foi o que entendi quis ele quis dizer então. Talvez o problema seja depois que toca a primeira, e ocorre na verdade conflito pelo script não ser adaptado para funcionar para várias markers.

Para funcionar dessa forma o que ele precisa fazer é tocar o som do jogador (DJ) e salvar ele para a marker que o painel abriu, e tudo mais seguindo essa ideia - ao remover verificar qual a marker que o player está, verificando se existe o sound-element, ao tocar o mesmo, aumentar volume, informações no lado cliente, etc.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Sim, é que ele duplicava os resources, porém os eventos e triggers como estavam iriam interferir em todos, ai se ele muda-se a música em um, ela alterava em outro também.
É, o melhor seria adaptar o mesmo resource para suportar essas variações.

Posted (edited)

Isso que eu faria, mas se as markers pra abrir o painel forem só 2 acho que seria mais simples pra ele duplicar os resources com os eventos adaptados para não ter conflitos. Senão o melhor realmente seria adaptar o código para várias markers.

Edited by DNL291

Please do not PM me with scripting related question nor support, use the forums instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...