Hello,
I have a JSON file for each of my MMORoom which contains the BattleGrids. A MMORoom is a zone (e.g. Forest) that can have one or more BattleGrids.
BattleGrids are basically an ID and a List<Cell>.
I'd like to store these data as persistant data in a MMORoom. The BattleGrids are not subject to change. They are manually defined in the Unity Editor, saved as JSON and now my goal is to export them to the server so the server knows about the map data.
BattleGrids are:
* Unique to a MMORoom
* One persistant BattleGrid (for monsters spawning, never destroyed) + other instances of the same BattleGrid every time a player starts a fight (otherwise, Cell at index 4 could be taken in another fight but not in ours).
* Used to spawn monsters on it when the server initializes (server-side extension)
* Sent to a player when he enters a fight with a monster
I've searched the forum and it looks like RoomVariables aren't the right place to place this data. Maybe I should place the JSON files in a folder under sfs2x/? Is there a built-in way to load JSON in the server-side extension?
Thank you for your help!
Kind regards,
Jihaysse
Where should I store MMORoom "config"?
Re: Where should I store MMORoom "config"?
Hi,
local file system or a database are probably the best options for storage.
As regards the API for local file system, you can just use Java standard API. Since JSON is text-based you can load the files using one of these code snippets:
https://howtodoinjava.com/java/io/java- ... -examples/
(NOTE: SFS2X uses Java 8 by default)
If you need to associate each JSON map file with an ID and store this data in the MMORoom object (for ease of access) you can do so by using the SFSRoom.getProperty() and SFSRoom.setProperty() methods (MMORoom is a subclass of SFSRoom).
These key/value pairs are server-side only, so they are accessible to your Extension code, but not to clients.
More on this:
docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSRoom.html
Cheers
local file system or a database are probably the best options for storage.
As regards the API for local file system, you can just use Java standard API. Since JSON is text-based you can load the files using one of these code snippets:
https://howtodoinjava.com/java/io/java- ... -examples/
(NOTE: SFS2X uses Java 8 by default)
If you need to associate each JSON map file with an ID and store this data in the MMORoom object (for ease of access) you can do so by using the SFSRoom.getProperty() and SFSRoom.setProperty() methods (MMORoom is a subclass of SFSRoom).
These key/value pairs are server-side only, so they are accessible to your Extension code, but not to clients.
docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSRoom.html
Cheers
Who is online
Users browsing this forum: No registered users and 52 guests