Jump to content

dx panel


Recommended Posts

Hello guys,

I got a problem i made a panel with dx but I can't make it open with the command /panel. Theres also no errors at debug.

Heres the code.

basis = dxDrawRectangle(491, 297, 497, 263, tocolor(23, 23, 23, 255), true) 
dxDrawRectangle(481, 279, 517, 28, tocolor(55, 55, 55, 255), true) 
dxDrawText("Player", 487, 350, 622, 383, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Weapon", 487, 383, 622, 416, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Vehicle", 487, 416, 622, 449, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Home", 487, 317, 622, 350, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("X", 968, 279, 998, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
dxDrawText("X", 481, 279, 511, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
dxDrawText("Hello,", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
dxDrawText("Binds", 487, 482, 622, 515, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
home = guiCreateButton(487, 317, 135, 33, "", false) 
guiSetAlpha(home, 0.00) 
vehicle = guiCreateButton(487, 416, 135, 33, "", false) 
guiSetAlpha(vehicle, 0.00) 
weapon = guiCreateButton(487, 383, 135, 33, "", false) 
guiSetAlpha(weapon, 0.00) 
player = guiCreateButton(487, 350, 135, 33, "", false) 
guiSetAlpha(player, 0.00) 
binds = guiCreateButton(487, 482, 135, 33, "", false) 
guiSetAlpha(binds, 0.00) 
guiSetVisible ( basis, false ) 
  
  
function open() 
    if ( guiGetVisible ( basis ) == true ) then 
        guiSetVisible ( basis, false ) 
        showCursor(false) 
    else then 
        guiSetVisible ( basis, true ) 
        showCursor(true) 
    end 
end 
addCommandHandler ("anony", open) 
  

Link to comment

Thanks, it opens now but I want it to open when I type /panel how do i fix that

What I've changed

function draw() 
basis = dxDrawRectangle(491, 297, 497, 263, tocolor(23, 23, 23, 255), true) 
dxDrawRectangle(481, 279, 517, 28, tocolor(55, 55, 55, 255), true) 
dxDrawText("Player", 487, 350, 622, 383, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Weapon", 487, 383, 622, 416, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Vehicle", 487, 416, 622, 449, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Home", 487, 317, 622, 350, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("X", 968, 279, 998, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
dxDrawText("X", 481, 279, 511, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
dxDrawText("Hello,", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
dxDrawText("Binds", 487, 482, 622, 515, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
home = guiCreateButton(487, 317, 135, 33, "", false) 
guiSetAlpha(home, 0.00) 
vehicle = guiCreateButton(487, 416, 135, 33, "", false) 
guiSetAlpha(vehicle, 0.00) 
weapon = guiCreateButton(487, 383, 135, 33, "", false) 
guiSetAlpha(weapon, 0.00) 
player = guiCreateButton(487, 350, 135, 33, "", false) 
guiSetAlpha(player, 0.00) 
binds = guiCreateButton(487, 482, 135, 33, "", false) 
guiSetAlpha(binds, 0.00) 
guiSetVisible ( basis, false ) 
showcursor (true) 
end 
addEventHandler("onClientRender",root,draw) 
  

Link to comment
local drawingPanel = false; 
  
function startDrawing_CMD() 
    if(drawingPanel == false) then 
        addEventHandler("onClientPreRender", getRootElement(), draw); 
        drawingPanel = true; 
    else 
        removeEventHandler("onClientPreRender", getRootElement(), draw); 
        drawingPanel = false; 
    end 
end 
addCommandHandler("Panel", startDrawing_CMD, false, false); 

Edit:

Remember to delete the event handler attached to the function draw as well.

Edited by Guest
Link to comment
local drawingPanel = false; 
  
function startDrawing_CMD() 
    if(drawingPanel == false) then 
        addEventHandler("onClientPreRender", getRootElement(), draw); 
        drawingPanel = true; 
    else 
        removeEventHandler("onClientPreRender", getRootElement(), draw); 
        drawingPanel = false; 
    end 
end 
addCommandHandler("Panel", startDrawing_CMD, false, false); 

thanks mate it worked;)

Link to comment
Thanks, it opens now but I want it to open when I type /panel how do i fix that

What I've changed

function draw() 
basis = dxDrawRectangle(491, 297, 497, 263, tocolor(23, 23, 23, 255), true) 
dxDrawRectangle(481, 279, 517, 28, tocolor(55, 55, 55, 255), true) 
dxDrawText("Player", 487, 350, 622, 383, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Weapon", 487, 383, 622, 416, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Vehicle", 487, 416, 622, 449, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("Home", 487, 317, 622, 350, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
dxDrawText("X", 968, 279, 998, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
dxDrawText("X", 481, 279, 511, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
dxDrawText("Hello,", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
dxDrawText("Binds", 487, 482, 622, 515, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
home = guiCreateButton(487, 317, 135, 33, "", false) 
guiSetAlpha(home, 0.00) 
vehicle = guiCreateButton(487, 416, 135, 33, "", false) 
guiSetAlpha(vehicle, 0.00) 
weapon = guiCreateButton(487, 383, 135, 33, "", false) 
guiSetAlpha(weapon, 0.00) 
player = guiCreateButton(487, 350, 135, 33, "", false) 
guiSetAlpha(player, 0.00) 
binds = guiCreateButton(487, 482, 135, 33, "", false) 
guiSetAlpha(binds, 0.00) 
guiSetVisible ( basis, false ) 
showcursor (true) 
end 
addEventHandler("onClientRender",root,draw) 
  

You're code is really,really inefficient, because it's creating GUI elements every render.

home = guiCreateButton(487, 317, 135, 33, "", false) 
guiSetAlpha(home, 0.00) 
vehicle = guiCreateButton(487, 416, 135, 33, "", false) 
guiSetAlpha(vehicle, 0.00) 
weapon = guiCreateButton(487, 383, 135, 33, "", false) 
guiSetAlpha(weapon, 0.00) 
player = guiCreateButton(487, 350, 135, 33, "", false) 
guiSetAlpha(player, 0.00) 
binds = guiCreateButton(487, 482, 135, 33, "", false) 
guiSetAlpha(binds, 0.00) 
showcursor (true) 
  
function draw() 
    xDrawRectangle(491, 297, 497, 263, tocolor(23, 23, 23, 255), true) 
    dxDrawRectangle(481, 279, 517, 28, tocolor(55, 55, 55, 255), true) 
    dxDrawText("Player", 487, 350, 622, 383, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Weapon", 487, 383, 622, 416, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Vehicle", 487, 416, 622, 449, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Home", 487, 317, 622, 350, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("X", 968, 279, 998, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
    dxDrawText("X", 481, 279, 511, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
    dxDrawText("Hello,", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
    dxDrawText("Binds", 487, 482, 622, 515, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
end 
  
  
local drawingPanel = false; 
function startDrawing_CMD() 
    if(drawingPanel == false) then 
        addEventHandler("onClientPreRender", getRootElement(), draw); 
        drawingPanel = true; 
    else 
        removeEventHandler("onClientPreRender", getRootElement(), draw); 
        drawingPanel = false; 
    end 
end 
addCommandHandler("Panel", startDrawing_CMD, false, false); 

Link to comment
  • Moderators

Try this (fill the function at the top to draw the right part of your panel:

function drawHomeDetails() 
    -- draw 
    dxDrawText("This is the home detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawPlayerDetails() 
    -- draw 
    dxDrawText("This is the player detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawWeaponDetails() 
    -- draw 
    dxDrawText("This is the weapon detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawVehicleDetails() 
    -- draw 
    dxDrawText("This is the vehicle detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawBindsDetails() 
    -- draw 
    dxDrawText("This is the binds detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
local panel = { 
    btn = {}, 
    detailFunction = drawHomeDetails 
} 
  
function drawPanel() 
    dxDrawRectangle(491, 297, 497, 263, tocolor(23, 23, 23, 255), true) 
    dxDrawRectangle(481, 279, 517, 28, tocolor(55, 55, 55, 255), true) 
    dxDrawText("Player", 487, 350, 622, 383, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Weapon", 487, 383, 622, 416, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Vehicle", 487, 416, 622, 449, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Home", 487, 317, 622, 350, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("X", 968, 279, 998, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
    dxDrawText("X", 481, 279, 511, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
    dxDrawText("Binds", 487, 482, 622, 515, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
     
    if detailFunction and type(detailFunction) == "function" then 
        detailFunction() -- draw the right part the panel 
    end 
end 
  
function onPanelHomeButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawHomeDetails 
end 
  
function onPanelPlayerButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawPlayerDetails 
end 
  
function onPanelWeaponButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawWeaponDetails 
end 
  
function onPanelVehicleButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawVehicleDetails 
end 
  
function onPanelBindsButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawBindsDetails 
end 
  
panel.btn.home = guiCreateButton(487, 317, 135, 33, "", false) 
guiSetAlpha(panel.btn.home, 0) 
guiSetVisible(panel.btn.home, false) 
addEventHandler("onClientGUIClick", panel.btn.home, onPanelHomeButtonClicked, false) 
panel.btn.vehicle = guiCreateButton(487, 416, 135, 33, "", false) 
guiSetAlpha(panel.btn.vehicle, 0) 
guiSetVisible(panel.btn.vehicle, false) 
addEventHandler("onClientGUIClick", panel.btn.vehicle, onPanelVehicleButtonClicked, false) 
panel.btn.weapon = guiCreateButton(487, 383, 135, 33, "", false) 
guiSetAlpha(panel.btn.weapon, 0) 
guiSetVisible(panel.btn.weapon, false) 
addEventHandler("onClientGUIClick", panel.btn.weapon, onPanelWeaponButtonClicked, false) 
panel.btn.player = guiCreateButton(487, 350, 135, 33, "", false) 
guiSetAlpha(panel.btn.player, 0) 
guiSetVisible(panel.btn.player, false) 
addEventHandler("onClientGUIClick", panel.btn.player, onPanelPlayerButtonClicked, false) 
panel.btn.binds = guiCreateButton(487, 482, 135, 33, "", false) 
guiSetAlpha(panel.btn.binds, 0) 
guiSetVisible(panel.btn.binds, false) 
addEventHandler("onClientGUIClick", panel.btn.binds, onPanelBindsButtonClicked, false) 
  
local drawingPanel = false 
function togglePanel() 
    if not drawingPanel then 
        showPanel() 
        drawingPanel = true 
    else 
        hidePanel() 
        drawingPanel = false 
    end 
end 
addCommandHandler("panel", togglePanel, false, false) 
  
function guiPanelBtnSetVisible( bool ) 
    guiSetVisible(panel.btn.home, bool) 
    guiSetVisible(panel.btn.player, bool) 
    guiSetVisible(panel.btn.weapon, bool) 
    guiSetVisible(panel.btn.vehicle, bool) 
    guiSetVisible(panel.btn.binds, bool) 
end 
  
function showPanel() 
    addEventHandler("onClientPreRender", root, drawPanel) 
    showCursor(true) 
    guiPanelBtnSetVisible(true) 
end 
  
function hidePanel() 
    removeEventHandler("onClientPreRender", root, drawPanel) 
    showCursor(false) 
    guiPanelBtnSetVisible(false) 
end 

Link to comment
Try this (fill the function at the top to draw the right part of your panel:
function drawHomeDetails() 
    -- draw 
    dxDrawText("This is the home detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawPlayerDetails() 
    -- draw 
    dxDrawText("This is the player detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawWeaponDetails() 
    -- draw 
    dxDrawText("This is the weapon detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawVehicleDetails() 
    -- draw 
    dxDrawText("This is the vehicle detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
function drawBindsDetails() 
    -- draw 
    dxDrawText("This is the binds detail content.", 660, 317, 887, 405, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
end 
  
local panel = { 
    btn = {}, 
    detailFunction = drawHomeDetails 
} 
  
function drawPanel() 
    dxDrawRectangle(491, 297, 497, 263, tocolor(23, 23, 23, 255), true) 
    dxDrawRectangle(481, 279, 517, 28, tocolor(55, 55, 55, 255), true) 
    dxDrawText("Player", 487, 350, 622, 383, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Weapon", 487, 383, 622, 416, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Vehicle", 487, 416, 622, 449, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("Home", 487, 317, 622, 350, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
    dxDrawText("X", 968, 279, 998, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
    dxDrawText("X", 481, 279, 511, 305, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "top", false, false, true, false, false) 
    dxDrawText("Binds", 487, 482, 622, 515, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "top", false, false, true, false, false) 
     
    if detailFunction and type(detailFunction) == "function" then 
        detailFunction() -- draw the right part the panel 
    end 
end 
  
function onPanelHomeButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawHomeDetails 
end 
  
function onPanelPlayerButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawPlayerDetails 
end 
  
function onPanelWeaponButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawWeaponDetails 
end 
  
function onPanelVehicleButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawVehicleDetails 
end 
  
function onPanelBindsButtonClicked( btn, state ) 
    if btn ~= "left" or state ~= "up" then return end 
    -- do some extra stuff if needed 
    detailFunction = drawBindsDetails 
end 
  
panel.btn.home = guiCreateButton(487, 317, 135, 33, "", false) 
guiSetAlpha(panel.btn.home, 0) 
guiSetVisible(panel.btn.home, false) 
addEventHandler("onClientGUIClick", panel.btn.home, onPanelHomeButtonClicked, false) 
panel.btn.vehicle = guiCreateButton(487, 416, 135, 33, "", false) 
guiSetAlpha(panel.btn.vehicle, 0) 
guiSetVisible(panel.btn.vehicle, false) 
addEventHandler("onClientGUIClick", panel.btn.vehicle, onPanelVehicleButtonClicked, false) 
panel.btn.weapon = guiCreateButton(487, 383, 135, 33, "", false) 
guiSetAlpha(panel.btn.weapon, 0) 
guiSetVisible(panel.btn.weapon, false) 
addEventHandler("onClientGUIClick", panel.btn.weapon, onPanelWeaponButtonClicked, false) 
panel.btn.player = guiCreateButton(487, 350, 135, 33, "", false) 
guiSetAlpha(panel.btn.player, 0) 
guiSetVisible(panel.btn.player, false) 
addEventHandler("onClientGUIClick", panel.btn.player, onPanelPlayerButtonClicked, false) 
panel.btn.binds = guiCreateButton(487, 482, 135, 33, "", false) 
guiSetAlpha(panel.btn.binds, 0) 
guiSetVisible(panel.btn.binds, false) 
addEventHandler("onClientGUIClick", panel.btn.binds, onPanelBindsButtonClicked, false) 
  
local drawingPanel = false 
function togglePanel() 
    if not drawingPanel then 
        showPanel() 
        drawingPanel = true 
    else 
        hidePanel() 
        drawingPanel = false 
    end 
end 
addCommandHandler("panel", togglePanel, false, false) 
  
function guiPanelBtnSetVisible( bool ) 
    guiSetVisible(panel.btn.home, bool) 
    guiSetVisible(panel.btn.player, bool) 
    guiSetVisible(panel.btn.weapon, bool) 
    guiSetVisible(panel.btn.vehicle, bool) 
    guiSetVisible(panel.btn.binds, bool) 
end 
  
function showPanel() 
    addEventHandler("onClientPreRender", root, drawPanel) 
    showCursor(true) 
    guiPanelBtnSetVisible(true) 
end 
  
function hidePanel() 
    removeEventHandler("onClientPreRender", root, drawPanel) 
    showCursor(false) 
    guiPanelBtnSetVisible(false) 
end 

Thanks it worked,

And how do I set that the homescreen opens directly when you type /panel and not a blank screen?

Link to comment

God damn does this look even a LITTLE bit like that one, dude get some glasses please.

If this is the same like that one seriously you got no brain then.

Sorry for my behaviour

Mine:

2rpfozt.png

Your:

jkvg91.jpg

EDIT:

Im not gonna even use any "ON" and "OFF" command. So it's completely different lol.

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