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