papam77 Posted June 20, 2013 Posted June 20, 2013 Hello, how can make alpha changing if i enter with mouse to my image? lobby = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/lobbyBG.png", true) arenas = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/arenas.png", true) dm = guiCreateStaticImage(0.157, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas) dd = guiCreateStaticImage(0.331, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas) guiSetAlpha ( dm, 0.75 ) guiSetAlpha ( dd, 0.75 ) This is code for images alpha must be 1.00 if player enter to the button. How can do that?
iPrestege Posted June 20, 2013 Posted June 20, 2013 Event's : onClientMouseEnter onClientMouseLeave Function : guiSetAlpha
Dealman Posted June 20, 2013 Posted June 20, 2013 Use the event onClientMouseEvent, and when the mouse is over the specified GUI Element it will trigger the function, for example; function onClientMouseHoverSetAlpha() if(source == dm) then guiSetAlpha(dm, 0.75) elseif(source == dd) then guiSetAlpha(dd, 0.75) end end addEventHandler("onClientMouseEnter", getRootElement(), onClientMouseHoverSetAlpha) Remember that you will also have to make it so it sets the Alpha back to the default when the mouse is not hovering over any of the specified elements. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Moderators IIYAMA Posted June 20, 2013 Moderators Posted June 20, 2013 I was already writing this,,,, so I post it any way. local guiTable = { ["lobby"]= guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/lobbyBG.png", true), ["arenas"]= guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "images/arenas.png", true), ["dm"]= guiCreateStaticImage(0.157, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas), ["dd"]= guiCreateStaticImage(0.331, 0.19, 0.17, 0.305, "images/areny/dm.png", true, arenas) } guiSetAlpha ( guiTable["dm"], 0.75 ) guiSetAlpha ( guiTable["dd"], 0.75 ) addEventHandler( "onClientMouseEnter", root, function(aX, aY) for key,gui in pairs (guiTable) do if gui == source then guiSetAlpha ( source, 1 ) return end end end ) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Dealman Posted June 20, 2013 Posted June 20, 2013 I was already writing this,,,, so I post it any way. No need to make it over-the-top with tables when you could just use onClientMouseLeave to return the Alpha to 1 :3 If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Moderators IIYAMA Posted June 20, 2013 Moderators Posted June 20, 2013 I did start writing it before you post anything. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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