Skip to content

Fix isElementOnScreen for markers#4771

Open
FileEX wants to merge 10 commits intomultitheftauto:masterfrom
FileEX:bugfix/isElementOnScreen
Open

Fix isElementOnScreen for markers#4771
FileEX wants to merge 10 commits intomultitheftauto:masterfrom
FileEX:bugfix/isElementOnScreen

Conversation

@FileEX
Copy link
Copy Markdown
Member

@FileEX FileEX commented Apr 1, 2026

Summary

This PR adds the ability to use the isElementOnScreen function for markers.

Known issues

When rendering 3D markers, GTA checks visibility using a fixed radius of 2.0. This causes a bug where large markers disappear/flicker when moving the camera.

A second bug concerns this PR itself - isElementOnScreen returns true even when the marker is not visible but is close to the edge of the camera. The reason is simple: the marker is not visible, but GTA still renders it because the camera is within the 2-unit radius. This can be fixed in a future PR.

Motivation

Fixes #2029

Test plan

local x, y, z = getElementPosition(localPlayer)
local m = createMarker(x, y, z + 1, 'checkpoint', 1.0, 255, 0, 0, 255);

addEventHandler('onClientRender', root, function()
    dxDrawText('Marker visible: '..(isElementOnScreen(m) and 'true' or 'false'), 300, 300, 0, 0, 0xFFFFFFFF, 1, 'default-bold');
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 1, 2026 20:06
@FileEX FileEX added the bugfix Solution to a bug of any kind label Apr 1, 2026
@ArranTuna
Copy link
Copy Markdown
Collaborator

I have tested this with all 5 marker types and it works.

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

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isElementOnScreen() does not work for markers

2 participants