Wes Posted May 31, 2013 Posted May 31, 2013 I want to put images in the MTA server, is there any function with I can trigger an event if the user clicks on the picture? Like onClientGUIClick, but instead of a gui button, you have to click on an image
iPrestege Posted May 31, 2013 Posted May 31, 2013 You can use the onClientGUIClick it's for any gui element .
Moderators IIYAMA Posted May 31, 2013 Moderators Posted May 31, 2013 or onClientClick https://wiki.multitheftauto.com/wiki/OnClientClick You can use that for clicking at directx render images or specific locations. compare the image start size and the image end size with the absoluteX and absoluteY value. local Xstart, Ystart = 100,100 local Xend,Yend = Xstart+100, Ystart+100 addEventHandler ("onClienClick",root, function (button, state,absoluteX, absoluteY ) if (absoluteX > Xstart and absoluteX < Xend) and (absoluteY > Ystart and absoluteY < Yend) then outputChatBox("clicked on the image") end end)
Wes Posted May 31, 2013 Author Posted May 31, 2013 I used guiCreateStaticImage, how can I make it clickable then? Cause I didn't understand the last answer.
iPrestege Posted May 31, 2013 Posted May 31, 2013 addEventHandler('onClientGUIClick',MyImage, function ( ) -- What ever you want . end ,false )
Wes Posted May 31, 2013 Author Posted May 31, 2013 Thank you Prestege, I'm gonna try this out! How can I make that so if the player cursor is on the image, it turns into another image? like mouseOver in Javascript.
iPrestege Posted May 31, 2013 Posted May 31, 2013 You mean that if the player enter the mouse into the image?
Wes Posted May 31, 2013 Author Posted May 31, 2013 So yea, if his cursor is over the image, doesnt click but it stands there, then it changes the picture. I want so when he hovers his mouse over the image, it changes into another button that has a border. The only thing I ask now is how can I make it so it will change the picture
Vision Posted May 31, 2013 Posted May 31, 2013 How can I make that so if the player cursor is on the image, it turns into another image? like mouseOver in Javascript. onClientMouseEnter
Castillo Posted May 31, 2013 Posted May 31, 2013 And onClientMouseLeave to restore it when the cursor leaves the image.
Wes Posted May 31, 2013 Author Posted May 31, 2013 So I should get the button positions, and replace absoluteX and absoluteY?
Castillo Posted May 31, 2013 Posted May 31, 2013 No, you just use the image element in that event, like this: addEventHandler ( "onClientMouseEnter", myImage, function ( ) -- Load your new image here end ,false )
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