Zinjaaa Posted July 21, 2013 Share Posted July 21, 2013 Help I have a button and I want the function to close the window --------------------------------------> http://tinypic.com/view.php?pic=t0kw9s&s=5 <-------------------------------------- I want this function Example: Press f1 (open panel), Press button ( X ) close panel This is my client.lua local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() function dxDrawTheImage ( ) if isPlayerViewingPanel then dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) end end addEventHandler ( "onClientRender", root, dxDrawTheImage ) bindKey("f9", "down",function() if ( isPlayerViewingPanel == true ) then isPlayerViewingPanel = false showCursor (false) else isPlayerViewingPanel = true showCursor (true) end Link to comment
Jaysds1 Posted July 21, 2013 Share Posted July 21, 2013 1. You're missing an end before "showCursor" 2. In order to detect if the cursor is over the button/close.png then you would need to use either of these events: OnClientMouseMove or OnClientCursorMove Link to comment
Zinjaaa Posted July 21, 2013 Author Share Posted July 21, 2013 1. You're missing an end before "showCursor"2. In order to detect if the cursor is over the button/close.png then you would need to use either of these events: OnClientMouseMove or OnClientCursorMove You can make example please? Link to comment
Jaysds1 Posted July 21, 2013 Share Posted July 21, 2013 Sorry, I meant OnClientClick Example: addEventHandler("onClientClick",root,function(_,_,x,y) if not isPlayerViewingPanel then return end --Checks if the panel's opening and if it is then stop the function --Checks if the cursor is over the mouse from x to the width and y to the height if ( x >= 746.50 and x <= 746.50 + 43.50) and ( y >= 144 and y <= 144 + 43.50 ) then isPlayerViewingPanel = false end end) Link to comment
Zinjaaa Posted July 21, 2013 Author Share Posted July 21, 2013 hahha, You can make this in my client.lua, I do not understand much please help i'am very stupid .( local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() function dxDrawTheImage ( ) if isPlayerViewingPanel then dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) end end addEventHandler ( "onClientRender", root, dxDrawTheImage ) bindKey("f9", "down",function() if ( isPlayerViewingPanel == true ) then isPlayerViewingPanel = false showCursor (false) else isPlayerViewingPanel = true showCursor (true) end Link to comment
Jaysds1 Posted July 21, 2013 Share Posted July 21, 2013 Try this: local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() addEventHandler ( "onClientRender", root, function( ) if isPlayerViewingPanel then dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) end end ) bindKey("f9", "down",function() if isPlayerViewingPanel then isPlayerViewingPanel = false showCursor (false) else isPlayerViewingPanel = true showCursor (true) end end) addEventHandler("onClientClick",root,function(_,_,x,y) if not isPlayerViewingPanel then return end --Checks if the panel's opening and if it is then stop the function --Checks if the cursor is over the mouse from x to the width and y to the height if ( x >= 746.50 and x <= 746.50 + 43.50) and ( y >= 144 and y <= 144 + 43.50 ) then isPlayerViewingPanel = false end end) Link to comment
Zinjaaa Posted July 21, 2013 Author Share Posted July 21, 2013 (edited) Thanks friend, but a detail, By pressing the button, the cursor does not disappear And I found the fault local isPlayerViewingPanel = false local sw,sh = guiGetScreenSize() addEventHandler ( "onClientRender", root, function( ) if isPlayerViewingPanel then dxDrawImage ( 240, 145, 550, 480, "window.png" ) dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) end end ) bindKey("f9", "down",function() if isPlayerViewingPanel then isPlayerViewingPanel = false showCursor (false) else isPlayerViewingPanel = true showCursor (true) end end) addEventHandler("onClientClick",root,function(_,_,x,y) if not isPlayerViewingPanel then return end --Checks if the panel's opening and if it is then stop the function --Checks if the cursor is over the mouse from x to the width and y to the height if ( x >= 746.50 and x <= 746.50 + 43.50) and ( y >= 144 and y <= 144 + 43.50 ) then isPlayerViewingPanel = false showCursor( false ) end end) Edited July 21, 2013 by Guest Link to comment
Castillo Posted July 21, 2013 Share Posted July 21, 2013 local isPlayerViewingPanel = false local sw, sh = guiGetScreenSize ( ) addEventHandler ( "onClientRender", root, function( ) if isPlayerViewingPanel then dxDrawImage ( 400, 120, 560, 480, "Ventana.png" ) dxDrawImage ( 746.50, 144, 43.50, 43.50, "close.png" ) end end ) bindKey ( "f9", "down", function ( ) isPlayerViewingPanel = ( not isPlayerViewingPanel ) showCursor ( isPlayerViewingPanel ) end ) addEventHandler ( "onClientClick", root, function ( _, _, x, y ) if ( not isPlayerViewingPanel ) then --Checks if the panel's opening and if it is then stop the function return end --Checks if the cursor is over the mouse from x to the width and y to the height if ( x >= 746.50 and x <= 746.50 + 43.50 ) and ( y >= 144 and y <= 144 + 43.50 ) then isPlayerViewingPanel = false showCursor ( false ) end end ) Link to comment
Zinjaaa Posted July 21, 2013 Author Share Posted July 21, 2013 Thanks for your help, if I see good people here 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