onPlayerTeleport | Multi Theft Auto: Wiki Skip to content

onPlayerTeleport

Client-side
Server-side
Shared

This event is triggered when a player's position changes significantly without direct server intervention, such as the use of setElementPosition. When the player synchronizes data with the server, the server monitors player positions to detect significant unexpected movements. If a player's position deviates beyond the established threshold without server functions like setElementPosition being used, this event will be triggered.

The sensitivity threshold can be adjusted through the player_teleport_alert setting, which accepts values between 5 and 500 (default: 100).

Parameters

float previousX, float previousY, float previousZ, float currentX, float currentY, float currentZ
  • previousX: A float representing the player X-coordinate before teleporting.
  • previousY: A float representing the player Y-coordinate before teleporting.
  • previousZ: A float representing the player Z-coordinate before teleporting.
  • currentX: A float representing the player current X-coordinate after teleporting.
  • currentY: A float representing the player current Y-coordinate after teleporting.
  • currentZ: A float representing the player current Z-coordinate after teleporting.

Source

element: The source of this event is the player who triggered the teleport detection.

Canceling

Canceling this event has no effect.

Code Examples

server

This example logs unexpected teleportation events.

addEventHandler("onPlayerTeleport", root, function()
outputServerLog("Player "..getPlayerName(source).." teleported unexpectedly. Possible hack detected.")
end)

See Also