Maybe using npm run dev
is the problem for that. If I reload the page works, but after some modifications in server I cant login again.
#update
After interact with some npcs and apply player.save()
, the error appears.
#update2
I save the state after update variable on disconnect and works. I will keep testing.
onDisconnected(player: RpgPlayer) {
player.setVariable('PLAYER_IN_GAME', false)
player.save()
},
#update3
Ok, after add some item to player the error appears. I don't know why.
I guess the error is something in the npm run dev
. Maybe after reload we need to disconnect all players before start again. This explain why, after reload, keep spawning players (freezed players).
#update4
Maybe we can fix this create another field to mongodb, like 'connected'.
const playerIsAlreadyInGame = user.connected
if (playerIsAlreadyInGame) {
throw new Error('PLAYER_IN_GAME')
}
And when connect, set to true and when disconnect or reload server, we set to false. Or, just let player login and connect, without this block.
Maybe just a notification mail like "another useragent/ip log to your account. You want to disconnect all and change password?".