Sign in to follow this  
Hugos

[Help] dxDrawRectangle

Recommended Posts

Please tell me whether it is possible to "dxDrawRectangle" to attach the function "onClientGUIClick"? If so, then how to do it?
 

Share this post


Link to post
Posted (edited)

use 

function isMouseInPosition ( x, y, width, height )
	if ( not isCursorShowing( ) ) then
		return false
	end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

addEventHandler ( "onClientClick", root,
    function ( button, state )
        if ( button == "left" and state == "down" ) then
            if ( isMouseInPosition ( the postion of the button ) ) then
		-- code
            end
        end
    end
)

 

Edited by salh
  • Thanks 1

Share this post


Link to post
On 13/06/2019 at 17:00, salh said:

use 


function isMouseInPosition ( x, y, width, height )
	if ( not isCursorShowing( ) ) then
		return false
	end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

addEventHandler ( "onClientClick", root,
    function ( button, state )
        if ( button == "left" and state == "down" ) then
            if ( isMouseInPosition ( the postion of the button ) ) then
		-- code
            end
        end
    end
)

 

Thank!

Share this post


Link to post
Posted (edited)
On 13/06/2019 at 17:00, salh said:

use 


function isMouseInPosition ( x, y, width, height )
	if ( not isCursorShowing( ) ) then
		return false
	end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

addEventHandler ( "onClientClick", root,
    function ( button, state )
        if ( button == "left" and state == "down" ) then
            if ( isMouseInPosition ( the postion of the button ) ) then
		-- code
            end
        end
    end
)

 

Found another way, easier:
Create "guiCreateLabel (x, y, width, height, "", false)", where x, y, width and height are the same as " dxDrawRectangle", and create function "onClientGUIClick"
;)

Edited by Hugos

Share this post


Link to post

It's not really that efficient, use the method salh gave you instead

Share this post


Link to post

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
Sign in to follow this