OnPlayerChangesProtectedData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Reverted edits by CoolDark (talk) to last revision by Srslyyyy)
Tag: Rollback
Line 11: Line 11:


==Example==
==Example==
The below example will ban all players who are trying to change protected element data.
This example will disconnect the suspected player from the server and display a warning about the teleport.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function processPlayerElementDataHack()
addEventHandler("onPlayerTeleport", root, function()
     addBan(source, "Element data hacking attempt")
     kickPlayer(source, "AC", "You were disconnected from the server for attempting to teleport. If this was a mistake, please contact the administration.")
end
end)
addEventHandler("onPlayerChangesProtectedData", root, processPlayerElementDataHack)


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

Revision as of 19:34, 29 January 2025

BETA: NEW FEATURE (BUILD: 1.6.0 r22790)
This event is triggered when a player tries to change protected element data. The server protects element data with using elementdata_whitelisted from mtaserver.conf and the clientChangesPolicy parameter in setElementData.

Parameters

  • element: The affected element.
  • key: The name of the element data entry that has changed.
  • value: The value that the player sends.

Source

The source of this event is the player who changes protected element data.

Example

This example will disconnect the suspected player from the server and display a warning about the teleport.

addEventHandler("onPlayerTeleport", root, function()
    kickPlayer(source, "AC", "You were disconnected from the server for attempting to teleport. If this was a mistake, please contact the administration.")
end)

See Also

Player events


Event functions