Jump to content

Como fechar um painel DX?


Recommended Posts

  Estou com problema para fechar o painel, ele abre mas não fecha, testei usar um while panel == true, mas acabou travando o jogo. Quero que feche o painel quando o jogador sair da barbearia.

Segue o código:

 

Server-side:

-- Quando o jogador entra no marker
function hitarMarker(marker, dim)
    if dim and not isPedInVehicle(source)  then
        -- abaixo ele verifica se o marker hitado é equivalente ao index [1] valor [1] da tabela enterMarker, ou seja a marker criada 1.
        if marker == enterMarker[1][1] then
            outputChatBox("Bem-vindo ao Reece's Barbershop", source, 127,255,212, true)
            teleportPlayer(source, 2, 411.61981, -22.34467, 1001.80469 , 0)
            triggerClientEvent(source, "showPanel", source, true) -- Ativa o painel
        elseif marker == exitMarker[1][1] then
            teleportPlayer(source, 0, 2071.88013, -1793.78210, 13.54688, 0)
            triggerClientEvent(source, "showPanel", source, false) -- Deveria desativar o painel
        end
    end
end
addEventHandler("onPlayerMarkerHit", getRootElement(), hitarMarker)

Client-side:

local screenW, screenH = guiGetScreenSize()

function barbershop(status)
    outputChatBox(tostring(status))
    local panel = status
    if panel == true then
        addEventHandler("onClientRender", root, function()
            bleft = dxDrawImage((screenW - 400) / 2, (screenH - 200) / 2, 100, 100, "img/arrow.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
            bright = dxDrawImage((screenW + 200) / 2, (screenH - 200) / 2, 100, 100, "img/arrow.png", 180, 0, 0, tocolor(255, 255, 255, 255), false)
            bconfirm = dxDrawImage((screenW - 100) / 2, (screenH + 200) / 2, 100, 100, "img/scissors.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        end)
    end
end
addEvent( "showPanel", true )
addEventHandler( "showPanel", localPlayer, barbershop)

 

Link to comment
  • Other Languages Moderators
local screenW, screenH = guiGetScreenSize()

function draw()
    dxDrawImage((screenW - 400) / 2, (screenH - 200) / 2, 100, 100, "img/arrow.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage((screenW + 200) / 2, (screenH - 200) / 2, 100, 100, "img/arrow.png", 180, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawImage((screenW - 100) / 2, (screenH + 200) / 2, 100, 100, "img/scissors.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end

function barbershop(status)
    if not type(status) == "boolean" then
        return false
    end

    if status == true then
        addEventHandler("onClientRender", root, draw)
    elseif status == false then
        removeEventHandler("onClientRender", root, draw)
    end
end
addEvent( "showPanel", true )
addEventHandler( "showPanel", localPlayer, barbershop)

Não crie variáveis para funções de renderização (dxDrawImage, dxDrawRectangle, dxDrawText etc). Elas devem ficar dentro de um bloco de função, sendo assim, basta, depois, adicionar ou remover o evento onClientRender nesta função, que no caso acima é a draw.

  • Thanks 1
Link to comment

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...