-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
base: master
Are you sure you want to change the base?
Fix marker screen detection and click events (#2029 & #1853) #4375
Conversation
Co-authored-by: Nico <[email protected]>
There's no sign of the |
Thanks , also |
26e7235
to
74cbc2b
Compare
9d86c52
to
5abe1e6
Compare
Any thoughts? |
MarkerArguments.PushNumber(markerPosition.fY); | ||
MarkerArguments.PushNumber(markerPosition.fZ); | ||
MarkerArguments.PushNumber(markerDistance); | ||
clickedMarker->CallEvent("onClientMarkerClick", MarkerArguments, false); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
(#2029 & #1853)
Statement
Markers are not traditional GTA objects and don't integrate with the game's native collision system.
Result :
isElementOnScreen
andonClientClick
now work properly with markers.Feedback is appreciated 👍🏻