MisterQuestions Posted October 9, 2014 Share Posted October 9, 2014 Hey, how can i create buttons with dxDraw and how to when a players click on it, apply a function? Link to comment
Banex Posted October 10, 2014 Share Posted October 10, 2014 Is this what you're looking for? https://community.multitheftauto.com/in ... ls&id=2136 Link to comment
MisterQuestions Posted October 10, 2014 Author Share Posted October 10, 2014 Mmm...Not like that i mean to create by my own, at now i know i should use the rectangles with onClientClick and getCursorPosition, but how to use those functions? Link to comment
Bonsai Posted October 10, 2014 Share Posted October 10, 2014 Just think about it... A rectangle doesn't react to clicks obviously. So you have to check if that click happened on that reactangle. If thats true, you can handle the click. Link to comment
#RooTs Posted October 10, 2014 Share Posted October 10, 2014 guiCreateLabel Look my panel in DX viewtopic.php?f=108&t=81062 Link to comment
Banex Posted October 10, 2014 Share Posted October 10, 2014 guiCreateLabel Look my panel in DX viewtopic.php?f=108&t=81062 oh, he did not ask how to do GUI @XeroxMTA maybe this will help you https://forum.multitheftauto.com/viewtopic.php?f ... 62#p653562 Link to comment
#RooTs Posted October 10, 2014 Share Posted October 10, 2014 guiCreateLabel Look my panel in DX viewtopic.php?f=108&t=81062 oh, he did not ask how to do GUI @XeroxMTA maybe this will help you https://forum.multitheftauto.com/viewtopic.php?f ... 62#p653562 Puts man, Stop being dumb,study more about DX Panels [ you do not know about DX panels my friend ] Link to comment
#RooTs Posted October 10, 2014 Share Posted October 10, 2014 (edited) use guiCreateLabel -- recognition function to the mouse dxDrawRectangle -- appearance and design dxDrawText -- text the button for create buttons with dxDraw Edited October 10, 2014 by Guest Link to comment
Banex Posted October 10, 2014 Share Posted October 10, 2014 (edited) use guiCreateLabel dxDrawRetangle for create buttons with dxDraw GUI is not DX guy ... Edited October 10, 2014 by Guest Link to comment
Banex Posted October 10, 2014 Share Posted October 10, 2014 @Sr.Zika you put a label on top of the rectangle to the panel? That is not to create a panel in DX ... you just is giving a false appearance to the panel. Since the panel always work with functions in GUI Link to comment
DNL291 Posted October 10, 2014 Share Posted October 10, 2014 XeroxMTA: Use this code and edit it the way you want, don't know if it's without bugs because I haven't tested. local dxButtons = {} local state = false addEventHandler( "onClientResourceStart", resourceRoot, function() dxButtons.acceptX, dxButtons.acceptY = 0, 0 -- dx-button pos dxButtons.acceptW, dxButtons.acceptH = 0, 0 -- dxButtons.cancelX, dxButtons.cancelY = 0, 0 dxButtons.cancelW, dxButtons.cancelH = 0, 0 addEventHandler("onClientClick", root, onClick) end ) addCommandHandler( "togglebuttons", function() _G[ (state and "add" or "remove").."EventHandler" ]( "onClientRender", root, drawDXButtons ) showCursor( state ) state = not state end ) function drawDXButtons() dxDrawRectangle(dxButtons.acceptX, dxButtons.acceptY, dxButtons.acceptW, dxButtons.acceptH, tocolor(0, 0, 0, 190)) dxDrawRectangle(dxButtons.cancelX, dxButtons.cancelY, dxButtons.cancelW, dxButtons.cancelH, tocolor(0, 0, 0, 190)) end addEvent( "onDXButtonClick" ) function onClick(button, state) if (button == "left") and (state == "up") then if isMouseWithinDxButton("accept") then triggerEvent("onDXButtonClick", resourceRoot, "accept") elseif isMouseWithinDxButton("cancel") then triggerEvent("onDXButtonClick", resourceRoot, "cancel") end end end addEventHandler( "onDXButtonClick", root function (buttonName) if buttonName == "accept" then -- elseif buttonName == "cancel" then -- end end ) function isMouseWithinDxButton(dxButtonName) if not dxButtonName then return false end if (dxButtonName == "accept") then return isMouseWithinRangeOf(dxButtons.acceptX, dxButtons.acceptW, dxButtons.acceptY, dxButtons.acceptH) elseif (dxButtonName == "cancel") then return isMouseWithinRangeOf(dxButtons.cancelX, dxButtons.cancelW, dxButtons.cancelY, dxButtons.cancelH) end return false end function isMouseWithinRangeOf(psx,pssx,psy,pssy) if not isCursorShowing() then return false end local cx,cy = getCursorPosition() local screenX, screenY = guiGetScreenSize() cx,cy = cx*screenX,cy*screenY if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then return true end return false end Link to comment
MisterQuestions Posted October 11, 2014 Author Share Posted October 11, 2014 I have made this simple script... Tell me if its ok please addEventHandler("onClientRender", root, function() dxDrawText("ES", 500, 431, 583, 467, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, false, true, false, false) dxDrawText("EN", 593, 431, 676, 467, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, false, true, false, false) end ) sx, sy = getCursorPosition() language = es addEventHandler("onClientClick", getRootElement(), function if sx == 500 and sy == 431 then language = es outputChatBox("El lenguaje del anuncio ahora es: ES (Español)", getRootElement(), 255, 255, 255, true) elseif sx == 593 and sy == 431 then language = en outputChatBox("The language of the announce is now: EN (English) ", getRootElement(), 255, 255, 255, true) end end end Link to comment
Bonsai Posted October 11, 2014 Share Posted October 11, 2014 I have made this simple script...Tell me if its ok please addEventHandler("onClientRender", root, function() dxDrawText("ES", 500, 431, 583, 467, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, false, true, false, false) dxDrawText("EN", 593, 431, 676, 467, tocolor(255, 255, 255, 255), 1.50, "default", "center", "center", false, false, true, false, false) end ) sx, sy = getCursorPosition() language = es addEventHandler("onClientClick", getRootElement(), function if sx == 500 and sy == 431 then language = es outputChatBox("El lenguaje del anuncio ahora es: ES (Español)", getRootElement(), 255, 255, 255, true) elseif sx == 593 and sy == 431 then language = en outputChatBox("The language of the announce is now: EN (English) ", getRootElement(), 255, 255, 255, true) end end end Maybe you should try to understand the basics first before trying something like this. Link to comment
MisterQuestions Posted October 11, 2014 Author Share Posted October 11, 2014 But im triying it please don't kill my hope at least can you say me how to with this rectangle? dxDrawRectangle(500, 431, 83, 36, tocolor(37, 27, 35, 255), false) Link to comment
MisterQuestions Posted October 12, 2014 Author Share Posted October 12, 2014 Somebody please D: 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