..:D&G:.. Posted November 16, 2013 Share Posted November 16, 2013 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
Desaster Posted November 16, 2013 Share Posted November 16, 2013 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 I hope you understood me Link to comment
..:D&G:.. Posted November 16, 2013 Author Share Posted November 16, 2013 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
xXMADEXx Posted November 17, 2013 Share Posted November 17, 2013 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
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 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
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 Too hard to make, and I just started using DX, I think I will use a button Link to comment
Smart. Posted November 17, 2013 Share Posted November 17, 2013 You could make a button and set it's alpha to 0 to make it invisible, but I'd suggest you to use onClientClick and get the absoluteX and absoluteY and check if they're close to, or the same as the dx one. Link to comment
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 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
Smart. Posted November 17, 2013 Share Posted November 17, 2013 use guiSetVisible(source, false) assuming the source is the button (a button is a gui element so guiSetVisible does work) Link to comment
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 What shoud the ''source'' be for guiSetVisible? As there are dx elemts and not a main gui Link to comment
DiSaMe Posted November 17, 2013 Share Posted November 17, 2013 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
kevenvz Posted November 17, 2013 Share Posted November 17, 2013 What about a using a dx library? Link to comment
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 Ok ok, all u did is to confuse me.. I call them DX elements because there is more then one thing in this (rectangle, text, image, line) And the only thing I need is to hide those DX things. Link to comment
DiSaMe Posted November 17, 2013 Share Posted November 17, 2013 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
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 Well, I knew that already, that they DRAW an image with pixels, but anyway, I used a static image as background and I just set its alpha. Thanks for help anyway! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now