#Paper Posted September 7, 2011 Share Posted September 7, 2011 So, i have 1 dxImage that i drow in the screen, how can i detect when the cursor is in the image? Link to comment
E-mail Posted September 7, 2011 Share Posted September 7, 2011 Hi Use This maybe https://wiki.multitheftauto.com/wiki/IsCursorShowing Link to comment
#Paper Posted September 7, 2011 Author Share Posted September 7, 2011 No lol... this function checks if the cursor is showing... i need to know if the cursor is in the image <_ Link to comment
karlis Posted September 7, 2011 Share Posted September 7, 2011 function isPointInBounds(pointx,pointy,boundx,boundy,boundw,boundh) return pointx>boundx and pointy>boundy and pointxand pointyend Link to comment
#Paper Posted September 7, 2011 Author Share Posted September 7, 2011 emh? wich coordinates i must insert in pointx,pointy,boundx,boundy,boundw and boundh? Link to comment
SDK Posted September 7, 2011 Share Posted September 7, 2011 point x,y is the cursor position on the screen (using getCursorPosition * guiGetScreenSize ) boundx,y is the image position boundw,h is image width and height Link to comment
#Paper Posted September 7, 2011 Author Share Posted September 7, 2011 OMG, Error @ line 2: "attempt to compare number whit nil" function isPointInBounds(pointx,pointy,boundx,boundy,boundw,boundh) return pointx>boundx and pointy>boundy and pointx<boundw+boundx and pointy<boundy+boundh end function checkForCursorInImage() local pointx, pointy, worldx, worldy, worldz = getCursorPosition" class="kw4">getCursorPosition" class="kw4">getCursorPosition() * guiGetScreenSize() if isPointInBounds(pointx,pointy,x + barX + 35,13 + textMove - 10,100,75) then showStatsWindow() end end addEventHandler("onClientCursorMove", root, checkForCursorInImage) EDIT: i tryed whit this: function isPointInBounds(pointx,pointy,boundx,boundy,boundw,boundh) if pointx>boundx then if pointy>boundy then if pointxthen if pointythen return true else return false end else return false end else return false end else return false end end and the error is @ line 3 Link to comment
SDK Posted September 7, 2011 Share Posted September 7, 2011 Use for the moment, [lua] is fucked up as you can see in your post. [code=text]local pointx, pointy, worldx, worldy, worldz = getCursorPosition() * guiGetScreenSize() Ehm, that won't work... local pointx, pointy = getCursorPosition() local screenx, screeny = guiGetScreenSize() local pointx = screenx * pointx local pointy = screeny * pointy Link to comment
#Paper Posted September 8, 2011 Author Share Posted September 8, 2011 "attempt to compare number whit nil" in this line "if pointx>boundx then" local selectedTab function checkForCursorInImage() local pointx, pointy = getCursorPosition() local screenx, screeny = guiGetScreenSize() local pointx = screenx * pointx local pointy = screeny * pointy local imgX, imgY, imgW, imgH = x + barX + 35, 13 + textMove - 10, 100, 75 if isCursorShowing() then if isPointInBounds(mouseX, mouseY, imgX, imgY, imgW, imgH) then selectedTab = "stats" checkForTabs() end end end addEventHandler("onClientCursorMove", root, checkForCursorInImage) Link to comment
karlis Posted September 8, 2011 Share Posted September 8, 2011 pointx pointy is defiend, not mouseX,mouseY 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