Jump to content

[Dúvida] DX Script


Recommended Posts

-- Client

local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1440), (screenH/900)

painel = false


function painel1 ()

        dxDrawRectangle(screenW * 0.8279, screenH * 0.0365, screenW * 0.1581, screenH * 0.4440, tocolor(0, 0, 0, 255), false)
        selector = dxDrawRectangle (screenW * 0.8279, screenH * 0.0801+32, screenW * 0.1581, screenH * 0.0221, tocolor(255, 0, 0, 255), false)
        dxDrawText("Teste 1", screenW * 0.8360, screenH * 0.0846, screenW * 0.9096, screenH * 0.1055, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Teste 2", screenW * 0.8360, screenH * 0.1185, screenW * 0.9096, screenH * 0.1393, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Teste 3", screenW * 0.8360, screenH * 0.1523, screenW * 0.9096, screenH * 0.1732, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Teste 4", screenW * 0.8360, screenH * 0.1862, screenW * 0.9096, screenH * 0.2070, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
end

function painel2 ()

        dxDrawRectangle(screenW * 0.8279, screenH * 0.0365, screenW * 0.1581, screenH * 0.4440, tocolor(0, 0, 0, 255), false)
        dxDrawText("Teste 5", screenW * 0.8360, screenH * 0.0846, screenW * 0.9096, screenH * 0.1055, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Teste 6", screenW * 0.8360, screenH * 0.1185, screenW * 0.9096, screenH * 0.1393, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Teste 7", screenW * 0.8360, screenH * 0.1523, screenW * 0.9096, screenH * 0.1732, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Teste 8", screenW * 0.8360, screenH * 0.1862, screenW * 0.9096, screenH * 0.2070, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
end

function Abrirpainel ()

if painel == false then
  addEventHandler ( "onClientRender", root, painel1 )
  painel = true
else
    removeEventHandler ( "onClientRender", root, painel1 )
    removeEventHandler ( "onClientRender", root, painel2 )
    painel = false
end
end
bindKey("=", "down", Abrirpainel)

Eu sou muito novo em script com dxGui, e eu queria saber como eu faço uma barra (selector) que ao clicar com as teclas "arrow_u" e "arrow_d", (seta pra cima e seta pra baixo), ela se move para cima e para baixo e se possível, se a barra estiver em uma certa posição, apertar algum botão e ir para o painel2, obrigado

Link to comment
local state = 0

function b()
  if state == 0 then
    addEventHandler("onClientRender", root, panel1)
    elseif state == 1 then
    removeEventHandler("onClientRender", root, panel1)
    addEventHandler("onClientRender", root, panel2)
    elseif state == 2 then
    removeEventHandler("onClientRender", root, panel1)
    removeEventHandler("onClientRender", root, panel2)
    end
  if state > 2 or state < 0 then
    state == 0
    end
  end
addEventHandler("onClientRender", root, b)
    

function onChange(key, press)
  if key == "arrow_d" then
    state = state+1
    elseif key == "arrow_u" then
    state = state-1
    end
  end
addEventHandler("onClientKey", root, onChange)

Not tested but should work. Also next time you make a post in scripting area please type in english. If you want to post this in your native language go to languages section. ?

Edited by Hydra
Link to comment

 

local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1440), (screenH/900)

panel = false


function redbar ()
-- this is supposed to be the red bar ↓
  selector = dxDrawRectangle (screenW * 0.8279, screenH * 0.0801, screenW * 0.1581, screenH * 0.0221, tocolor(255, 0, 0, 255), false)

end

function panel1 ()

        dxDrawRectangle(screenW * 0.8279, screenH * 0.0365, screenW * 0.1581, screenH * 0.4440, tocolor(0, 0, 0, 255), false)
        
        dxDrawText("Test 1", screenW * 0.8360, screenH * 0.0846, screenW * 0.9096, screenH * 0.1055, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Test 2", screenW * 0.8360, screenH * 0.1185, screenW * 0.9096, screenH * 0.1393, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Test 3", screenW * 0.8360, screenH * 0.1523, screenW * 0.9096, screenH * 0.1732, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Test 4", screenW * 0.8360, screenH * 0.1862, screenW * 0.9096, screenH * 0.2070, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
end

function panel2 ()

        dxDrawRectangle(screenW * 0.8279, screenH * 0.0365, screenW * 0.1581, screenH * 0.4440, tocolor(0, 0, 0, 255), false)
        dxDrawText("Test 5", screenW * 0.8360, screenH * 0.0846, screenW * 0.9096, screenH * 0.1055, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Test 6", screenW * 0.8360, screenH * 0.1185, screenW * 0.9096, screenH * 0.1393, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Test 7", screenW * 0.8360, screenH * 0.1523, screenW * 0.9096, screenH * 0.1732, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Test 8", screenW * 0.8360, screenH * 0.1862, screenW * 0.9096, screenH * 0.2070, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
end

function openpanel ()

if panel == false then
  addEventHandler ( "onClientRender", root, panel1 )
  panel = true
else
    removeEventHandler ( "onClientRender", root, panel1 )
    removeEventHandler ( "onClientRender", root, panel2 )
    panel = false
end
end
bindKey("=", "down", openpanel)

local state = 0

function b()
  if state == 0 then -- state 0 == stay on the panel1 and test 1
    addEventHandler("onClientRender", root, Test)
    elseif state == 1 then -- state 1 == stay on the panel1 and test 2 and so it goes

    elseif state == 2 then

    end
  if state > 2 or state < 0 then
    state = 0
    end
  end
addEventHandler("onClientRender", root, b)
    

function onChange(key, press)
  if key == "arrow_d" then
    state = state+1
    elseif key == "arrow_u" then
    state = state-1
    end
  end
addEventHandler("onClientKey", root, onChange)

sorry for the wrong section, it is because i'm new to this forum. the code wasn't working, so i made some changes and until it worked well, but can you tell me how to make a red bar to select the categories?  (i translated the language to english to understand better)

Edited by Genesis_
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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