Items for an mmorpg

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

genar
Posts: 84
Joined: 13 Jul 2017, 11:49

Items for an mmorpg

Postby genar » 15 Mar 2018, 12:19

Hey there !

Im working on an mmorpg. Lately i introduced the inventory to my game. Players are now able to receive items by gathering resources for example. I store those items in an special database table, with a relation to the itemType ( if its a Axe, Sword, Wood, Stone etc ) and a relation to the player.

When the player logs in, i send the whole player inventory to him. When he gathers something, it will be added server side to his inventory.

Players should also be able to drop items... and thats the point where im stuck... how exactly should i handle such a case ? Even if the player logs out, or the server crashes or restarts, the items should persist, until a timer deletes them, or someone picks them up.

Do you guys have any idea how to deal with such an case ?
User avatar
Lapo
Site Admin
Posts: 20378
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Items for an mmorpg

Postby Lapo » 15 Mar 2018, 15:16

Hi,
you can use MMOItems to represent these objects that can be picked up and dropped in the map.
MMOItems are not persistent by nature but you can add this feature via server side code by storing the changes to the game map to a database or local file.

This could be done in multiple ways. Doing it on a per-item basis might require more resources, meaning that every item picked up or dropped would trigger a database call which can be expensive, especially at high loads with thousands of items etc...

Otherwise you could use a batching system where you store all of the changes since the last X minutes. You can also add a "shutdown hook" in your code to execute the database save when the server is being restarted or the JVM is stopped.
Bad crashes of the JVM might no trigger the hook, however. So if you need 100% consistency the per-item basis is probably necessary.

Does this help?
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 18 guests