- Documentation
- Client functions
- getCursorPosition
Function
getCursorPosition
Returns the cursor position as a fraction of the screen 0-1 (x, y). Works only while the cursor is shown. The next three results (a world point) are zeros for now; getWorldFromScreenPosition gives the world point under the cursor.
Syntax
float, float, float, float, float getCursorPosition()Differences from MTA:SA
- In MTA:SA this function is server-side only.
In MTA:SA
getCursorPosition()Returns
x, y (0-1) and three zeros, or false.
Example
addEventHandler("onClientClick", root, function(button, state)
local x, y = getCursorPosition()
if x then outputChatBox(("Klik: %.2f, %.2f"):format(x, y)) end
end)
See also
getCursorPositionAbsoluteReturns the cursor position in screen pixels (while the cursor is shown).setCursorPositionMoves the cursor to a spot in the game window (pixels). Returnsfalsewhen the game window is not active or is minimised.getWorldFromScreenPositionConverts a point on the screen into a point in the 3D world at the given distance from the camera. Useful e.g. for placing objects with the mouse cursor.