Jump to content

getCursorPosition got boolean


nurfaizfy19

Recommended Posts

sorry for my bad english

i want to get cursor position, but in debug show me an error got boolean. I have the code below

....
local sx,sy = guiGetScreenSize()
local cx,cy = getCursorPosition()
local cx,cy = cx*sx,cy*sy -- line 222
....

error message

Quote

myscript.lua:222: attempt to perform arithmetic on local 'cx' (a boolean value)

how to solve this? thank you very much

Edited by nurfaizfy19
typo
Link to comment
9 hours ago, DNL291 said:

Try removing 'local':


local sx,sy = guiGetScreenSize()
local cx,cy = getCursorPosition()
cx,cy = cx*sx,cy*sy

 

i tried it but still got boolean

9 hours ago, Patrick2562 said:

You can only get the cursor's position if cursor is showing.

https://wiki.multitheftauto.com/wiki/IsCursorShowing

 

 


local sx, sy = guiGetScreenSize()
function getpos()
	if isCursorShowing() then
		local cx, cy = getCursorPosition()
		return sx*cx, sy*cy
	end
	return false
end

 

It works for me, thank you very much

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