Jump to content

What's the problem?


off

Recommended Posts

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
Link to comment
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
Link to comment
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

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
Link to comment
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...