Sure! Below is a PAWN script for SA-MP 0.3.7 that allows players to place a marker on the map, then use the /tpmark command to teleport to that location. The script is entirely in English and displays an on-screen message when the teleport is successful.
#include <a_samp>
// Arrays to store map marker coordinates for each player
new Float:MapClickX[MAX_PLAYERS];
new Float:MapClickY[MAX_PLAYERS];
new Float:MapClickZ[MAX_PLAYERS];
new HasMapMarker[MAX_PLAYERS];
// Called when a player clicks on the map
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
// Store the clicked coordinates
MapClickX[playerid] = fX;
MapClickY[playerid] = fY;
MapClickZ[playerid] = fZ;
HasMapMarker[playerid] = 1; // Set flag indicating the player has a marker
SendClientMessage(playerid, -1, "Map marker set.");
return 1;
}
// Command to teleport to the map marker
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/tpmark", cmdtext, true) == 0) // Check if the command is /tpmark
{
if(HasMapMarker[playerid] == 1) // Check if the player has set a map marker
{
// Teleport the player to the stored coordinates
SetPlayerPos(playerid, MapClickX[playerid], MapClickY[playerid], MapClickZ[playerid] + 1.0);
// Display a success message
SendClientMessage(playerid, -1, "Teleport successful!");
}
else
{
// Inform the player that no marker is set
SendClientMessage(playerid, -1, "You have not set a map marker.");
}
return 1; // Command processed
}
return 0; // Command not recognized
}
// Optionally, clear the marker data when the player disconnects
public OnPlayerDisconnect(playerid, reason)
{
HasMapMarker[playerid] = 0;
return 1;
}
Explanation:
How to use:
-
Place a Map Marker:
- Open the in-game map (typically by pressing
ESC and selecting the map).
- Click on the location where you want to teleport. This sets the map marker.
-
Teleport to the Marker:
- Type
/tpmark in the chat box.
- If successful, you will be teleported to the map marker location and receive the message "Teleport successful!".
- If you haven't set a marker, you'll receive "You have not set a map marker."
Notes:
- Make sure your server has the necessary permissions and that players are allowed to teleport.
- Adjust the
SetPlayerPos function as needed, for example, adding 1.0 to the Z coordinate to prevent spawning inside the ground.
- This script uses basic SA-MP functions and should work without additional includes or libraries.
Installation:
- Copy the script into your
.pwn file.
- Compile the script using the PAWN compiler (
pawncc).
- Run the server, and the script will be active.
Let me know if you need any further assistance or modifications!