Kenix Posted March 25, 2011 Share Posted March 25, 2011 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 Citizen Posted March 25, 2011 Moderators Share Posted March 25, 2011 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
qaisjp Posted March 26, 2011 Share Posted March 26, 2011 This is slightly offtopic, but what is this shit -- below local screenx, screeny = getCursorPosition" class="kw4">getCursorPosition() I have seen that class="kw4" on various functions. What the hell is it? Link to comment
Moderators Citizen Posted March 26, 2011 Moderators Share Posted March 26, 2011 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
Kenix Posted March 26, 2011 Author Share Posted March 26, 2011 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 Citizen Posted March 26, 2011 Moderators Share Posted March 26, 2011 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 Citizen Posted March 27, 2011 Moderators Share Posted March 27, 2011 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 ) Try with this: if ( screenx >= 0.3077 ) and ( screenx <= 0.4259) and ( screeny >= 0.1182 ) and ( screeny <= 0.1631 ) then Link to comment
Kenix Posted March 27, 2011 Author Share Posted March 27, 2011 I've corrected it still does not work. Link to comment
Moderators Citizen Posted March 27, 2011 Moderators Share Posted March 27, 2011 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
Kenix Posted March 27, 2011 Author Share Posted March 27, 2011 i need this something like this example: Link to comment
Castillo Posted March 27, 2011 Share Posted March 27, 2011 You are trying to copy a server, why? can't you think on your own ideas? Link to comment
Discord Moderators Zango Posted March 28, 2011 Discord Moderators Share Posted March 28, 2011 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 thissomething like this example: Link to comment
Kenix Posted March 28, 2011 Author Share Posted March 28, 2011 I have my own ideas and I showed you this screenshot as an example. Link to comment
Moderators Citizen Posted March 28, 2011 Moderators Share Posted March 28, 2011 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
Moderators Citizen Posted March 28, 2011 Moderators Share Posted March 28, 2011 Could you answer to my question ? Link to comment
Kenix Posted March 28, 2011 Author Share Posted March 28, 2011 at the moment I do not need the event onClientClick Link to comment
Moderators Citizen Posted March 28, 2011 Moderators Share Posted March 28, 2011 Ok like you want dude so I can't help you more except that: This is linked to the GTA world, as appose to GUI for which onClientGUIClick is to be used Link to comment
Buffalo Posted March 29, 2011 Share Posted March 29, 2011 Just use following events: onClientMouseEnter onClientMouseLeave Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now