Skip to content

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

MohabCodeX commented Aug 25, 2025

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

@frqher
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.

@tederis
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.

@blonter
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.

The onElementPositionChange event now receives both the old and new position of the element as arguments.
@frqher
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

@tzwer
Copy link
Contributor

tzwer commented Aug 27, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants