Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix marker screen detection and click events (#2029 & #1853) #4375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
MohabCodeX wants to merge 27 commits into multitheftauto:master
base: master
Choose a base branch
Loading
from MohabCodeX:fix/client-side-entity

Conversation

@MohabCodeX
Copy link
Contributor

@MohabCodeX MohabCodeX commented Aug 20, 2025
edited
Loading

(#2029 & #1853)

Statement
Markers are not traditional GTA objects and don't integrate with the game's native collision system.

Result :

  • isElementOnScreen and onClientClick now work properly with markers.

Feedback is appreciated 👍🏻

Co-authored-by: Nico <122193236+Nico8340@users.noreply.github.com>
Copy link
Member

Nico8340 commented Aug 20, 2025
edited
Loading

Solution
Implemented a specialized marker detection system, enhanced screen visibility detection (IsClientSideOnScreen) with proper viewport clipping, and a new onClientMarkerClick event with parameters (button, state, screenX, screenY, worldX, worldY, worldZ, distance).

There's no sign of the onClientMarkerClick event in your code. If you're still working on it, please mark this pull request as stale.

Copy link
Contributor Author

There's no sign of the onClientMarkerClick event in your code. If you're still working on it, please mark this pull request as stale.

Thanks , also onClientMarkerClick is already implemented

https://github.com/MohabCodeX/mtasa-blue/blob/fix/client-side-entity/Client/mods/deathmatch/logic/CClientGame.cpp#L2815

https://github.com/MohabCodeX/mtasa-blue/blob/fix/client-side-entity/Client/mods/deathmatch/logic/CClientGame.cpp#L2530

@MohabCodeX MohabCodeX force-pushed the fix/client-side-entity branch 3 times, most recently from 9d86c52 to 5abe1e6 Compare August 21, 2025 04:13
@FileEX FileEX added the bugfix Solution to a bug of any kind label Aug 24, 2025
Copy link
Contributor Author

Any thoughts?

MarkerArguments.PushNumber(markerPosition.fY);
MarkerArguments.PushNumber(markerPosition.fZ);
MarkerArguments.PushNumber(markerDistance);
clickedMarker->CallEvent("onClientMarkerClick", MarkerArguments, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not entirely sure if we need a separate event for this? onClientClick works on all entity types such as object, vehicle, ped, so why have a separate event just for markers?

The main issue with markers is that methods like IsOnScreen or ProcessLineOfSight (used for collision detection) are based on CEntity. But markers, meaning the C3dMarker class, don’t inherit from CEntity, which means they aren’t treated as full-fledged entities at all.

MohabCodeX reacted with thumbs up emoji
Copy link
Contributor Author

@MohabCodeX MohabCodeX Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FileEX
Thanks for the feedback, i think working good now, could you check it please ?

i've tested it with simple script, seems ok.

local marker
local trash
function createElements()
 local player = getLocalPlayer()
 local x, y, z = getElementPosition(player)
 local matrix = getElementMatrix(player)
 
 local forwardX = matrix[2][1]
 local forwardY = matrix[2][2]
 local forwardZ = matrix[2][3]
 
 local markerDistance = 5
 local trashDistance = 7 
 local markerX = x + markerDistance * forwardX
 local markerY = y + markerDistance * forwardY
 local markerZ = z + markerDistance * forwardZ
 local trashX = x + trashDistance * forwardX
 local trashY = y + trashDistance * forwardY
 local trashZ = z + trashDistance * forwardZ 
 
 marker = createMarker(markerX, markerY, markerZ, "cylinder", 1.0, 255, 0, 0, 150)
 
 trash = createObject(1359, trashX, trashY, trashZ)
 
 setTimer(checkOnScreen, 2000, 0)
end
function checkOnScreen()
 if marker then
 local onScreenMarker = isElementOnScreen(marker)
 outputChatBox("Marker on screen: " .. tostring(onScreenMarker))
 end
 if trash then
 local onScreenTrash = isElementOnScreen(trash)
 outputChatBox("Trash on screen: " .. tostring(onScreenTrash))
 end
end
function onClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
 if state == "down" then 
 if clickedElement == marker then
 outputChatBox("Clicked on marker!")
 elseif clickedElement == trash then
 outputChatBox("Clicked on trash!")
 end
 end
end
addEventHandler("onClientResourceStart", resourceRoot, createElements)
addEventHandler("onClientClick", root, onClick)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t work properly.

Copy link
Member

FileEX commented Sep 5, 2025

image image

isElementOnScreen doesn’t work very well.

image The same applies to clicking.
MohabCodeX reacted with confused emoji

@MohabCodeX MohabCodeX marked this pull request as draft September 11, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tederis tederis tederis requested changes

@FileEX FileEX FileEX left review comments

@Nico8340 Nico8340 Awaiting requested review from Nico8340

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /