Jump to content

Linking Dx elements and close them at once


..:D&G:..

Recommended Posts

Hey, is the first time I used Dx draw elements to make a guy, and I need a bit of help. I made a guy which contains dxDrawRectangle, dxDrawText, dxDrawLine and dxDrawImage. How do I conect this elemts together, like a normal GUI, so I can use this dx drawn button:

dxDrawText("X", 879, 442, 900, 466, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 

to close the dx drawn GUI? (all elements at once)

Link to comment
addEventHandler("onClientRender", root, functionname) 

put all your dxElements in a function and open them with that event

removeEventHandler("onClientRender", root, functionname) 

just remove the event to remove the dxElements

to put buttons the eaziest way is to make normal buttons and turn their alpha to 0 then you can use onClientMouseEnter I think to make them some colors :D I hope you understood me :D

Link to comment

Well, this is what I did for now:

addEventHandler("onClientRender", root, 
    function showPlayerStats() 
        dxDrawRectangle(408, 159, 498, 314, tocolor(0, 0, 0, 208), true) 
        dxDrawText("Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Armă: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietății (" .. numproperties .. "): " .. string.sub(properties, 1, string.len(properties)-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " oră/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nSocial Security Numar: ".. finalstring .."", 414, 226, 654, 378, tocolor(255, 255, 255, 255), 1.30, "clear", "left", "top", false, false, true, false, false) 
        dxDrawLine(408, 206, 904, 206, tocolor(255, 255, 255, 255), 2, true) 
        dxDrawText("~-~-~-~-~" .. getPlayerName(thePlayer) .. "~-~-~-~-~", 516, 172, 797, 194, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawImage(730, 252, 118, 107, ":skins/img/000.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
        dxDrawRectangle(876, 444, 28, 27, tocolor(0, 0, 0, 255), true) 
        dxDrawRectangle(875, 443, 28, 27, tocolor(0, 0, 0, 247), true) 
        dxDrawText("X", 879, 442, 900, 466, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
) 

And the button should be this, I think...:

dxDrawRectangle(876, 444, 28, 27, tocolor(0, 0, 0, 255), true) 
        dxDrawRectangle(875, 443, 28, 27, tocolor(0, 0, 0, 247), true) 
        dxDrawText("X", 879, 442, 900, 466, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 

And what should the button be, the text or the rectangle itself? What is the easier way, I don't want to use a button cause I want the gui to be 100% dx drawn

Link to comment
    addEventHandler("onClientRender", root, 
        function  ( ) 
            dxDrawRectangle(408, 159, 498, 314, tocolor(0, 0, 0, 208), true) 
            dxDrawText("Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Armă: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietății (" .. numproperties .. "): " .. string.sub(properties, 1, string.len(properties)-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " oră/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nSocial Security Numar: ".. finalstring .."", 414, 226, 654, 378, tocolor(255, 255, 255, 255), 1.30, "clear", "left", "top", false, false, true, false, false) 
            dxDrawLine(408, 206, 904, 206, tocolor(255, 255, 255, 255), 2, true) 
            dxDrawText("~-~-~-~-~" .. getPlayerName(thePlayer) .. "~-~-~-~-~", 516, 172, 797, 194, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, true, false, false) 
            dxDrawImage(730, 252, 118, 107, ":skins/img/000.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
            dxDrawRectangle(876, 444, 28, 27, tocolor(0, 0, 0, 255), true) 
            dxDrawRectangle(875, 443, 28, 27, tocolor(0, 0, 0, 247), true) 
            dxDrawText("X", 879, 442, 900, 466, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 
        end 
    ) 

To make a button, you'll need to make one (Maybe with dxDrawText & dxDrawRectangle) and then when the client clicks, check to see if the cursor is inside the coordinates.

Link to comment

Well this should be my button:

     dxDrawRectangle(876, 444, 28, 27, tocolor(0, 0, 0, 255), true) 
            dxDrawText("X", 879, 442, 900, 466, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, true, false, false) 

But how do I make it a button, what fuctions do I need to use? God, I didn't know how hard it is to make just a small simple button in dx :(

Link to comment

I will try with the button. I use this code to close the button, but I can't use guiSetVisible as the is no gui...

  
addEventHandler("onClientGUIClick", root, 
    function() 
        if ( source == dxGui.button[1] ) then 
        --guiSetVisible(  , false) 
        showCursor(false) 
    end 
end 
) 

------------------------EDITED------------------------

This is what I did till now:

dxGui = { 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        dxGui.button[1] = guiCreateButton(874, 446, 26, 25, "X", false) 
        guiSetAlpha(dxGui.button[1], 0.42) 
        guiSetFont(dxGui.button[1], "default-bold-small") 
        guiSetProperty(dxGui.button[1], "NormalTextColour", "FFFFFFFF")     
    end 
) 
  
addEventHandler("onClientRender", root, 
    function() 
        dxDrawRectangle(407, 161, 498, 314, tocolor(0, 0, 0, 208), false) 
        dxDrawText("Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Armă: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietății (" .. numproperties .. "): " .. string.sub(properties, 1, string.len(properties)-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " oră/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nSocial Security Numar: ".. finalstring .."\n\n\n                Nume: " .. getPlayerName(thePlayer) .. "", 414, 226, 654, 378, tocolor(255, 255, 255, 255), 1.30, "clear", "left", "top", false, false, true, false, false) 
        dxDrawLine(408, 206, 904, 206, tocolor(255, 255, 255, 255), 2, true) 
        dxDrawText("~-~-~-~-~" .. getPlayerName(thePlayer) .. "~-~-~-~-~", 525, 172, 806, 194, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, true, false, false) 
        dxDrawImage(416, 386, 86, 78, ":skins/img/000.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
    end 
) 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if ( source == dxGui.button[1] ) then 
        --guiSetVisible(  , false) 
        showCursor(false) 
    end 
end 
) 

Link to comment

There are no DX elements. Such things like "DX elements" do not exist. Therefore they can't be created/destroyed/moved/hidden/linked/whatever. DX drawing functions do exactly what their names say: they draw, that means, the function call changes the colors of some pixels. This change is visible for one frame because all pixels on the screen are cleared, so whatever the function drew is already gone the next frame.

Link to comment

I didn't confuse you in the first place. Your mind confused you because it tricked you into believing you see DX rectangles, text, images and lines. What you see is actually lots of pixels with various colors on the screen. When DX drawing function is called, colors of some pixels are changed and your mind interprets these combinations of colors as distinct elements, while in MTA, nothing is created. So if you don't want DX drawings to be visible, simply don't draw them when they shouldn't be visible.

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