Karuzo Posted February 28, 2014 Share Posted February 28, 2014 Hey guys, i have a problem with my Alpha in my Scoreboard Script. I want it to fade it in. but that doesn't really work. The problem is it sets the alpha to 0 if it reached 255. And how can i let it fade back if i unpress tab. local alpha = 0 function Alpha() if alpha < 255 then alpha = alpha + 10 end end --Alpha is triggered if i press tab. Hope you can help me Link to comment
WhoAmI Posted February 28, 2014 Share Posted February 28, 2014 if (alpha >= 255) then alpha = 255 end And added to render event. Link to comment
Karuzo Posted February 28, 2014 Author Share Posted February 28, 2014 I don't understand. What should that be ? Link to comment
iPrestege Posted February 28, 2014 Share Posted February 28, 2014 So you want that when you open the scoreboard the alpha changed to '0' As i think and return to '255' When the scoreboard closed? Link to comment
TrapLord Studios™ Posted February 28, 2014 Share Posted February 28, 2014 First thing is it a GUI or DX Scoreboard? Link to comment
Karuzo Posted February 28, 2014 Author Share Posted February 28, 2014 @CVC: No, it should slowly fade to 255 if i open it. And if i close the scoreboard it should fade slowly to 0. @VinnieBwoy: It's a DX Scoreboard where i just set the color with the alpha . tocolor(255,255,255,alpha) Link to comment
WhoAmI Posted February 28, 2014 Share Posted February 28, 2014 addEventHandler("onClientRender", root, function () if (alpha >= 255) then alpha = 255 end end ) I got same problem when I was doing animation on DX's ;p If your animation is done, you can remove this event using removeEventHandler. Link to comment
Karuzo Posted February 28, 2014 Author Share Posted February 28, 2014 So like this ? addEventHandler("onClientRender", root, function () if (alpha >= 255) then alpha = 255 elseif (alpha == 0) then removeEventHandler("onClientRender", root, Alpha) end end ) Link to comment
cheez3d Posted February 28, 2014 Share Posted February 28, 2014 (edited) fadeScoreboard = function(keyState) local fadeProgress = 0 if keyState == "down" then fadeProgress = fadeProgress+0.01 local alphaValue = interpolateBetween(0,0,0,255,0,0,fadeProgress,"InOutQuad") --dxDrawStuff + tocolor(r,g,b,alphaValue) if alphaValue>=1 then removeEventHandler("onClientRender",root,renderScoreboard) end elseif keyState == "up" then fadeProgress = fadeProgress-0.01 local alphaValue = interpolateBetween(0,0,0,255,0,0,fadeProgress,"InOutQuad") --dxDrawStuff + tocolor(r,g,b,alphaValue) if alphaValue<=0 then removeEventHandler("onClientRender",root,renderScoreboard) end end end addEventHandler("onPlayerJoin",root,function() bindKey(source,"tab","both",function(_,keyState) function renderScoreboard() fadeScoreboard(keyState) end addEventHandler("onClientRender",root,renderScoreboard) end) end) Edited February 28, 2014 by Guest Link to comment
WhoAmI Posted February 28, 2014 Share Posted February 28, 2014 function changeAlpha () if (alpha >= 255) then alpha = 255 removeEventHandler("onClientRender", root, changeAlpha) end end addEventHandler("onClientRender", root, changeAlpha) 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