Best way to handle in game items.

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

Moderators: Lapo, Bax

charris456
Posts: 16
Joined: 03 Feb 2012, 02:08

Best way to handle in game items.

Postby charris456 » 26 Feb 2012, 01:48

I'm about to get to the point where I'm going to need to setup items that have various values. I have a pretty good idea on how to handle them client side, but I was wondering what is the best way to handle them server side?

Here's the way I thought of having them..

1. Each item has an id.
2. A list of items are in the database (for easy adding, editing, and removing).
3. On server startup it would load these items and their various values, that way we're not making a call to the database everytime we need to get some info on items. (Would this kill the server if there were thousands of items?)
4. It would be preferable to have a way to get values about these items by doing something like: item(id).name, item(id).maxDamage, etc..

What is the best way performance wise to go about this, and to be able to get item values easily in different handlers.

Note: This not about an inventory for players. I'm trying to figure out a way to retrieve values for items that will be in the game. That way if I see a player has itemID 6 attached as their primary weapon, on the server I can do something like item(id).maxDamage to get the max damage for that weapon.

Thanks
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Best way to handle in game items.

Postby rjgtav » 26 Feb 2012, 18:20

Hi.
Well, it depends on what items you're going to store. For example, in a MMORPG, usually the items usually have some bonuses (which resulted from some kind of crafting) which are random and different from player to player. If your game will have items like that, so your strategy won't work, specially when you start having lots of different items with the same id, but different properties. In that case, you would have to create a special table on the database where you'd store each user's items, and load them when the user logged in.

If that's not the case, then yes, I'm pretty sure that's the way to go. You just have to store a List of items that would be accessible from all the game. You can check this chapter of the docs, as it explains 2 possible ways of achieving it.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
charris456
Posts: 16
Joined: 03 Feb 2012, 02:08

Re: Best way to handle in game items.

Postby charris456 » 26 Feb 2012, 21:00

rjgtav wrote:Hi.
Well, it depends on what items you're going to store. For example, in a MMORPG, usually the items usually have some bonuses (which resulted from some kind of crafting) which are random and different from player to player. If your game will have items like that, so your strategy won't work, specially when you start having lots of different items with the same id, but different properties. In that case, you would have to create a special table on the database where you'd store each user's items, and load them when the user logged in.

If that's not the case, then yes, I'm pretty sure that's the way to go. You just have to store a List of items that would be accessible from all the game. You can check this chapter of the docs, as it explains 2 possible ways of achieving it.


Thank you again rjgtav.

Yeah, I don't plan on any "specially crafted" bonuses to items, so that should work.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 109 guests