OnPlayerTeleport: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server event}} {{Added feature/item|1.6.1|1.6.0|22930|This event is triggered when a player's position changes significantly without being caused by setElementPosition.}} During each interval (''player_teleport_alert''), the server monitors player positions and checks for significant unexpected movements. If a player's position deviates beyond the defined threshold without using setElementPosition, this event will be fired. The threshold can...")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server event}}
{{Server event}}
{{Added feature/item|1.6.1|1.6.0|22930|This event is triggered when a player's position changes significantly without being caused by [[setElementPosition]].}}   
{{Added feature/item|1.6.1|1.6.0|22930|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.  
{{Note|The sensitivity threshold can be adjusted through the '''player_teleport_alert''' setting, which accepts values between 5 and 500 (default: 100).}}


During each interval (''player_teleport_alert''), the server monitors player positions and checks for significant unexpected movements. If a player's position deviates beyond the defined threshold without using [[setElementPosition]], this event will be fired. 
==Parameters==
<syntaxhighlight lang="lua">
float previousX, float previousY, float previousZ, float currentX, float currentY, float currentZ
</syntaxhighlight>


The threshold can be configured using ''player_teleport_alert'', which can be set between 5 and 500 (default: 100).
*'''previousX''': A [[float]] representing the player X-coordinate before teleporting.
 
*'''previousY''': A [[float]] representing the player Y-coordinate before teleporting.
==Parameters== 
*'''previousZ''': A [[float]] representing the player Z-coordinate before teleporting.
None 
*'''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==   
==Source==   
Line 16: Line 23:
Canceling this event has no effect.   
Canceling this event has no effect.   


==Example==
==Example==
<syntaxhighlight lang="lua">
This example logs unexpected teleportation events.
function handlePlayerTeleportCheat()
<syntaxhighlight lang="lua">
     outputChatBox("Stop teleporting!", source)
addEventHandler("onPlayerTeleport", root, function()
end 
     outputServerLog("Player "..getPlayerName(source).." teleported unexpectedly. Possible hack detected.")
addEventHandler("onPlayerTeleport", root, handlePlayerTeleportCheat)
end)
</syntaxhighlight> 


</syntaxhighlight>
{{See also/Server event|Player events}}
{{See also/Server event|Player events}}

Latest revision as of 20:04, 16 February 2025

BETA: NEW FEATURE (BUILD: 1.6.0 r22930)
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.

[[{{{image}}}|link=|]] Note: 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

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

Canceling

Canceling this event has no effect.

Example

This example logs unexpected teleportation events.

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

See Also

Player events


Event functions