Jump to content

Click near element


Leo Messi

Recommended Posts

So simple and easy, I want to make something like;

for example; I created an icon (static image) and if I clicked near this image it will add event on it like onClientGUIClick and get a message with 'You clicked on x image' for example.

Just like CIT rapid transportation map to be clear.

Link to comment
9 hours ago, Leo Messi said:

So simple and easy, I want to make something like;

for example; I created an icon (static image) and if I clicked near this image it will add event on it like onClientGUIClick and get a message with 'You clicked on x image' for example.

Just like CIT rapid transportation map to be clear.

You could create a PNG image thats bigger than the original one with transparency, have an onclick for it

 

Link to comment
  • 5 weeks later...

Umh, i maybe didn't understood well but i'll try to explain what i figured out...

You could store the whole data in an array and use them with onClientKey, like: 

function Example (button, pressOrRelease)
  if not pressOrRelease then return end
  if isMouseInPosition ( Array[0],Array[1],Array[2],Array[3] ) then 
    outputChatBox("You clicked on X image")
  end
end
addEventHandler("onClientKey", root, Example)

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

Don't blame me if that's not what you needed, that's just what i understood and i'm trying to help...

Edited by XisH
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...