Jump to content

help with getCursorPosition()


Kenix

Recommended Posts

script does not work

I need to get a place the cursor if it matches then write in chat.

  
function startGetPositionSkills() 
local showing = isCursorShowing () 
   if showing then -- if the cursor is showing 
      local screenx, screeny = getCursorPosition" class="kw4">getCursorPosition() 
      if ( screenx == 0.3077 ) and ( screeny == 0.5103 ) then  
        outputChatBox("1") 
    elseif ( screenx == 0.4342 ) and ( screeny == 0.5103 ) then  
         outputChatBox("2") 
    elseif ( screenx == 0.5558 ) and ( screeny == 0.5103 ) then  
          outputChatBox("3") 
    elseif ( screenx == 0.6948 ) and ( screeny == 0.5103 ) then  
          outputChatBox("4") 
    elseif ( screenx == 0.8263 ) and ( screeny == 0.5103 ) then  
         outputChatBox("5") 
    end 
end 
end  
  

Link to comment
  • Moderators

This script can't work except if you are very lucky ^^

I explain; for exemple here:

if ( screenx == 0.3077 ) and ( screeny == 0.5103 ) then 

it work's if the player click at 0.3077 ( x ) and 0.5103 ( y ) on the screen => It's almost IMPOSSIBLE

You have to specify a range of x and for y; for exemple like this:

if ( screenx >= 0.3077 ) and ( screenx <= 0.3477 ) and ( screeny >= 0.5103 ) and ( screeny <= 0.5503 ) then 

Here I made a little square of 0.4 ( Width ) and 0.4 ( Height ), so your players can click easily on this.

Link to comment
  • Moderators
not work :(

Of course, I don't know where do you want that the player can click ( is this sentence correct ? :? )

So where you want to click ?

Because if you made this, it works perfectly:

if ( screenx >= 0 ) and ( screenx <= 1 ) and ( screeny >= 0 ) and ( screeny <= 1 ) then 

Link to comment

it works but I do not see here is the position of the picture:

  
GUIEditor_Image[131] = guiCreateStaticImage(0.3077,0.1182,0.0819,0.0449,"images/white.png",true,GUIEditor_Window[131]) 
  

getCursorPosition :

  
if ( screenx >= 0.3077 ) and ( screenx <= 0.1182 ) and ( screeny >= 0.3077  ) and ( screeny <= 0.1182 ) then 
  

but somehow it does not work with these coordinates :(

and I need to do if the cursor is near the place you would write in chat

Link to comment
  • Moderators

Because 3 > 1so:

if the cursor position is > 3 and if the cursor position is < 1 too => it's impossible !

See this:

GUIEditor_Image[131] = guiCreateStaticImage(x, y, width, height, "images/white.png",true,GUIEditor_Window[131])

if ( screenx >= x) and ( screenx <= x+width ) and ( screeny >= y  ) and ( screeny <= y+height ) then

So:

if ( screenx >= 0.3077 ) and ( screenx <= 0.3077+0.0819 ) and ( screeny >= 0.1182 ) and ( screeny <= 0.1182+0.0449 ) then  
-- Or 
if ( screenx >= 0.3077 ) and ( screenx <= 0,4259) and ( screeny >= 0.1182 ) and ( screeny <= 0,1631 ) then  

Link to comment
  • Moderators

Yeah sorry, you use this ?

if ( screenx >= 0.3077 ) and ( screenx <= 0,4259) and ( screeny >= 0.1182 ) and ( screeny <= 0,1631 ) then 

As you can see, there are ',' instead of '.' ( I copy-paste the result of my calculator :roll: )

Try with this:

if ( screenx >= 0.3077 ) and ( screenx <= 0.4259) and ( screeny >= 0.1182 ) and ( screeny <= 0.1631 ) then 

Link to comment
  • Moderators

Why don't you use onClientGUIClick ?

and use it like this:

function image131Clicked() 
    outputChatBox("Image 131 Clicked !" ) 
end 
  
GUIEditor_Image[131] = guiCreateStaticImage(0.3077,0.1182,0.0819,0.0449,"images/white.png",true,GUIEditor_Window[131]) 
addEventHandler ( "onClientGUIClick", GUIEditor_Image[131] , image131Clicked, false) 

Link to comment
  • Discord Moderators
You are trying to copy a server, why? can't you think on your own ideas?

this is an example of something he has in mind.

why is he suddenly trying to copy a server and unable to use any of his own ideas, because he's using a feature for inspiration?

i need this

something like this

example:

Link to comment
  • Moderators
Why don't you use onClientGUIClick ?

and use it like this:

function image131Clicked() 
    outputChatBox("Image 131 Clicked !" ) 
end 
  
GUIEditor_Image[131] = guiCreateStaticImage(0.3077,0.1182,0.0819,0.0449,"images/white.png",true,GUIEditor_Window[131]) 
addEventHandler ( "onClientGUIClick", GUIEditor_Image[131] , image131Clicked, false) 

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