SoiiNoob Posted May 23, 2012 Share Posted May 23, 2012 what i am doing wrong? i cant understand 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
TAPL Posted May 23, 2012 Share Posted May 23, 2012 (edited) 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 May 23, 2012 by Guest Link to comment
SoiiNoob Posted May 23, 2012 Author Share Posted May 23, 2012 I tryed that before but same error line 14 : bad argument @ 'addEventHandler' [expected element at argument 2,got nil] Link to comment
Alpha Posted May 23, 2012 Share Posted May 23, 2012 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
TAPL Posted May 23, 2012 Share Posted May 23, 2012 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
X-SHADOW Posted May 23, 2012 Share Posted May 23, 2012 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
Alpha Posted May 23, 2012 Share Posted May 23, 2012 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
SoiiNoob Posted May 23, 2012 Author Share Posted May 23, 2012 thx, another question, can i make the button smaller than 0.1? because the size 0.1 is really big 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