Jump to content

How to create a Dx Panel , Please help me!


MineX server

Recommended Posts

  • Human Resources Staff
Posted

Hi, welcome to the forums!

I've moved your thread to a better section so you can get the answers you're looking for.

Posted

Hello MineX server,

creating a custom UI layout system along with all the required layout math can be frustrating for beginners. By asking this question I am assuming that you have no prior experience with custom UI systems in general. For that reason I recommend you to use the DGS resource. It was created by renowned members ( @xLive and @thisdp) of the MTA community and is based on the dx family of drawing functions. How about you give it a try? ?

  • Like 1
Posted

Ok thanks, now i create a custom window that shows when you press ( i ) :

 

function openwin()
        dxDrawRectangle(510, 217, 368, 349, tocolor(3, 0, 0, 179), false)
        dxDrawRectangle(523, 518, 68, 38, tocolor(201, 12, 12, 254), false)
        dxDrawText("Close", 521, 525, 591, 552, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawRectangle(601, 518, 68, 38, tocolor(40, 36, 36, 180), false)
        dxDrawText("Use", 599, 525, 669, 552, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawRectangle(524, 326, 128, 75, tocolor(201, 12, 12, 254), false)
        dxDrawText("Bottle", 527, 345, 642, 387, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    end

setElementData(localPlayer, "open", false)

function show()
if getElementData(localPlayer, "open") == true then
removeEventHandler("onClientRender", getRootElement(), openwin)
setElementData(localPlayer, "open", false)
showCursor(false)
return
elseif getElementData(localPlayer, "open") == false then
addEventHandler("onClientRender", root, openwin)
showCursor(true)
setElementData(localPlayer, "open", true)
end
end
bindKey("i", "down", show)

 

Now i need how to create a button

Posted (edited)
3 minutes ago, MineX server said:

if you can give me a simple script for it

But what you are trying to do is not a simple task! Try to read the post I mentioned and research onClientClick event handlers.

addEventHandler("onClientClick", root,
    function(button, state, screen_x, screen_y)
        outputChatBox("bla");
    end
);

 

Edited by The_GTA
Posted

In normal gui i can do like this:

 

GUIEditor = {
    button = {},
    window = {}
}
    function GUI()
        GUIEditor.window[1] = guiCreateWindow(599, 297, 163, 121, "Talk Menu", false)
        guiWindowSetSizable(GUIEditor.window[1], false)
guiSetVisible(GUIEditor.window[1], false)
guiSetInputEnabled(false)
        GUIEditor.button[1] = guiCreateButton(9, 25, 144, 43, "Say Hi!", false, GUIEditor.window[1])
        GUIEditor.button[2] = guiCreateButton(9, 72, 144, 39, "Close", false, GUIEditor.window[1])    
    end
    addEventHandler("onClientResourceStart", resourceRoot, GUI)
setElementData(localPlayer, "show", false)    
    
function show()
if getElementData(localPlayer, "show") == false then
    guiSetVisible(GUIEditor.window[1], true)
    guiSetInputEnabled(true)
setElementData(localPlayer, "show", true)
return
elseif getElementData(localPlayer, "show") == true then
    guiSetVisible(GUIEditor.window[1], false)
    guiSetInputEnabled(false)
setElementData(localPlayer, "show", false)
end
end
bindKey("h", "down", show)

function click()
if source == GUIEditor.button[1] then
    outputChatBox("Hi!")
    guiSetVisible(GUIEditor.window[1], false)
    guiSetInputEnabled(false)
elseif source == GUIEditor.button[2] then
    guiSetVisible(GUIEditor.window[1], false)
    guiSetInputEnabled(false)
end
end
addEventHandler("onClientGUIClick", root, click)

 

How i can do like the click function ,choose the button and add a event (on clicked will do command)

But on Dx panel, i can understand if you give me a full script

 

Posted

DX drawing does not result in elements. Instead of drawing things manually I whole-heartedly recommend you to use DGS instead. You have not entirely read my mentioned posts.

I am not supporting this topic anymore.

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