Jump to content

Painel DX - Dúvidas


Recommended Posts

Posted (edited)

Olá pessoal , estou a fazer um painel pessoal em dx para rp, tenho umas dúvidas.

lembrando que estou usando um resource para criar o painel dx.

ex:

normalmente para clicar em um desses botões eu usaria o mouse.

tem como eu clicar com a tecla "enter" e movimentar entre elas com as setas up , down ...

kk4kZiw.png

 

Edited by Renaz
Posted

exemplo de um botao em dx ele é ativado pelo evento onClientCLick certo, no seu caso é diferente só é necessario mudar o ID da aba com bindkey.

abaAtual = 1
abas={
	{carros},
  	{motos},
  	{avioes}
}

function up ()
  abaAtual = abaAtual - 1
end
bindKey("arrow_u","down",up)

function down()
  abaAtual = abaAtual - 1
end
bindKey("arrow_d","down",down)

-- minha pagina sendo mostrada
abas[abaAtual]

espero que de para entender kk

 

obs: nao construir a funcao para ser utilizada é somente como exemplo basico de como deve ser construido

Posted (edited)

meio que entendi, mas no caso eu tenho vários menus ou seja cada botão do meu principal abre outro menu.

terei que fazer essa função em todos eles?

 

Edited by Renaz
Posted (edited)

Fiz algo bem simples, de uma maneira bem fácil(leiga), espero que te ajude na suas dúvidas.

Lembrando, isso é apenas um exemplo de como você pode fazer. (Não testado).

local screenW,screenH = guiGetScreenSize()
local x, y = (screenW/1366), (screenH/768)

--# Simples.

local aba_painel = 0

addEventHandler("onClientRender", getRootElement(), function ()
   if aba_painel == 0 then
      dxDrawRectangle(x*1366/2, y*(768/2), x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Admin
   else
      dxDrawRectangle(x*1366/2, y*(768/2), x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Admin
   end
   if aba_painel == 1 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Policia
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Policia
   end
   if aba_painel == 2 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*2, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Inventário
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*2, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Inventário
   end
   if aba_painel == 3 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*3, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Animação
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*3, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Animação
   end
   if aba_painel == 4 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*4, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Ações
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*4, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Ações
   end
   if aba_painel == 5 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*5, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Veiculo
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*5, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Veiculo
   end
    
   if aba_painel_menus == "Admin" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(100, 100, 0, 100), false)
   elseif aba_painel_menus == "Policia" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(255, 0, 0, 100), false)
   elseif aba_painel_menus == "Inventário" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(100, 100, 100, 100), false)
   elseif aba_painel_menus == "Animação" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 100, 0, 100), false)
   elseif aba_painel_menus == "Ações" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 0, 100, 100), false)
   elseif aba_painel_menus == "Veiculo" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 0, 255, 100), false)
   end
end)

function subir_tecla ()
   if aba_painel_principal >= 1 then 
      aba_painel_principal = aba_painel_principal - 1
   else
      outputChatBox("Você Subiu no Limite!") 
   end
end
bindKey("arrow_u", "down", subir_tecla)

function descer_tecla ()
   if aba_painel_principal <= 4 then 
      aba_painel_principal = aba_painel_principal + 1
   else
      outputChatBox("Você Desceu no Limite!") 
   end
end
bindKey("arrow_d", "down", descer_tecla)

function confirmar_tecla ()
   if aba_painel_principal == 0 then
      outputChatBox("Admin")
      aba_painel_menus = "Admin"
   elseif aba_painel_principal == 1 then
      outputChatBox("Policia")
      aba_painel_menus = "Policia"
   elseif aba_painel_principal == 2 then
      outputChatBox("Inventário")
      aba_painel_menus = "Inventário"
   elseif aba_painel_principal == 3 then
      outputChatBox("Animação")
      aba_painel_menus = "Animação"
   elseif aba_painel_principal == 4 then
      outputChatBox("Ações")
      aba_painel_menus = "Ações"
   elseif aba_painel_principal == 5 then
      outputChatBox("Veiculo")
      aba_painel_menus = "Veiculo"
   end
end
bindKey("enter", "down", confirmar_tecla)

function voltar_tecla ()
   if aba_painel_menus ~= "Nenhum" then
      aba_painel_menus = "Nenhum"
   end
end
bindKey("backspace", "down", voltar_tecla)

 

Edited by Angelo Pereira
  • Thanks 1
Posted (edited)

Desde já desculpe a demora para responder , testei no jogo mas não está funcionando para mover para cima e baixo.

além disso eu não consigo aplicar isto no meu código.

addEventHandler("onClientRender", getRootElement(), function ()
   if aba_painel == 0 then
      dxDrawRectangle(x*1366/2, y*(768/2), x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Admin
   else
      dxDrawRectangle(x*1366/2, y*(768/2), x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Admin
   end
   if aba_painel == 1 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Policia
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Policia
   end
   if aba_painel == 2 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*2, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Inventário
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*2, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Inventário
   end
   if aba_painel == 3 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*3, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Animação
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*3, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Animação
   end
   if aba_painel == 4 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*4, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Ações
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*4, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Ações
   end
   if aba_painel == 5 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*5, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Veiculo
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*5, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Veiculo
   end
    
   if aba_painel_menus == "Admin" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(100, 100, 0, 100), false)
   elseif aba_painel_menus == "Policia" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(255, 0, 0, 100), false)
   elseif aba_painel_menus == "Inventário" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(100, 100, 100, 100), false)
   elseif aba_painel_menus == "Animação" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 100, 0, 100), false)
   elseif aba_painel_menus == "Ações" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 0, 100, 100), false)
   elseif aba_painel_menus == "Veiculo" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 0, 255, 100), false)
   end
end)

meu código (Painel Principal)

function PainelPrincipal()
        dxDrawLine(23 - 1, 174 - 1, 23 - 1, 513, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 174 - 1, 23 - 1, 174 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 513, 218, 513, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 513, 218, 174 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 174, 195, 339, tocolor(0, 0, 0, 144), false)
        dxDrawRectangle(23, 174, 195, 44, tocolor(255, 63, 63, 182), false)
        dxDrawText("Painel Pessoal", 25 - 1, 177 - 1, 213 - 1, 214 - 1, tocolor(0, 0, 0, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Painel Pessoal", 25 + 1, 177 - 1, 213 + 1, 214 - 1, tocolor(0, 0, 0, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Painel Pessoal", 25 - 1, 177 + 1, 213 - 1, 214 + 1, tocolor(0, 0, 0, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Painel Pessoal", 25 + 1, 177 + 1, 213 + 1, 214 + 1, tocolor(0, 0, 0, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Painel Pessoal", 25, 177, 213, 214, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawLine(23 - 1, 219 - 1, 23 - 1, 255, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 219 - 1, 23 - 1, 219 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 255, 218, 255, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 255, 218, 219 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 219, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawText("Admin", 24, 218, 218, 254, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawLine(23 - 1, 255 - 1, 23 - 1, 291, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 255 - 1, 23 - 1, 255 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 291, 218, 291, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 291, 218, 255 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 255, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawLine(23 - 1, 291 - 1, 23 - 1, 327, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 291 - 1, 23 - 1, 291 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 327, 218, 327, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 327, 218, 291 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 291, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawLine(23 - 1, 327 - 1, 23 - 1, 363, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 327 - 1, 23 - 1, 327 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 363, 218, 363, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 363, 218, 327 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 327, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawLine(23 - 1, 363 - 1, 23 - 1, 399, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 363 - 1, 23 - 1, 363 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 399, 218, 399, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 399, 218, 363 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 363, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawLine(23 - 1, 399 - 1, 23 - 1, 435, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 399 - 1, 23 - 1, 399 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 435, 218, 435, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 435, 218, 399 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 399, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawLine(23 - 1, 435 - 1, 23 - 1, 471, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 435 - 1, 23 - 1, 435 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 471, 218, 471, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 471, 218, 435 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 435, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawLine(23 - 1, 471 - 1, 23 - 1, 507, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 471 - 1, 23 - 1, 471 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(23 - 1, 507, 218, 507, tocolor(0, 0, 0, 255), 1, false)
        dxDrawLine(218, 507, 218, 471 - 1, tocolor(0, 0, 0, 255), 1, false)
        dxDrawRectangle(23, 471, 195, 36, tocolor(255, 255, 255, 0), false)
        dxDrawText("Policia", 23, 254, 217, 290, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Mecânico", 23, 291, 217, 327, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Inem", 24, 327, 218, 363, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Inventário", 24, 363, 218, 399, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Animações", 24, 399, 218, 435, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Veiculo", 23, 435, 217, 471, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawText("Informações", 24, 471, 218, 507, tocolor(255, 255, 255, 255), 0.90, "pricedown", "center", "center", false, false, false, false, false)
        dxDrawRectangle(23, 507, 195, 6, tocolor(255, 63, 63, 182), false)
end

ele não está organizado da maneira que voce mostrou , tenho que criar outra função com os dxRectangle de parte? mas assim não iria criar conflito tendo 2 funçoes para cada painel?

 

j0zVqkV.png

 

Edited by Renaz
add detalhes
Posted

Deixarei o código aqui, que lhe enviei privado com as correções (Que acabei deixando passar).

local screenW,screenH = guiGetScreenSize()
local x, y = (screenW/1366), (screenH/768)

--# Simples.

local aba_painel_principal = 0 
local aba_painel_menus = "Nenhum" --/> Falto isso.

addEventHandler("onClientRender", getRootElement(), function ()
   if aba_painel_principal == 0 then
      dxDrawRectangle(x*1366/2, y*(768/2), x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Admin
   else
      dxDrawRectangle(x*1366/2, y*(768/2), x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Admin
   end
   if aba_painel_principal == 1 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Policia
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Policia
   end
   if aba_painel_principal == 2 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*2, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Inventário
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*2, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Inventário
   end
   if aba_painel_principal == 3 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*3, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Animação
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*3, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Animação
   end
   if aba_painel_principal == 4 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*4, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Ações
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*4, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Ações
   end
   if aba_painel_principal == 5 then
      dxDrawRectangle(x*1366/2, y*(768/2)+35*5, x*200, y*30, tocolor(100, 0, 0, 100), false) --/> Veiculo
   else
      dxDrawRectangle(x*1366/2, y*(768/2)+35*5, x*200, y*30, tocolor(0, 0, 0, 100), false) --/> Veiculo
   end
    
   if aba_painel_menus == "Admin" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(100, 100, 0, 100), false)
   elseif aba_painel_menus == "Policia" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(255, 0, 0, 100), false)
   elseif aba_painel_menus == "Inventário" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(100, 100, 100, 100), false)
   elseif aba_painel_menus == "Animação" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 100, 0, 100), false)
   elseif aba_painel_menus == "Ações" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 0, 100, 100), false)
   elseif aba_painel_menus == "Veiculo" then
      dxDrawRectangle(x*(1366/2)-200, y*(768/2)+35*5, x*200, y*100, tocolor(0, 0, 255, 100), false)
   end
end)

--/> Subir Botão (arrow_u).
function subir_tecla ()
   if aba_painel_principal >= 1 then 
      aba_painel_principal = aba_painel_principal - 1
   else
      outputChatBox("Você Subiu no Limite!") 
   end
end
bindKey("arrow_u", "down", subir_tecla)

--/> Descer Botão (arrow_d)
function descer_tecla ()
   if aba_painel_principal <= 4 then 
      aba_painel_principal = aba_painel_principal + 1
   else
      outputChatBox("Você Desceu no Limite!") 
   end
end
bindKey("arrow_d", "down", descer_tecla)

--/> Acessa Painel (Enter).
function confirmar_tecla ()
   if aba_painel_principal == 0 then
      outputChatBox("Admin")
      aba_painel_menus = "Admin"
   elseif aba_painel_principal == 1 then
      outputChatBox("Policia")
      aba_painel_menus = "Policia"
   elseif aba_painel_principal == 2 then
      outputChatBox("Inventário")
      aba_painel_menus = "Inventário"
   elseif aba_painel_principal == 3 then
      outputChatBox("Animação")
      aba_painel_menus = "Animação"
   elseif aba_painel_principal == 4 then
      outputChatBox("Ações")
      aba_painel_menus = "Ações"
   elseif aba_painel_principal == 5 then
      outputChatBox("Veiculo")
      aba_painel_menus = "Veiculo"
   end
end
bindKey("enter", "down", confirmar_tecla)

--/> Retorna (backspace)
function voltar_tecla ()
   if aba_painel_menus ~= "Nenhum" then
      aba_painel_menus = "Nenhum"
   end
end
bindKey("backspace", "down", voltar_tecla)

 

  • Thanks 1

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