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!

i5 7400 3.0GHZ
B150M-GAMING 3 DDR4
HyperX FURY 8GB 2133Mhz DDR4
Galax GTX 1060 6GB OC

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.

i5 7400 3.0GHZ
B150M-GAMING 3 DDR4
HyperX FURY 8GB 2133Mhz DDR4
Galax GTX 1060 6GB OC

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

If I helped you, please click the like button on the right ;) Thanks!

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

i5 7400 3.0GHZ
B150M-GAMING 3 DDR4
HyperX FURY 8GB 2133Mhz DDR4
Galax GTX 1060 6GB OC

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.

If I helped you, please click the like button on the right ;) Thanks!

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.

i5 7400 3.0GHZ
B150M-GAMING 3 DDR4
HyperX FURY 8GB 2133Mhz DDR4
Galax GTX 1060 6GB OC

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

If I helped you, please click the like button on the right ;) Thanks!

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!

i5 7400 3.0GHZ
B150M-GAMING 3 DDR4
HyperX FURY 8GB 2133Mhz DDR4
Galax GTX 1060 6GB OC

Posted
Just now, IgorRodriguesCo said:

Worked perfectly! Thank you!

You're welcome!

  • Like 1

If I helped you, please click the like button on the right ;) Thanks!

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