Jump to content

Alpha Set :D


#Paper

Recommended Posts

I want to make a funny window:

function setMajorAlpha () 
local getAlpha = guiGetAlpha(wndShop) 
guiSetAlpha(wndShop, tonumber(getAlpha + 0.1)) 
end 
  
function setMinorAlpha () 
local getAlpha = guiGetAlpha(wndShop) 
guiSetAlpha(wndShop, tonumber(getAlpha - 0.1)) 
end 
  
function ShowHide (key, keyState) 
local getAlpha = guiGetAlpha(wndShop) 
if getAlpha == 0.1 then 
setTimer(setMajorAlpha, 500, 6) 
elseif getAlpha == 0.6 then 
setTimer(setMinorAlpha, 500, 6) 
end 
end 
bindKey("F10", "down", ShowHide) 

When i press F10 the Alpha doesn't changes it's the same: 0.1

Link to comment

Did you set the default alpha?

guiSetAlpha(wndShop, 0.6)) 

after wndShop cteation

also try to secure the condition more

if getAlpha <= 0.1 then 
setTimer(setMajorAlpha, 500, 6) 
elseif getAlpha >= 0.6 then 
setTimer(setMinorAlpha, 500, 6) 
 end 

Link to comment
  • Moderators
Did you set the default alpha?
guiSetAlpha(wndShop, 0.6)) 

after wndShop cteation

also try to secure the condition more

if getAlpha <= 0.1 then 
setTimer(setMajorAlpha, 500, 6) 
elseif getAlpha >= 0.6 then 
setTimer(setMinorAlpha, 500, 6) 
 end 

I'm agree, if you put an outputChatBox( "Alpha: "..getAlpha ), you will can noticed that it's not exactly 0.6 or 0.1 but something like 0.599863 or IDK

So the Alpha is never exactly 0.6 or 0.1

Wojak is right, but change a little thing:

if getAlpha <= 0.13 then 
setTimer(setMajorAlpha, 500, 6) 
elseif getAlpha >= 0.57 then 
setTimer(setMinorAlpha, 500, 6) 
 end 

It's more secure like that :wink:

Link to comment
  • Moderators

So I test it and it works but I changed 2 things ( and we don't need the ; ^^ ):

You have to get the Alpha each time instead of the variable getAlpha because if the getAlpha value is ( for exemple ) 0.3, the server gona make guiSetAlpha(wndShop, 0.3+ 0.1)

So the Alpha is always 0.4 do you understand ? I'm sure that you understand :mrgreen:

And it was not rather fluid so a modified it for you :D :

setTimer(function () guiSetAlpha(wndShop, guiGetAlpha( wndShop )+0.02) end, 100, 30) 

and

setTimer(function () guiSetAlpha(wndShop, guiGetAlpha( wndShop )-0.02) end, 100, 30) 

It works perfectly on my own server

Link to comment
So I test it and it works but I changed 2 things ( and we don't need the ; ^^ ):

You have to get the Alpha each time instead of the variable getAlpha because if the getAlpha value is ( for exemple ) 0.3, the server gona make guiSetAlpha(wndShop, 0.3+ 0.1)

So the Alpha is always 0.4 do you understand ? I'm sure that you understand :mrgreen:

And it was not rather fluid so a modified it for you :D :

setTimer(function () guiSetAlpha(wndShop, guiGetAlpha( wndShop )+0.02) end, 100, 30) 

and

setTimer(function () guiSetAlpha(wndShop, guiGetAlpha( wndShop )-0.02) end, 100, 30) 

It works perfectly on my own server

ye i understand and i fixxed it, but, why i can't set the time of the timer under "50"? xD

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...