Jump to content

[HELP] Function alpha


jamelnassar

Recommended Posts

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 ) 
  

Link to comment

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) 

Link to comment
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)

Link to comment
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.

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