Jump to content

What's the problem?


off

Recommended Posts

Posted
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!

Posted
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.

Posted (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 by myonlake
Posted (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 by IgorRodriguesCo
Posted

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.

Posted
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.

Posted

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
Posted
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!

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...