Jump to content

[HELP] Function alpha


jamelnassar

Recommended Posts

Posted

hello gys

i want to make the gui hide in 3 second

i want to change alpha actilly

   Image = guiCreateStaticImage( 690, 200, 100, alpha, "R1.png", false ) 
local Alpha = 255 - o 
local o = 0.1 
  

i dont know why it doesnt work

can someone fix it

Posted

You mean keep lowering the alpha until it's fully invisible?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
local alpha1 = 255  
local alpha2 = 0 
Image = guiCreateStaticImage( 690, 200, 100, alpha, "R1.png", false ) 
function setalpha() 
    setTimer ( function() 
        guiSetAlpha(Image, alpha2) 
    end, 3000, 1 ) 
end 

xMWUKnl.gif
Posted

If you are trying to make a fade effect, i'd recommend using dxDrawImage so that you can just declare the alpha to a variable, and every render you can lower the alpha.

Example:

  
local alpha = 255 
addEventHandler ( "onClientRender", root, function ( ) 
    dxDrawImage ( 690, 200, 100, "R1.png", 0, 0, 0, tocolor ( 255, 255, 255, alpha ) ) 
    if ( alpha > 25 ) then 
       alpha = alpha - 1 
     end 
end ) 
  

Posted

You guys are doing serveral things wrong.

When using guiSetAlpha

alpha: The visibility/transparency of the GUI element. Ranges from 0 (fully transparent) to 1 (fully opaque).

And you are using guiCreateStaticImage and dxDrawImage wrong, it only has screenX, screenY, Width, and no height!

So:

local alpha = 255 
addEventHandler ( "onClientRender", root, function ( ) 
    dxDrawImage ( 690, 200, 100, 100, "R1.png", 0, 0, 0, tocolor ( 255, 255, 255, alpha ) )  
-- starts at 690 pixels from the Xscreen 
-- then starts at 200 pixels from the Y 
--draw is 100 pixels to the X ( width ) 
--and 100 pixels to the Y  ( height ) 
    if ( alpha > 25 ) then 
       alpha = alpha - 1 
     end 
end ) 

OR:

local alpha = 1 
Image = guiCreateStaticImage( 690, 200, 100, 100, "R1.png", false ) 
  
addEventHandler ( "onClientRender", root, function ( ) 
    if ( alpha >= 0 ) then 
       alpha = alpha - 0.1 
       guiSetAlpha ( Image, alpha ) 
     end 
end) 

Sometimes I dream about cheese

Posted
If you want to display it for every user in the game, you should loop through it using the getElementsByType.

That doesn't make any sense xD

If you put it on client side, then it will execute if the client's pc has loaded the client script.

Sometimes I dream about cheese

Posted

What's wrong with guiSetAlpha?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
If you want to display it for every user in the game, you should loop through it using the getElementsByType.

That doesn't make any sense xD

If you put it on client side, then it will execute if the client's pc has loaded the client script.

It does, you loop the elements that are players and send to each one's client-side the trigger. (correctly setup should work, but i would rather use the player variable than all elements, but still should work)

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted
What's wrong with guiSetAlpha?

guiSetAlpha not working with GUI Static Images

You are wrong, it's working.

The values are from 0 to 1, like I said earlier before.

If you want to display it for every user in the game, you should loop through it using the getElementsByType.

That doesn't make any sense xD

If you put it on client side, then it will execute if the client's pc has loaded the client script.

It does, you loop the elements that are players and send to each one's client-side the trigger. (correctly setup should work, but i would rather use the player variable than all elements, but still should work)

So you want to loop all players on the server side and then trigger X amount of players to the client, so if you have 50 players on your server, you are sending 50 times a trigger to the client??? Better use "root" instead.

Sometimes I dream about cheese

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...