Page 1 of 1

Possibilities to store game data online (sql, ftp)

Posted: Fri Nov 23, 2012 9:24 am
by darkbasicer
Hi everyone,
this is my first post in this forum, so I hope to put this into the right section.

I'm looking for a nice solution to handle data for an online game. What I mean is a database holding global data like world-statistics and player information (not the general UDP/TCP-thing)


But first some words to my game:

I'm developing a turn based RTS
It is roughly based on advance wars which is a popular game by Nintendo.

What I've done so far is the game mechanics (building and moving units, attacking, terrain-dependent defense, animation, ...)
It is all working fine. There is online multiplayer, too. ;-)

Now I want to expand the game by adding MMO-functionality.
So where will be a big world map, where each player has it's own land (or more of them). If he wants to attack an enemy land, he sends a request and then the players can play online against each other (via TCP).
The winner takes the new land. There will be some restrictions, so it will be hard to manage many lands. I hope I can get some good balancing in there.


So what I'm looking for:
I want to store information about the lands, their ressources and which player currently owns them.
The data is updated after a whole battle. One battle will take around 20 min to 1 hour depending on the size of the map and the player's skills :)
It would also be nice to store all unit positions and properties after a player ends his turn, so players can save and pause to game during one session. This saving procedure would be called onces every one or two minutes.
The saved data should be accessable by all players.

I wanted to use a SQL-database hosted online, but I can't get the luasql library to work with löve.
I could create a php script and call it via http-request, but I thought there would be a nicer solution.

An other option would be to store everything in an XML-file or lua table and upload it via ftp. But when two players download and modify the file simultaniously, I have to check and merge the changes they did to the file.

Is there a better solution or has anyone figured out the sql thing and can provide the library he used?


Thanx for your effort! When I have some time, I will polish the game a little bit and introduce the current version here on the forums in the near future :)

Re: Possibilities to store game data online (sql, ftp)

Posted: Mon Nov 26, 2012 1:38 am
by Jamie
I'm not an expert with regard to luasql but it seems to be for establishing a direct connection to a database, i.e. if it's on the same machine or if you log in with a direct socket which is usually not permitted remotely because it's almost never the right solution. The direct database connection, if it were permitted, would use database credentials, which is usually one per application, not one per user, and offers no protection against seriously messing up your data.

I think you're going to have to use a php program and web requests. It shouldn't be too bad if you use JSON or some general purpose data language (XML could work too) so you don't have to parse and generate your own custom format. Most of the php work is going to be parsing and querying the database and existing libraries have those pretty well covered. There is a learning curve for them, but it will serve you well in other projects in the future too.

-Jamie

Re: Possibilities to store game data online (sql, ftp)

Posted: Mon Nov 26, 2012 11:24 pm
by monsieur_h
My two cents:
I'm not fond of your idea of saving once every two minutes on a remote server. If your game gets a little popular (and I wish you it will), it will be resource hungry for your server(s). I would advice to save it when the player leaves or, when the player wants to. Do you also want the server to actually host the games? Or is it only used as a backup to store scores and/or savedgames?

Apart from that, I guess that what you're looking for are webservices. It allows you to remotely send data in a language-agnostic way. It's mostly based over XML and/or JSON, and you can find an example of client-side Lua http://postneo.com/2006/10/05/web-servi ... on-and-lua. On the server side it's pretty much handled out-of-the-box by any "web" language. PHP, ASP.NET, Java, Python, whatever.

Hope this helps

Re: Possibilities to store game data online (sql, ftp)

Posted: Sat Jan 11, 2014 8:46 pm
by Overtorment
I would recommend CouchDB (a NoSQL database), as it has REST interface and basically can be accessed via plain HTTP.

Re: Possibilities to store game data online (sql, ftp)

Posted: Tue Jan 14, 2014 3:58 pm
by Lafolie
I'll just leave this here: viewtopic.php?f=4&t=20014&p=84933&hilit=%2AMMO%2A#p84933 (ignore the middle part about it being boring, it's more about the first/last paragraphs and link).

Re: Possibilities to store game data online (sql, ftp)

Posted: Tue Jan 14, 2014 5:27 pm
by Germanunkol
Lafolie wrote:I'll just leave this here: viewtopic.php?f=4&t=20014&p=84933&hilit=%2AMMO%2A#p84933 (ignore the middle part about it being boring, it's more about the first/last paragraphs and link).
While that post by Robin is very much worth a read, I'm not so sure it applies here.
For one thing, what the OP is doing is turnbased (which doesn't make it "easy", but takes away quite a few of the other problems real-time games have). For another, its multiplayer part is already working, which proves that he knows what he's talking about.
And last (but definately not least), what he's trying to do sounds much more like an interactive, and fun serverlist - and a serverlist is definately in the range of what's doable as an indie developper....

P.S.
I noticed the OP is from 2012... O.o
So it's kinda unlikely the OP will come back - seeing that he has only ever written one post.

For what its worth, the LuaSql plugin seems to be able to connect remotely:
http://help.interfaceware.com/kb/405