Sign in to follow this  
IgorRodriguesCo

What's the problem?

Recommended Posts

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!

Share this post


Link to post
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 by myonlake

Share this post


Link to post
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 by IgorRodriguesCo

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post

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 )

 

  • Like 1

Share this post


Link to post
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!

Share this post


Link to post
Just now, IgorRodriguesCo said:

Worked perfectly! Thank you!

You're welcome!

  • Like 1

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.