Leo Messi

Click near element

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.

Share this post


Link to post
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

 

Share this post


Link to post
On 8/10/2018 at 21:41, knightscript said:

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

 

Good idea, but wastes time and I already made it before

I need something new

Share this post


Link to post
Just now, Leo Messi said:

Any example?

Forgive me, I wasnt at home, I will work on an example and I will send it to you, i will use 1920x1080 and make calculations there, theoretically if I do it relative it should work on any res, i will update my comment when its ready.

  • Thanks 1

Share this post


Link to post

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

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

  • Recently Browsing   0 members

    No registered users viewing this page.