Skip to content

Conversation

MohabCodeX
Copy link
Contributor

@MohabCodeX MohabCodeX commented Aug 20, 2025

(#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 👍🏻

@Nico8340
Copy link
Member

Nico8340 commented Aug 20, 2025

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.

@MohabCodeX
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 from 26e7235 to 74cbc2b Compare August 21, 2025 03:48
@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
@MohabCodeX
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.

Copy link
Contributor Author

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)

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.

4 participants