Skip to content
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 event for players changing position (by a significant distance) #3293

Open
Dutchman101 opened this issue Jan 16, 2024 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@Dutchman101
Copy link
Member

Dutchman101 commented Jan 16, 2024

By having an event that fires when a player's GTA position changes by a significant distance that can't be traveled on foot or vehicle, it is possible to utilize additional script security (servers can check if a certain teleport is legitimate, by tracking legitimate uses of setElementPosition for players until the teleport is done)

Naming it onPlayerChangePosition would be misleading, as we can't make true to firing the event at literally every movement, such as walking or driving a car, because it would be super spammy. So, if we're doing this, we need to implement a limit to filter relevant position changes, like again: a significant distance that can't be traveled on foot or vehicle or rather, when the new player position is one that wasn't streamed in to them before. In case there's no way to check this server-side, this can be a simple number of typical streaming distance in GTA, after all the goal is approximation of what is to be seen as a significant distance travelled.

To convey that's what it is, and avoid a misleading event name, we may use something like onPlayerTeleport (open for suggestions)

By extension, it may be considered to add an event for all elements changing position, instead of just players. Or if it's better, one event for players and one event for vehicles.

Additional context

Note: im aware that there's ways to achieve it already, like using timers (or timers with coroutines) that store and check all player's positions. But it's not good for performance as well as unnecesarily complex to get it right, if we could just add an event for the purpose.

@Dutchman101 Dutchman101 added the enhancement New feature or request label Jan 16, 2024
@ffsPLASMA
Copy link

How about onElementSuspiciousMovement to account for players and vehicles.

Issues we have to account for:

  • Clients running on 3x gamespeed
  • Position change via setElementPosition
  • Modified vehicle handlings

@PlatinMTA
Copy link
Contributor

PlatinMTA commented Jan 16, 2024

  • Clients running on 3x gamespeed

We shouldn't trust clientsided functions. We should see if the server has changed the game speed tho. Same for the handlings since now they can be changed clientside as well.

@Dutchman101
Copy link
Member Author

Dutchman101 commented Jan 16, 2024

There was already some discussion in dev discord that led to better concepts like this:

a setElementThreshold function, e.g:

setElementThreshold(getPlayerFromName("dude"), "distancemove", 1000)
setElementThreshold(getPlayerFromName("dude"), "velocity", 360)

.. and likely some other useful threshold types.
To work with a new event onElementTriggerThreshold or onThresholdViolated

If this is what will be agreed upon, i can soon change OP or someone can write a better feature request concept in a new issue

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

No branches or pull requests

3 participants