Jump to content

a simple gui window


Recommended Posts

what i am doing wrong? i cant understand :S

function VentanaAyuda() 
    local ventana = guiCreateWindow (0,0,0.5,0.4,"Ayuda",true) 
    local boton = guiCreateButton (0,0,3,3,"x",true,cerrar) 
    local visibilidad = guiSetVisible (true) 
    local cursor = showCursor(true) 
end 
  
function cerrar() 
    guiSetVisible(cerrar,false) 
    showCursor(false) 
end 
  
addCommandHandler ("ayuda", VentanaAyuda) 
addEventHandler( "onClientGUIClick",boton,cerrar) 

line 14 : bad argument @ 'addEventHandler' [expected element at argument 2,got nil]

Link to comment
function VentanaAyuda() 
     cerrar = guiCreateWindow (0,0,0.5,0.4,"Ayuda",true) 
     boton = guiCreateButton (0,0,3,3,"x",true,cerrar) 
     guiSetVisible(cerrar,true) 
     showCursor(true) 
end 
  
function cerrarx() 
     guiSetVisible(cerrar,false) 
     showCursor(false) 
end 
  
addCommandHandler ("ayuda", VentanaAyuda) 
addEventHandler( "onClientGUIClick",boton,cerrarx) 

Edited by Guest
Link to comment
function VentanaAyuda() 
     cerrar = guiCreateWindow (0,0,0.5,0.4,"Ayuda",true) 
     boton = guiCreateButton (0,0,3,3,"x",true,cerrar) 
     guiSetVisible(cerrar,true) 
     showCursor(true) 
     addEventHandler( "onClientGUIClick",boton,cerrarx, false) 
end 
  
function cerrarx() 
     guiSetVisible(cerrar,false) 
     showCursor(false) 
end 
  
addCommandHandler ("ayuda", VentanaAyuda) 
  

Link to comment

i don't understand why your code is mess like that -_-"

ventana = guiCreateWindow (0,0,0.5,0.4,"Ayuda",true) 
boton = guiCreateButton (0,0,3,3,"x",true,ventana) 
  
addCommandHandler ("ayuda", 
function() 
     guiSetVisible(ventana,true) 
     showCursor(true) 
end) 
  
addEventHandler( "onClientGUIClick",boton, 
function() 
     guiSetVisible(ventana,false) 
     showCursor(false) 
end) 

Link to comment

Alpha dosnt the event must be after the end ?

#sollinoob

function VentanaAyuda() 
     cerrar = guiCreateWindow (0,0,0.5,0.4,"Ayuda",true) 
     boton = guiCreateButton (0,0,3,3,"x",true,cerrar) 
     guiSetVisible(cerrar,true) 
     showCursor(true) 
end 
addCommandHandler ("ayuda", VentanaAyuda) 
  
addEventHandler('onClientGUIClick', root, function () 
if ( source == boton ) then 
guiSetVisible(cerrar,false) 
showCursor(false) 
end 
end) 

Link to comment

It does if it will be executed right after making the function, but in this case, you will first use the command /ayuda, then the GUI will be created.

So there won't be a problem doing this.

Another way of doing this would be:

cerrar = guiCreateWindow (0,0,0.5,0.4,"Ayuda",true) 
boton = guiCreateButton (0,0,3,3,"x",true,cerrar) 
guiSetVisible(cerrar, false) 
  
function VentanaAyuda() 
     guiSetVisible(cerrar,true) 
     showCursor(true) 
end 
 addCommandHandler ("ayuda", VentanaAyuda) 
function cerrarx() 
     guiSetVisible(cerrar,false) 
     showCursor(false) 
end 
 addEventHandler( "onClientGUIClick",boton,cerrarx, false) 
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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