Kronos Posted July 1, 2013 Posted July 1, 2013 Hola, tanto tiempo , he creado un window de prueba y no se que falla que no se cierra y me tira este error: expected element at argument 2, got nil Aca esta addEventHandler( "onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(346, 205, 369, 401, "Window prueba", false) guiWindowSetSizable(Window, false) close = guiCreateButton(74, 344, 221, 47, "Close", false, Window) end ) addEventHandler( "onClientGUIClick", close, closeWindow, true ) function main( ) showCursor(true) end addEventHandler ( "onClientResourceStart", getRootElement(), main ) function closeWindow() showCursor(false) guiSetVisible(Window, false) guiSetVisible(close, false) end
Renkon Posted July 1, 2013 Posted July 1, 2013 Prueba escribiendo primero y principal del archivo la función close window, así queda arriba del event handler
~ProtoN! Posted July 1, 2013 Posted July 1, 2013 El Problema es que el evento "onClientGUIClick" tiene que estar dentro de la funcion donde se crean los elementos GUI asi: addEventHandler( "onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(346, 205, 369, 401, "Window prueba", false) guiWindowSetSizable(Window, false) close = guiCreateButton(74, 344, 221, 47, "Close", false, Window) addEventHandler( "onClientGUIClick", close, closeWindow, true) end ) function main( ) showCursor(true) end addEventHandler ( "onClientResourceStart", getRootElement(), main ) function closeWindow() showCursor(false) guiSetVisible(Window, false) guiSetVisible(close, false) end pero seria mejor hacer que lo elementos GUI no se inicien por ninguna funcion ni evento algo asi: --Elementos GUI.-------------- Window = guiCreateWindow(346, 205, 369, 401, "Window prueba", false) guiWindowSetSizable(Window, false) close = guiCreateButton(74, 344, 221, 47, "Close", false, Window) showCursor(true) ------------------------------ function closeWindow() showCursor(false) guiSetVisible(Window, false) guiSetVisible(close, false) end addEventHandler( "onClientGUIClick", close, closeWindow, true)
Kronos Posted July 1, 2013 Author Posted July 1, 2013 El Problema es que el evento "onClientGUIClick" tiene que estar dentro de la funcion donde se crean los elementos GUIasi: addEventHandler( "onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(346, 205, 369, 401, "Window prueba", false) guiWindowSetSizable(Window, false) close = guiCreateButton(74, 344, 221, 47, "Close", false, Window) addEventHandler( "onClientGUIClick", close, closeWindow, true) end ) function main( ) showCursor(true) end addEventHandler ( "onClientResourceStart", getRootElement(), main ) function closeWindow() showCursor(false) guiSetVisible(Window, false) guiSetVisible(close, false) end pero seria mejor hacer que lo elementos GUI no se inicien por ninguna funcion ni evento algo asi: --Elementos GUI.-------------- Window = guiCreateWindow(346, 205, 369, 401, "Window prueba", false) guiWindowSetSizable(Window, false) close = guiCreateButton(74, 344, 221, 47, "Close", false, Window) showCursor(true) ------------------------------ function closeWindow() showCursor(false) guiSetVisible(Window, false) guiSetVisible(close, false) end addEventHandler( "onClientGUIClick", close, closeWindow, true) Muchas gracias me funciono, sobre eso del script de hacerlo sin que se inicie lo tengo planeado hacerlo asi pero para no escribir ni apretar nada lo empieso asi
Recommended Posts