Jump to content

[Help] onClientClick dxImage


Recommended Posts

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"000tocolor(255255255255), false)
    dxDrawImage(screenW * 0.3110, screenH * 0.5339, screenW * 0.0956, screenH * 0.1016"button.png"000tocolor(255255255255), false-- button off
    dxDrawImage(screenW * 0.5949, screenH * 0.5339, screenW * 0.0956, screenH * 0.1016"button.png"000tocolor(255255255255), false-- Button on
    dxDrawText("text ", screenW * 0.3088, screenH * 0.3698, screenW * 0.6904, screenH * 0.4010tocolor(255255255255), 1.00"default-bold""center""center"falsefalsefalsefalsefalse)
    dxDrawText("Text", screenW * 0.4029, screenH * 0.4297, screenW * 0.5978, screenH * 0.5716tocolor(255255255255), 1.00"default-bold""center""center"falsefalsefalsefalsefalse)
    dxDrawText("Off", screenW * 0.3250, screenH * 0.5586, screenW * 0.3956, screenH * 0.6029tocolor(255255255255), 1.00"default-bold""center""center"falsefalsefalsefalsefalse)
    dxDrawText("On", screenW * 0.6081, screenH * 0.5586, screenW * 0.6787, screenH * 0.6029tocolor(255255255255), 1.00"default-bold""center""center"falsefalsefalsefalsefalse)
end


I tried to do something like this 

addEventHandler("onClientClick"rootfunction()
    if getCursorPosition(screenW * 0.3110, screenH * 0.5339, screenW * 0.0956, screenH * 0.1016then 
        showCursor(false)
        removeEventHandler("onClientRender"root, gui) return
    end 
end)

but not working

Link to comment

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