code an MTA SA code to show the cursor when the map is opened, wait for a player to click -> convert his click cords on the map to in-game world cords -> teleport the player there
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Creating an MTA:SA (Multi Theft Auto: San Andreas) script to show the cursor when the map is opened, wait for a player to click, convert the click coordinates on the map to in-game world coordinates, and then teleport the player there, involves several steps. Below is a basic example of how you might achieve this using Lua scripting for MTA:SA.
First, you need to create a server-side resource script. The script will handle the map click event and teleport the player.
Step 1: Create the Resource Directory
Create a folder named teleport_on_map_click in your resources directory.
Step 2: Create the Meta File
Create a meta.xml file in the teleport_on_map_click directory with the following content:
xml
<meta>
<info author="Your Name" version="1.0" description="Teleport player on map click" />
<script src="teleport_on_map_click_s.lua" type="server" />
<script src="teleport_on_map_click_c.lua" type="client" />
</meta>
Step 3: Create the Server Script
Create a teleport_on_map_click_s.lua file in the teleport_on_map_click directory with the following content:
lua
function teleportPlayer(player, x, y, z)
setElementPosition(player, x, y, z)
end
addEvent("onPlayerMapClick", true)
addEventHandler("onPlayerMapClick", getRootElement(), teleportPlayer)
Step 4: Create the Client Script
Create a teleport_on_map_click_c.lua file in the teleport_on_map_click directory with the following content:
lua
local screenX, screenY = guiGetScreenSize()
local mapX, mapY, mapWidth, mapHeight = 0, 0, 0, 0
function onClientMapStart()
showCursor(true)
mapX, mapY, mapWidth, mapHeight = getElementPositionSize(getMinimap())
addEventHandler("onClientClick", getRootElement(), onClientMapClick)
end
addEventHandler("onClientMapStart", getRootElement(), onClientMapStart)
function onClientMapStop()
showCursor(false)
removeEventHandler("onClientClick", getRootElement(), onClientMapClick)
end
addEventHandler("onClientMapStop", getRootElement(), onClientMapStop)
function onClientMapClick(button, state, absoluteX, absoluteY)
if button == "left" and state == "down" then
local relativeX = (absoluteX - mapX) / mapWidth
local relativeY = (absoluteY - mapY) / mapHeight
local worldX, worldY, worldZ = getGroundPositionFromProportionalCoordinates(relativeX, relativeY)
if worldX and worldY and worldZ then
triggerServerEvent("onPlayerMapClick", localPlayer, worldX, worldY, worldZ)
end
end
end
function getGroundPositionFromProportionalCoordinates(relativeX, relativeY)
local mapSize = 6000
local worldX = -mapSize + relativeX * mapSize * 2
local worldY = -mapSize + relativeY * mapSize * 2
local groundZ = getGroundPosition(worldX, worldY, 1000)
if groundZ then
return worldX, worldY, groundZ
else
return nil, nil, nil
end
end
Step 5: Start the Resource
Add the resource to your server by editing the mtaserver.conf file or using the in-game resource manager to start the teleport_on_map_click resource.
Explanation
Server Script (teleport_on_map_click_s.lua):
Defines a function teleportPlayer that teleports the player to the given coordinates.
Adds an event listener for the custom event onPlayerMapClick and binds it to the teleportPlayer function.
Client Script (teleport_on_map_click_c.lua):
Shows the cursor when the map is opened and hides it when the map is closed.
Listens for click events on the map.
Converts the click coordinates on the map to in-game world coordinates using a custom function getGroundPositionFromProportionalCoordinates.
Triggers a server event onPlayerMapClick with the world coordinates to teleport the player.
This script provides a basic implementation. Depending on your needs, you might want to add more features, such as error handling, user feedback, and more accurate coordinate conversion.
“code an MTA SA code to show the cursor when the map is opened, wait for a player to….” Conversation with mistral-large-2407, from the LMArena Human Preference 100K dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m8505bpnd1a1c8kasyy1m7t8