Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
frqher wants to merge 2 commits into multitheftauto:master
base: master
Choose a base branch
Loading
from frqher:feature/server-positionchange-event

Conversation

@frqher
Copy link

@frqher frqher commented Aug 25, 2025

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.

...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).
Copy link
Contributor

MohabCodeX commented Aug 25, 2025
edited
Loading

I’m not sure, but isn’t onPlayerTeleport enough?
But maybe onElementPositionChange would be useful for general cases to deal with SetElementPosition

frqher reacted with thumbs up emoji

Copy link
Author

frqher commented Aug 26, 2025

I’m not sure, but isn’t onPlayerTeleport enough? But maybe onElementPositionChange would be useful for general cases to deal with SetElementPosition

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.

Copy link
Member

tederis commented Aug 26, 2025

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.

Copy link

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.

frqher reacted with thumbs up emoji

The onElementPositionChange event now receives both the old and new position of the element as arguments.
Copy link
Author

frqher commented Aug 26, 2025

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.

dasd

Copy link
Contributor

tzwer commented Aug 27, 2025
edited
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /