McDeKi Posted January 23, 2014 Posted January 23, 2014 Hello! I have problem with dx, local x,y = guiGetScreenSize() function test() local xMysz,yMysz,cos1,cos2,cos3 = getCursorPosition() realneX,realneY = fullx*xMysz,fully*xMysz kameraHusta = dxDrawRectangle(x*0,y*0,x*1,y*0.20,tocolor(0,0,0,255)) if realneX > 0 and realneX < 0 + 1280 and realneY > 0 and realneY < 0 + 144 then outputChatBox("test") end end addEventHandler("onClientRender",root,test) It works, but it doesn't suit all resolutions, I know why (if realneX > 0 and realneX < 0 + 1280 and realneY > 0 and realneY < 0 + 144 then) , but I don't know how can fix it.
denny199 Posted January 23, 2014 Posted January 23, 2014 local x,y = guiGetScreenSize() function test() local xMysz,yMysz,cos1,cos2,cos3 = getCursorPosition() realneX,realneY = fullx*xMysz,fully*xMysz kameraHusta = dxDrawRectangle(x*0,y*0,x*1,y*0.20,tocolor(0,0,0,255)) if realneX > 0 and realneX < 0 + x*1 and realneY > 0 and realneY < 0 + y*0.20 then outputChatBox("test") end end addEventHandler("onClientRender",root,test) Pretty easy
McDeKi Posted January 23, 2014 Author Posted January 23, 2014 I tried it before, and It works, but in wrong section of screen, http://imgur.com/d1VvFwD
Gallardo9944 Posted January 23, 2014 Posted January 23, 2014 Should be working, but it's untested. local x,y = guiGetScreenSize() local topSize = 144 function renderRectangle() local range = isMouseWithinRangeOf(0,x,0,topSize) -- startX,sizeX,startY,sizeY if range then -- if the mouse is in the area dxDrawRectangle(0,0,x,topSize,tocolor(0,0,0,200)) -- 200 alpha if you hover it else dxDrawRectangle(0,0,x,topSize,tocolor(0,0,0,40)) -- 40 otherwise end end addEventHandler("onClientRender",getRootElement(),renderRectangle) function isMouseWithinRangeOf(psx,pssx,psy,pssy) if not isCursorShowing() then return false end local cx,cy = getCursorPosition() cx,cy = cx*x,cy*y if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then return true,cx,cy else return false end end
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