Hello @Samarium ,
I will try to explain it my best 😃
onLeave
hook breaks my game because when I add this then onLoad
works only at first join map.
onJoin
should work also when I leave the map and then return.
I assume it does not work because when I am adding onLeave
hook then default one is overwritten.
The default one is (found in the source):
// Hook: called by simple-room package
onLeave(player: RpgPlayer) {
this.removeObject(player)
}
so when I leave the map then this.nbPlayers is still 1
because the player object isn't removed.
And that's why onLoad
hook does not work anymore, because the map is not required to be reloaded.
I tried to add this.removeObject(player)
into my onLeave
hook, but this method is private in source 😥
Edit: without onLeave
hook, nbPlayer is still 1
setTimeout(() => {
console.log('onLeave', this.nbPlayers);
}, 0);
result: onLeave 0
@Samarium I see here a pattern with previous issues.