bad skull Posted July 13, 2020 Share Posted July 13, 2020 alguém me fala onde estou errando?, o código funciona para abrir o painel dx lentamente ( efeito de fade ) mais pra fechar não funciona, ele fecha direto e quando vou abrir dnv ja abre com o alpha no maximo, me ajudem :c local screenH, screenW = guiGetScreenSize() local x, y = (screenH/1366), (screenW/768) mostrar = false local alpha = 0 -------------------------------------------- function pdx() if mostrar == true then dxDrawRectangle(x * 300, y*221, x*323, y*248, tocolor(0, 0, 0, alpha), false) if alpha < 230 then alpha = alpha + 4 else alpha >= 230 then alpha = alpha - 4 end end end addEventHandler("onClientRender", root, pdx) function abrirdx() if mostrar == false then showCursor(true) mostrar = true addEventHandler("onClientRender", root,pdx) else showCursor(false) mostrar = false removeEventHandler("onClientRender", root, pdx) end end bindKey("x", "down", abrirdx) Link to comment
Gw8 Posted July 14, 2020 Share Posted July 14, 2020 local screenH, screenW = guiGetScreenSize() local x,y = (screenH/1366),(screenW/768) local effect = { alpha = 0, tick = getTickCount(), state = false } function pdx() local progress = math.min((getTickCount()-effect.tick)/3000,1) if effect.state then effect.alpha = interpolateBetween(effect.alpha,0,0,1,0,0,progress,"Linear") else effect.alpha = interpolateBetween(effect.alpha,0,0,0,0,0,progress,"Linear") if progress >= 0.9 then removeEventHandler("onClientRender",root,pdx) end end dxDrawRectangle(x*300,y*221,x*323,y*248,tocolor(0,0,0,255*effect.alpha)) end function abrirdx() effect.state = not effect.state effect.tick = getTickCount() showCursor(effect.state) if effect.state then removeEventHandler("onClientRender",root,pdx) addEventHandler("onClientRender",root,pdx) end end bindKey("x","down",abrirdx) não testei Link to comment
bad skull Posted July 16, 2020 Author Share Posted July 16, 2020 n entendi a parte do effect.state e do effect.tick me desculpe kkkkkkkkk, agora eu entendi, tava dentro da tabela, srry 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