A plugin takes the example of backup and stores the data in MongoDB (https://docs.rpgjs.dev/plugins/title-screen.html)
But indeed, you have the freedom to take any type of database.
What you get back is a JSON. You can save it in the player's session.
You can have a "players" table with for example the following fields:
- id
- username
- email
- password
- data
1) You are free to create endpoints for account creation or login (with username, email, password)
Look at how the endpoints were created: https://github.com/RSamaium/RPG-JS/blob/v3/packages/plugins/title-screen/src/server/mmorpg/index.ts#L50
2) After the login, the identifier has been registered in a property of the player (in the following link, it is under a mongoId)
https://github.com/RSamaium/RPG-JS/blob/v3/packages/plugins/title-screen/src/server/mmorpg/index.ts#L115
The following logic is: either there is no data and we start on the starting map, or there is data and we use the .load()
method to load the player to its previous state (https://github.com/RSamaium/RPG-JS/blob/v3/packages/plugins/title-screen/src/server/mmorpg/index.ts#L116)
3) the save()
method has been overloaded, in order to save the new data in the database. you can do this very well with MYSQL:
UPDATE players SET data='<The json to save>' WHERE id=<player id>