ibootleeg Posted February 7, 2014 Posted February 7, 2014 Hello, I've been trying to create, so far I can create, but when I try to use dxGUI what I had created disappears! I can not create a menu using dxGUI if someone can help me I appreciate it! Just what I need is at least how do I create a window with button and memo ! Like this login panel:
Dealman Posted February 7, 2014 Posted February 7, 2014 Because DX Drawings only render for one frame. Thus you need to attach it to either onClientRender or onClientPreRender. Remove the event handler to stop rendering it.
ibootleeg Posted February 7, 2014 Author Posted February 7, 2014 @Dealman, so i need put this on my code ? @KRZO This is my code for tests. Using normal MTA GUI: function createMenuGUI() local xw, xh = guiGetScreenSize() local Width, Height = 473,284 local X = (xw/2) - (Width/2) local Y = (xh/2) - (Height/2) window_test = guiCreateWindow(X, Y, Width, Height, "Test", false) btn_test = guiCreateButton(155, 135, 200, 30, "Test Button", false, window_test) end function openGUI() createMenuGUI() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), openGUI) Result: http://i.imgur.com/111RHhz.png Using dxGUI: function createMenuGUI() local xw, xh = guiGetScreenSize() local Width, Height = 473,284 local X = (xw/2) - (Width/2) local Y = (xh/2) - (Height/2) window_test = exports.dxgui_v1:dxCreateWindow(X, Y, Width, Height, "Test", tocolor(255, 255, 255, 255), "Lighter Black") btn_test = exports.dxgui_v1:dxCreateButton(140, 135, 200, 30, "Test Button", tocolor(255,0,0,255), "default-bold", "Orange", window_test) end function openGUI() createMenuGUI() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), openGUI) Result (nothing): http://i.imgur.com/vH3K4Mq.png
Dealman Posted February 7, 2014 Posted February 7, 2014 For dXGUI change this; addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), openGUI) to this; addEventHandler("onClientRender", getRootElement(), openGUI) onClientResourceStart will only be triggered once. That means your DX GUI will render for one frame. onClientRender is run with every frame so 30-60 times per second.
ibootleeg Posted February 7, 2014 Author Posted February 7, 2014 @Dealman, thank you, it worked but when I create a button to the window, he did not appear, so the button as other things, upon entering the server only window appears. Here is the code: function createMenuGUI() local xw, xh = guiGetScreenSize() local Width, Height = 473,284 local X = (xw/2) - (Width/2) local Y = (xh/2) - (Height/2) window_test = exports.dxgui_v1:dxCreateWindow(X, Y, Width, Height, "Test", tocolor(255, 255, 255, 255), "Lighter Black") btn_test = exports.dxgui_v1:dxCreateButton(10, 50, 200, 50, "Button Test", tocolor(255, 255, 255, 255), "default-bold", "Lighter Black", window_test) end function openGUI() createMenuGUI() root = getRootElement() end addEventHandler("onClientRender", root, openGUI)
Dealman Posted February 7, 2014 Posted February 7, 2014 Any errors or warnings? Also, you don't need to define root as getRootElement, root is already defined as that. You can also use resourceRoot for the resource element.
ibootleeg Posted February 7, 2014 Author Posted February 7, 2014 No have errors, and ok i'will remove "root = getRoot..." thanks ! Now, you don't have any idea for this ?
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