- Documentation
- Client events
- onClientPlayerMapClick
Event
onClientPlayerMapClick
The player clicked the open map. The left button arrives on release, only if the map was not dragged; the right button arrives straight away. World coordinates are already converted from the map view.
Handler
addEventHandler("onClientPlayerMapClick", root, function(button, worldX, worldY, screenX, screenY) ... end)Parameters
buttonstring"left"or"right".worldX, worldYfloat- The world point under the cursor.
screenX, screenYint- The screen point in pixels.
Source
source is the local player.
Example
addEventHandler("onClientPlayerMapClick", localPlayer, function(button, x, y)
if button == "left" then
local z = getGroundPosition(x, y, 500)
outputChatBox(("Wybrane miejsce: %.0f, %.0f, %.0f"):format(x, y, z))
end
end)
See also
forcePlayerMapOpens or closes the game map: the same map as in the ESC menu, with blips, the GPS target and the route. On the server it works for one player or everyone (root). On the client you can pass a screen rectangle: the map is then drawn only inside it, without the title, legend or background around it. This works well for a spawn selection screen, because clicks outside the map still go to scripts (onClientClick, GUI). The player closes the map with ESC or the "Back" button and goes straight back to the game. Bind it to a key (e.g. F11) withbindKey.setPlayerMapWaypointEnabledTurns setting the GPS target with a right click on the map on or off. Turning it off is useful on a location picker screen: the right click still arrives inonClientPlayerMapClick, but the GPS stays unchanged.getWorldPositionFromPlayerMapConverts a screen point on the open map to a world point. It works the same as the coordinates fromonClientPlayerMapClick.