Open Dutchman101 opened 9 months ago
How about onElementSuspiciousMovement to account for players and vehicles.
Issues we have to account for:
- 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.
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
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.