Skip to content

Add crosshair component to *playerHudComponentProperty functions#4780

Open
FileEX wants to merge 2 commits intomultitheftauto:masterfrom
FileEX:feature/hud-component-crosshair
Open

Add crosshair component to *playerHudComponentProperty functions#4780
FileEX wants to merge 2 commits intomultitheftauto:masterfrom
FileEX:feature/hud-component-crosshair

Conversation

@FileEX
Copy link
Copy Markdown
Member

@FileEX FileEX commented Apr 5, 2026

Summary

This PR adds the crosshair component to the setPlayerHudComponentProperty, getPlayerHudComponentProperty, and resetPlayerHudComponentProperty functions. It allows you to change the size, position, and color of the crosshair.

image

Note

The crosshair is composed of 4 textures arranged in a 2x2 layout. The size specified in setPlayerHudComponentProperty defines the size of a single part of the crosshair, not the entire crosshair. On the other hand, the size returned by getPlayerHudComponentProperty represents the size of the whole crosshair; you can divide it by 2 to get the size of a single part.

Motivation

Closes #4553

Test plan

addEventHandler('onClientRender', root, function()
    local x, y = getPlayerHudComponentProperty('crosshair', 'position')
    local w, h = getPlayerHudComponentProperty('crosshair', 'size')

    dxDrawRectangle(x, y, w, h, tocolor(255, 255, 255, 100))
end);

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@FileEX FileEX requested a review from a team as a code owner April 5, 2026 15:04
@FileEX FileEX added the enhancement New feature or request label Apr 5, 2026
@ArranTuna
Copy link
Copy Markdown
Collaborator

I tested changing the position and noticed the white dot at the center stays in the same place:
image

@FileEX
Copy link
Copy Markdown
Member Author

FileEX commented Apr 8, 2026

I tested changing the position and noticed the white dot at the center stays in the same place: image

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

For getPlayerHudComponentProperty("crosshair", "position") to return the crosshair position

2 participants