off Posted January 8, 2017 Share Posted January 8, 2017 local cursorX, cursorY = getCursorPosition() showCursor ( true ) setCursorAlpha(0) dxDrawImage ( cursorX, cursorY, 41, 41, 'images/cursor.png' ) Simple, what's the problem? Thanks in advance for your attention, Thank you! Link to comment
myonlake Posted January 8, 2017 Share Posted January 8, 2017 There is no problem, you're just not rendering the image inside a renderer. Link to comment
off Posted January 8, 2017 Author Share Posted January 8, 2017 11 hours ago, myonlake said: There is no problem, you're just not rendering the image inside a renderer. Its done, but the image is stuck in the upper left corner and the cursor is free. Link to comment
myonlake Posted January 8, 2017 Share Posted January 8, 2017 (edited) 4 minutes ago, IgorRodriguesCo said: Its done, but the image is stuck in the upper left corner and the cursor is free. You need to put the getCursorPosition function inside the renderer as well (you want it to get the cursor vector all the time, not only in the beginning of the script). Edited January 8, 2017 by myonlake Link to comment
off Posted January 8, 2017 Author Share Posted January 8, 2017 (edited) 3 minutes ago, myonlake said: You need to put the getCursorPosition function inside the renderer as well (you want it to get the cursor vector all the time, not only in the beginning of the script). function drawCursor( ) local showing = isCursorShowing () if showing then local cursorX, cursorY = getCursorPosition() setCursorAlpha(0) dxDrawImage ( cursorX, cursorY, 41, 41, 'images/cursor.png' ) end end addEventHandler ( "onClientRender", getRootElement(), drawCursor ) Its done, no? Edited January 8, 2017 by IgorRodriguesCo Link to comment
myonlake Posted January 8, 2017 Share Posted January 8, 2017 You can move the setCursorAlpha outside to where you use showCursor, because you are now setting the alpha all the time, whereas you only need to put it once. That script seems to be fine. Link to comment
off Posted January 8, 2017 Author Share Posted January 8, 2017 3 minutes ago, myonlake said: You can move the setCursorAlpha outside to where you use showCursor, because you are now setting the alpha all the time, whereas you only need to put it once. That script seems to be fine. The problem still persists. The image is stuck in the upper left corner and the cursor is free. Link to comment
myonlake Posted January 8, 2017 Share Posted January 8, 2017 Oh, right, forgot getCursorPosition returns a relative vector instead. This should do it: local screenWidth, screenHeight = guiGetScreenSize( ) function drawCursor( ) if ( isCursorShowing( ) ) then local cursorX, cursorY = getCursorPosition( ) dxDrawImage( cursorX * screenWidth, cursorY * screenHeight, 41, 41, 'images/cursor.png' ) end end addEventHandler( "onClientRender", root, drawCursor ) showCursor( true ) setCursorAlpha( 0 ) 1 Link to comment
off Posted January 8, 2017 Author Share Posted January 8, 2017 3 minutes ago, myonlake said: Oh, right, forgot getCursorPosition returns a relative vector instead. This should do it: local screenWidth, screenHeight = guiGetScreenSize( ) function drawCursor( ) if ( isCursorShowing( ) ) then local cursorX, cursorY = getCursorPosition( ) dxDrawImage( cursorX * screenWidth, cursorY * screenHeight, 41, 41, 'images/cursor.png' ) end end addEventHandler( "onClientRender", root, drawCursor ) showCursor( true ) setCursorAlpha( 0 ) Worked perfectly! Thank you! Link to comment
myonlake Posted January 8, 2017 Share Posted January 8, 2017 Just now, IgorRodriguesCo said: Worked perfectly! Thank you! You're welcome! 1 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