fivem-docs icon indicating copy to clipboard operation
fivem-docs copied to clipboard

Add playerEnteredScope/playerLeftScope examples

Open 4mmonium opened this issue 1 year ago • 3 comments

Adds the implementation examples to the OneSync guide.

4mmonium avatar Jan 29 '24 14:01 4mmonium

These events notoriously are bad to use (bad performance), is it a good idea to publicly document them?

AvarianKnight avatar Jan 29 '24 20:01 AvarianKnight

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! 😊

4mmonium avatar Jan 30 '24 15:01 4mmonium

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.

AvarianKnight avatar Feb 29 '24 22:02 AvarianKnight