DeathMta Posted October 16, 2015 Share Posted October 16, 2015 BUENAS ANDO CREANDO UNA GUI DE UN PANEL Y QUIERO QUE UN BOTON SE ELIMINE POR 4 MINUTOS Y VUELVA A APARECER trato de integrar esto a mi boton function guiFade( gui, state ) if state == "in" then -- This state will fade IN the GUI fadeIn = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it lower the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha - 0.1) -- We set the GUI's actual alpha after each loop if alpha == 0 then -- If the loop reached "0"... guiSetVisible(gui, false) -- We set the GUI visibility to 0 so it won't be clickable or editable killTimer(fadeIn) -- ... We kill the timer fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil end elseif state == "out" then -- This state will fade OUT the GUI guiSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" fadeOut = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it higher the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha + 0.1) -- We set the GUI's actual alpha after each loop if alpha == 1 then -- If the loop reached "1"... killTimer(fadeOut) -- ... We kill the timer fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil end end end a este boton : function FuncionMuniciones () showCursor (true) playSound("sonidos/sonidobronce.wav") triggerServerEvent ( "CuandoCliqueaMuniciones", getLocalPlayer()) end Link to comment
Calculador Posted October 16, 2015 Share Posted October 16, 2015 BUENAS ANDO CREANDO UNA GUI DE UN PANEL Y QUIERO QUE UN BOTON SE ELIMINE POR 4 MINUTOS Y VUELVA A APARECERtrato de integrar esto a mi boton function guiFade( gui, state ) if state == "in" then -- This state will fade IN the GUI fadeIn = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it lower the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha - 0.1) -- We set the GUI's actual alpha after each loop if alpha == 0 then -- If the loop reached "0"... guiSetVisible(gui, false) -- We set the GUI visibility to 0 so it won't be clickable or editable killTimer(fadeIn) -- ... We kill the timer fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil end elseif state == "out" then -- This state will fade OUT the GUI guiSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" fadeOut = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it higher the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha + 0.1) -- We set the GUI's actual alpha after each loop if alpha == 1 then -- If the loop reached "1"... killTimer(fadeOut) -- ... We kill the timer fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil end end end a este boton : function FuncionMuniciones () showCursor (true) playSound("sonidos/sonidobronce.wav") triggerServerEvent ( "CuandoCliqueaMuniciones", getLocalPlayer()) end La función perfecta para lo que quieres es: guiSetEnabled Link to comment
DeathMta Posted October 16, 2015 Author Share Posted October 16, 2015 claro lo use pero al reabrir mi panel el guisetenable no funciona Link to comment
Kilfwan Posted October 16, 2015 Share Posted October 16, 2015 Creo que asi seria no he probado lol. timesito = 4 totals = timesito * 60000 function FuncionMuniciones () showCursor (true) playSound("sonidos/sonidobronce.wav") triggerServerEvent ( "CuandoCliqueaMuniciones", getLocalPlayer()) guiSetEnabled(boton, false) setTimer(function() guiSetEnabled(boton, true) end, totals, 1 ) end Link to comment
DeathMta Posted October 16, 2015 Author Share Posted October 16, 2015 eso esta bien pero quiere que cuente el tiempo cuando cierra el panel osea mira algo asi: presiona el boton , luego lo cierra , aunque este abierto o no que pase el tiempo . Link to comment
UserToDelete Posted October 16, 2015 Share Posted October 16, 2015 eso esta bien pero quiere que cuente el tiempo cuando cierra el panel osea mira algo asi:presiona el boton , luego lo cierra , aunque este abierto o no que pase el tiempo . No entendi lo que quisite decir exactamente, podrias aclararlo un poco mas? Link to comment
DeathMta Posted October 17, 2015 Author Share Posted October 17, 2015 osea mas claro : uno usuario "x" abre un panel "x", al presionar un boton , se destruya y pase un tiempo y se cree de nuevo el boton. use el guisetenable , pero lo bloquea cuando el panel esta abierto , y al usar un settimer con el guisetenable , cuenta el tiempo cuando el panel esta abierto mas no cerrado no se si me dejo entender Link to comment
DeathMta Posted October 17, 2015 Author Share Posted October 17, 2015 function guiFade( gui, state ) if state == "in" then -- This state will fade IN the GUI fadeIn = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it lower the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha - 0.1) -- We set the GUI's actual alpha after each loop if alpha == 0 then -- If the loop reached "0"... guiSetVisible(gui, false) -- We set the GUI visibility to 0 so it won't be clickable or editable killTimer(fadeIn) -- ... We kill the timer fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil end elseif state == "out" then -- This state will fade OUT the GUI guiSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" fadeOut = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it higher the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha + 0.1) -- We set the GUI's actual alpha after each loop if alpha == 1 then -- If the loop reached "1"... killTimer(fadeOut) -- ... We kill the timer fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil end end end trato de integrar esa funcion a mi boton ya que en la wiki mta https://wiki.multitheftauto.com/wiki/GuiGetAlpha ese es el link esa funcion dice que a un boton "x" lo destruye por un determinado tiempo Link to comment
Kilfwan Posted October 17, 2015 Share Posted October 17, 2015 Creo para que transcurra un tiempo como tu quieres deberías usar getTickCount O si no usa un timer, que seria mas facil. Link to comment
UserToDelete Posted October 17, 2015 Share Posted October 17, 2015 Prueba esto, si mal no entendi el problema es que al cerrar el panel se recrea el boton al 100%, la cosa es, que debes usar guiSetVisible(element, false) para la ventana, y no destroyElement(element) [en este caso] function guiFade( gui, state ) if not isElement(gui) then error("'gui' is not an element") return end if state == "in" then -- This state will fade IN the GUI fadeIn = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it lower the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha - 0.1) -- We set the GUI's actual alpha after each loop if alpha == 0 then -- If the loop reached "0"... guiSetVisible(gui, false) -- We set the GUI visibility to 0 so it won't be clickable or editable killTimer(fadeIn) -- ... We kill the timer fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil end elseif state == "out" then -- This state will fade OUT the GUI guiSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" guiSetEnabled(gui, false) fadeOut = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it higher the alpha each 50 ms alpha = guiGetAlpha(gui) -- We get the GUI's actual alpha after each loop guiSetAlpha(gui, alpha + 0.1) -- We set the GUI's actual alpha after each loop if alpha == 1 then -- If the loop reached "1"... killTimer(fadeOut) -- ... We kill the timer guiSetEnabled(gui, true) fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil end end end Link to comment
DeathMta Posted October 17, 2015 Author Share Posted October 17, 2015 osea esa funcion a mi boton le pongo asi?: function FuncionOtros () guiFade() showCursor (true) playSound("sonidos/sonidobronce.wav") triggerServerEvent ( "CuandoCliqueaOtros", getLocalPlayer()) end Link to comment
Enargy, Posted October 17, 2015 Share Posted October 17, 2015 guiFade( element gui, string state ) Link to comment
DeathMta Posted October 17, 2015 Author Share Posted October 17, 2015 Sigue lo mismo :c Link to comment
Kilfwan Posted October 17, 2015 Share Posted October 17, 2015 guiFade( ventana, "out" ) Creo que deberías leer mas. Link to comment
DeathMta Posted October 18, 2015 Author Share Posted October 18, 2015 lo hice , pero da lo mismo :v Link to comment
Recommended Posts