Kelly003 Posted June 7, 2021 Share Posted June 7, 2021 I want to if you click on the fixed button [dx image] then the whole gui turns off. But I don't know how to do it. please help code: function gui() dxDrawImage(screenW * 0.2654, screenH * 0.2057, screenW * 0.4699, screenH * 0.5885, "window.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.3110, screenH * 0.5339, screenW * 0.0956, screenH * 0.1016, "button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- button off dxDrawImage(screenW * 0.5949, screenH * 0.5339, screenW * 0.0956, screenH * 0.1016, "button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- Button on dxDrawText("text ", screenW * 0.3088, screenH * 0.3698, screenW * 0.6904, screenH * 0.4010, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Text", screenW * 0.4029, screenH * 0.4297, screenW * 0.5978, screenH * 0.5716, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Off", screenW * 0.3250, screenH * 0.5586, screenW * 0.3956, screenH * 0.6029, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("On", screenW * 0.6081, screenH * 0.5586, screenW * 0.6787, screenH * 0.6029, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end I tried to do something like this addEventHandler("onClientClick", root, function() if getCursorPosition(screenW * 0.3110, screenH * 0.5339, screenW * 0.0956, screenH * 0.1016) then showCursor(false) removeEventHandler("onClientRender", root, gui) return end end) but not working Link to comment
SpecT Posted June 7, 2021 Share Posted June 7, 2021 (edited) Hey, You used the getCursorPosition function wrongly. It doesn't take arguments but returns them. You can check examples in the link above. For your case you will need the useful function on the wiki: IsMouseInPosition. You will need to add the function in your script and then replace your "getCursorPosition" with "isMouseInPosition". Edited June 7, 2021 by SpecT 1 Link to comment
Kelly003 Posted June 8, 2021 Author Share Posted June 8, 2021 how to do when I navigate with the button on the button, then it changes the transparency and when the cursor is not on the button, it will return to the usual transparency? Link to comment
Tekken Posted June 8, 2021 Share Posted June 8, 2021 Exactly the same you did with onClientClick but with your gui() function. Link to comment
SpecT Posted June 8, 2021 Share Posted June 8, 2021 (edited) You will have to create a variable which will be for your alpha. All your images' and texts' alpha value will have to be multiplied by this variable. If the mouse is not in the position set this variable's value to 0.5 (for example) else 1. Something like this: function gui() local alpha = 1 if not isMouseInPosition(...) then alpha = 0.5 end dxDrawImage(..., tocolor(255, 255, 255, 255*alpha), ...) ... end Edited June 8, 2021 by SpecT 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