-
-
Couldn't load subscription status.
- Fork 496
Add onElementPositionChange event to SetElementPosition for anti-cheat compatibility #4392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onElementPositionChange event to SetElementPosition for anti-cheat compatibility #4392
Conversation
...t compatibility This event allows anti-cheat scripts to distinguish between server-initiated and client-initiated position changes, preventing false positives when the server teleports players (e.g., for elevators or scripted events).
I’m not sure, but isn’t onPlayerTeleport enough?
But maybe onElementPositionChange would be useful for general cases to deal with SetElementPosition
I’m not sure, but isn’t onPlayerTeleport enough? But maybe
onElementPositionChangewould be useful for general cases to deal withSetElementPosition
onPlayerTeleport is indeed sufficient for detecting sudden (teleport-like) position changes, especially those initiated by the client.
However, an event like onElementPositionChange can be useful for more general cases, as it allows you to detect all position changes made via server-side scripts (e.g., when using setElementPosition). This is not limited to players, but can also apply to vehicles, peds, objects, etc.
Gamemode scripts shall not allow cheaters to call server-side setElementPosition. Otherwise it indicates that a gamemode was designed with mistakes. I personally don't like the idea of adding tons of events in trying to fix poorly designed scripts.
blonter
commented
Aug 26, 2025
There are multiple issues with onPlayerTeleport. It doesn’t trigger when it should, and when it does, it can still produce false positives. More info can be found on Discord. There’s been a lot of discussion about these problems there.
It’s important to ensure this event only triggers for element position changes initiated on the client side, since we trust the server.
Once everything is fixed, the current onPlayerTeleport should be marked as deprecated.
The onElementPositionChange event now receives both the old and new position of the element as arguments.
dasdGamemode scripts shall not allow cheaters to call server-side setElementPosition. Otherwise it indicates that a gamemode was designed with mistakes. I personally don't like the idea of adding tons of events in trying to fix poorly designed scripts.
This PR adds a server-side "onElementPositionChange" event to the SetElementPosition function.
Reason:
Some anti-cheat scripts detect large position changes as cheating, but do not distinguish between server-initiated and client-initiated changes. This causes false positives when the server teleports players (e.g., for elevators or scripted events).
How it works:
By triggering the "onElementPositionChange" event server-side, anti-cheat scripts can listen for this event and safely ignore position changes that originate from the server.
This improves compatibility with anti-cheat resources and prevents legitimate server-side teleports from being flagged as cheats.