ID:151562
 
So I was trying to concider what would be better.

I can either store all saveable varibles into list and upload them to their mysql database names, or to have a text string and load all the varibles into the same field and split them when the new mob is created.
I.e varname=amt;varname2=amt2

Which way (if either) would be the better way of doing this?

Another way would be to update the database as actions occour( such as save the players new level on levelup along with their stats. )

Thanks!

You'll want a mapping of one SQL table column per variable you want to save. The main issue with the list approach you're suggesting is querying by variables. For example if you have saving slots, you presumably have several rows in the table (mobs) that a given client (with key Stephen001 for example) can load. With a list you need to pull out all the rows and split them to see which saved mobs have a client of "Stephen001".

If it's one variable per column, then you can simply do:

SELECT * FROM player_mobs WHERE key = 'Stephen001';

Which will return you all the rows (mobs) that have a key of 'Stephen001'. SQL will do this oh so much faster than you can in SQL. The mapping also allows you do to neat things like check for unique names on new characters:

SELECT COUNT(*) AS existing_mobs FROM player_mobs WHERE name = 'SomeName';

If existing_mobs has a value that isn't 0, someone's already got that name.
In response to Stephen001
Edit: I get what you mean about sperate mapping, that makes sense.

would it be better to update them as they change, or periodically, or a mixture of both or even only on logouts.
In response to Pirion
Oh. Well, that's really up to you I guess. Do players stay logged in for long periods of time?
In response to Stephen001
Yes they would. So I guess that takes out only on logouts...

I guess I would have to do a little bit of testing to figure out how much of a diffence periodic saving and on update saving would make on the hosting server.
In response to Pirion
Updating when they change is probably too intensive, as I suspect you update some of the variables quite frequently. Periodically may be best.
In response to Pirion
Every five to ten minutes is generally an industry standard for intensive RPGs or the like. Every round is pretty standard for puzzle/action/RTS games.