- Documentation
- Client functions
- setCursorImage
Function
setCursorImage
Swaps the game cursor for your own image: a PNG file from the resource or a texture from dxCreateTexture or dxCreateRenderTarget. Calling it with no argument or with false returns to the built-in cursor.
Syntax
bool setCursorImage([string|texture|bool image = nil, int hotX = 0, int hotY = 0, int width, int height])Arguments
imagestring|texture|bool, optional = nil- A file path, a texture or
false. hotXint, optional = 0- The click point in the image: pixels from the left edge.
hotYint, optional = 0- The click point: pixels from the top edge.
widthint, optional- On-screen width (the image width by default, up to 512).
heightint, optional- On-screen height (the image height by default, up to 512).
Returns
true on success.
Example
A 32x32 crosshair that clicks with its centre.
showCursor(true)
setCursorImage("img/celownik.png", 16, 16)
Notes
Pixels are copied at the moment of the call. A cursor drawn into a render target needs another call after every change. When the resource that set the image stops, the plain arrow returns.
See also
setCursorTypeChanges the game cursor shape. Without an argument the cursor goes back to changing shape by itself: over a link in a browser it turns into a hand, over a text field into an I-beam.setCursorAlphaSets the in-game cursor alpha (0 = invisible, 255 = opaque). The cursor shown withshowCursoris drawn by the game, above the HUD, GUI and browsers, so the alpha also shows on screenshots.showCursorShows or hides the mouse cursor. The cursor stays visible while at least one resource wants it, so hiding it in one resource does not close another's cursor. By default, while the cursor is shown, the ped controls are blocked.