fivem-docs
fivem-docs copied to clipboard
Add playerEnteredScope/playerLeftScope examples
Adds the implementation examples to the OneSync guide.
These events notoriously are bad to use (bad performance), is it a good idea to publicly document them?
These events notoriously are bad to use (bad performance), is it a good idea to publicly document them?
You make a good point, although I think that depends on how the end user writes their implementation. If they write a for loop inside the handler to keep track of users in their scope, it's going to be non-performant, if they just use it to assign player related variables i.e. playerData[playerId].something = true
it may be ok.
Perhaps a word of caution should be added, stating that the method shouldn't be used to perform CPU-intensive operations (such as a for-loop) inside the handler(s) as it will lead to bad performance, for the simple fact that each handler will be triggered every time someone enters/leaves the scope.
Nice catch! 😊
I don't think the issue here is user implementation but the overhead of events, for larger servers using these no matter the circumstance can lead to weird performance issues.
Players should mostly be using state bags if they want to do stuff when a player enters another players scope.