Jump to content

No se cierra el GUI ayuda porfavor


Kronos

Recommended Posts

Hola, tanto tiempo xD, 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 
  

Link to comment

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)   
  

Link to comment
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)   
  

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

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...