GabrielBas Posted May 22, 2017 Posted May 22, 2017 Estoy ingresando al area de la programación Lua y no tengo muchos conocimientos, igual, intenté algo, viendo tutoriales y demás logré llegar a este codigo para que al entrar al servidor, seleccione un equipo de las tres imagenes. Todo bien, hasta que al hacerle click a la imagen, no pasa nada, ¿que creen que esté mal?. Gracias de ante mano. function chooseG() background = guiCreateStaticImage(0, 0, 1, 1, "imagenes/background.png", true) soldado = guiCreateStaticImage(0.1, 0.100, 0.4, 0.6, "imagenes/infames.png", true) civil = guiCreateStaticImage(0.4, 0.100, 0.4, 0.6, "imagenes/insurgentes.png", true) bandido = guiCreateStaticImage(0.7, 0.100, 0.4, 0.6, "imagenes/imparciales.png", true) showCursor(true) addEventHandler("onClientGUIClick", civil, playerChosen) end function playerChosen() local date, time = getTheTime() if(source==soldado)then setGroup(localPlayer, "INFAMES", date, "Infame") setElementPosition ( localplayer, 0, 0, 0 ) elseif(source==civil)then setGroup(localPlayer, "INSURGENTES", date, "Insurgente") setElementPosition ( localplayer, 0, 0, 0 ) elseif(source==bandido)then setGroup(localPlayer, "IMPARCIALES", date, "Imparcial") setElementPosition ( localplayer, 0, 0, 0 ) end destroyElement(background) showCursor(false) end addEvent("equipo",true) addEventHandler("equipo",root,chooseG)
Rose Posted May 22, 2017 Posted May 22, 2017 function chooseG() background = guiCreateStaticImage(0, 0, 1, 1, "imagenes/background.png", true) soldado = guiCreateStaticImage(0.1, 0.100, 0.4, 0.6, "imagenes/infames.png", true) civil = guiCreateStaticImage(0.4, 0.100, 0.4, 0.6, "imagenes/insurgentes.png", true) bandido = guiCreateStaticImage(0.7, 0.100, 0.4, 0.6, "imagenes/imparciales.png", true) showCursor(true) end addEvent("equipo",true) addEventHandler("equipo",root,chooseG) function playerChosen() local date, time = getTheTime() if(source==soldado)then setGroup(localPlayer, "INFAMES", date, "Infame") setElementPosition ( localPlayer, 0, 0, 0 ) elseif(source==civil)then setGroup(localPlayer, "INSURGENTES", date, "Insurgente") setElementPosition ( localPlayer, 0, 0, 0 ) elseif(source==bandido)then setGroup(localPlayer, "IMPARCIALES", date, "Imparcial") setElementPosition ( localPlayer, 0, 0, 0 ) end destroyElement(background) showCursor(false) end addEventHandler("onClientGUIClick", root, playerChosen)
GabrielBas Posted May 22, 2017 Author Posted May 22, 2017 Realicé las sugerencias que me realizaste pero continúa igual, al hacer click en una de las tres imágenes, no pasa nada y continúan las imágenes.
Rose Posted May 22, 2017 Posted May 22, 2017 Muestra como lo tienes, yo lo probé así pero con botones(me da flojera buscar imágenes) y funciona bien
GabrielBas Posted May 23, 2017 Author Posted May 23, 2017 (edited) function chooseG() background = guiCreateStaticImage(0, 0, 1, 1, "imagenes/background.png", true) soldado = guiCreateStaticImage(-0.10, 0.100, 0.5, 0.6, "imagenes/infames.png", true) civil = guiCreateStaticImage(0.25, 0.100, 0.5, 0.6, "imagenes/insurgentes.png", true) bandido = guiCreateStaticImage(0.55, 0.100, 0.5, 0.6, "imagenes/imparciales.png", true) showCursor(true) end addEvent("equipo",true) addEventHandler("equipo",root,chooseG) function playerChosen() local date, time = getTheTime() if(source==soldado)then setElementPosition ( localplayer, 0, 0, 0 ) elseif(source==civil)then setElementPosition ( localplayer, 0, 0, 0 ) elseif(source==bandido)then setElementPosition ( localplayer, 0, 0, 0 ) end destroyElement(background) showCursor(false) end addEventHandler("onClientGUIClick", root, playerChosen) addCommandHandler ( "prueba", chooseG ) Así, ¿qué crees que me falla?, gracias desde ya por la ayuda. Es ese lua más su correspondiente meta.xml. Edited May 23, 2017 by GabrielBas
Rose Posted May 23, 2017 Posted May 23, 2017 @GabrielBas es localPlayer, no localplayer(pudiese ser localplayer si defines qué es, pero localPlayer ya devuelve al jugador local...)
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