~Funky~ Posted October 27, 2013 Share Posted October 27, 2013 Hola a todos, tengo un problema que al apretar un boton la Puerta se habre pero a volver a apretar ese boton no se me cierra nada :c , que esta malo? Aca los codigos Client : function Puerta_N1() local jugador = getLocalPlayer() if (source == Puerta_1) then triggerServerEvent("PuertaN1",getLocalPlayer()) end end addEventHandler("onClientGUIClick", Puerta_1, Puerta_N1) Server : objeto1 = createObject ( 2990, -2046.80005, -115.3, 38.1, 0, 0 ,90 ) addEvent ("PuertaN1", true) addEventHandler("PuertaN1",root, function () if objeto1 then moveObject(objeto1,6000,-2046.80005, -115.3, 3.1) else moveObject(objeto1,6000,-2046.80005, -115.3, 38.1) end end) Link to comment
Castillo Posted October 27, 2013 Share Posted October 27, 2013 Eso es porque tu 'if' lo unico que hace es verificar si 'objeto1' esta definido, tenes que definir una variable con el estado de la puerta, asi: objeto1 = createObject ( 2990, -2046.80005, -115.3, 38.1, 0, 0 ,90 ) state = false addEvent ( "PuertaN1", true ) addEventHandler ( "PuertaN1", root, function ( ) if ( not state ) then moveObject ( objeto1, 6000, -2046.80005, -115.3, 3.1 ) state = true else moveObject ( objeto1, 6000, -2046.80005, -115.3, 38.1 ) state = false end end ) Link to comment
~Funky~ Posted October 27, 2013 Author Share Posted October 27, 2013 Funciono Muchas gracias solid Link to comment
Recommended Posts