Zinjaaa Posted July 29, 2013 Share Posted July 29, 2013 I need help, I want my buttons to make a function like this example Pass the mouse over the button. ---------------> http://oi44.tinypic.com/t7j4gn.jpg <--------------- Remove the mouse from the button. ---------------> http://oi41.tinypic.com/bgtmw5.jpg <--------------- Please, I need help I want that function, but I can not create it, Somebody do an example without using the wikipedia Would greatly appreciate it If you have doubts here my client local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() function dxDrawTheImage ( ) if isPlayerViewingPanel then dxDrawImage ( 240, 145, 550, 480, "window.png" ) dxDrawImage ( 431.50, 530, 165, 60, "button.png" ) dxDrawImage ( 610.50, 530, 165, 60, "button.png" ) dxDrawImage ( 252.50, 530, 165, 60, "button.png" ) dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") end end addEventHandler ( "onClientRender", root, dxDrawTheImage ) bindKey("O", "down",function() if ( isPlayerViewingPanel == true ) then isPlayerViewingPanel = false showCursor (false) else isPlayerViewingPanel = true showCursor (true) end end ) Link to comment
iMr.3a[Z]eF Posted July 29, 2013 Share Posted July 29, 2013 "onClientMouseEnter" dxSetPixelColor-- alpha argument to 0.75 "onClientMouseLeavr" dxSetPixelColor-- alpha argument to 1.00 Link to comment
Zinjaaa Posted July 29, 2013 Author Share Posted July 29, 2013 "onClientMouseEnter" dxSetPixelColor-- alpha argument to 0.75 "onClientMouseLeavr" dxSetPixelColor-- alpha argument to 1.00 You can create example with my client? (no use wiki) Link to comment
WASSIm. Posted July 29, 2013 Share Posted July 29, 2013 use this you will make windown image easy like DX guiCreateStaticImage Link to comment
Zinjaaa Posted July 29, 2013 Author Share Posted July 29, 2013 use this you will make windown image easy like DX guiCreateStaticImage I use dxDrawTheImage Link to comment
FatalTerror Posted July 29, 2013 Share Posted July 29, 2013 I need help, I want my buttons to make a function like thisexample Pass the mouse over the button. ---------------> http://oi44.tinypic.com/t7j4gn.jpg <--------------- Remove the mouse from the button. ---------------> http://oi41.tinypic.com/bgtmw5.jpg <--------------- Please, I need help I want that function, but I can not create it, Somebody do an example without using the wikipedia Would greatly appreciate it If you have doubts here my client local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() function dxDrawTheImage ( ) if isPlayerViewingPanel then dxDrawImage ( 240, 145, 550, 480, "window.png" ) dxDrawImage ( 431.50, 530, 165, 60, "button.png" ) dxDrawImage ( 610.50, 530, 165, 60, "button.png" ) dxDrawImage ( 252.50, 530, 165, 60, "button.png" ) dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") end end addEventHandler ( "onClientRender", root, dxDrawTheImage ) bindKey("O", "down",function() if ( isPlayerViewingPanel == true ) then isPlayerViewingPanel = false showCursor (false) else isPlayerViewingPanel = true showCursor (true) end end ) I edit some stuffs in your code to make things possible. First one, I create a table containing the buttons with they position. In the render, I explore this table and create every buttons. I added a second render for the cursor, if the cursor is between the button position then, we change the image target, otherwise let the default image. Buttons = { firstButton = {x =431.50, y = 530, w = 165, h = 60, img = "button.png"}, secondButton = {x =610.50, y = 530, w = 165, h = 60, img = "button.png"}, thirdButton = {x =252.50, y = 530, w = 165, h = 60, img = "button.png"} } local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() function dxDrawTheImage ( ) if isPlayerViewingPanel then dxDrawImage ( 240, 145, 550, 480, "window.png" ) for i, button in pairs(Buttons)do dxDrawImage (button.x, button.y, button.w, button.h, button.img) end dxDrawText ( "Rules", sw/2 - 26, sh/2 - 230, sw/2 + 175, sh/2 + 80, tocolor ( 255, 255, 255, 255 ), 1.6, "default-bold") end end addEventHandler ( "onClientRender", root, dxDrawTheImage ) function cursorPosition() local x, y = getCursorPosition() local x, y = x*sw, y*sh; for i, button in pairs(Buttons)do if (x >= button.x) and (y >= button.y) and (x <= (button.x+button.w)) and (y <= (button.y+button.h)) then -- Cursor is in the button button.img = "button_hover.png"; else -- Cursor isn't anymore in the button button.img = "button.png"; end end end bindKey("O", "down",function() if ( isPlayerViewingPanel == true ) then isPlayerViewingPanel = false showCursor (false) removeEventHandler("onClientRender", getRootElement(), cursorPosition) else isPlayerViewingPanel = true showCursor (true) addEventHandler("onClientRender", getRootElement(), cursorPosition) end end ) 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