ID:1414588
 
(See the best response by Nadrew.)
If I had a single player game, where you could join a multi-player server with your single player character (Save system through mysql), would you need to be hosting your single player server for the save to be successful?

If you would, would you need to be able to host (where the server was joinable (obviously I would make it so even if it was hosted, anyone who joined would merely be spectators, or get kicked instantly))?

For example, you go through the story mode with your character in a single player mode, then at any point you could join a multi-player server to fight with other players (assuming it was a fighting game).

I do plan on starting a new project once I get everything planned exactly how I am going to do it (So try ensure it doesn't fail) so I would like accurate information please.

Cheers guys,

Howey
If the server exists and is hosted properly, there's no reason for you to host anything. You can just join that server (like you would any server) and load up your character from wherever it is, whether it's in some online database or in your own computer.
What I mean is there would be no server set up for the single player mode, you would simply download the host files to play the game.

To reword my question, would you be able to save to a mysql database if the user didn't click "host" and enter a port and stuff?

If they did, would they need to be portforwarded in order for them to save their game and the data to be transferred to the database?

The database would be on a web-server hosted by me (By me I mean I'd have a hosting plan with godaddy, lcn, or some other hosting company).
The only game server hosted by me would be like a "chat" game, you would join it, and basically just chat, with the ability to challenge other player to a fight.

If you accepted a challenge, the map and stuff would be shown and your character would be loaded from the database in order for you to fight.
Best response
You'd be able to save off-site regardless of if the game is being hosted or not, as long as the player has internet access.

Outgoing connections rarely need to be port-forwarded but usually need to be approved by the firewall if one is running.
Cheers Nadrew. That's the information I needed.
You should keep in mind though, you need to worry HEAVILY about security here, not just on the database end, if the person is hosting the world on their own computer they can literally alter anything they want if they really feel inclined to do so; meaning you have to make sure people can't just willy-nilly change things using memory editors and packet sniffers.

You also need to be careful about how you store your MySQL password, generally storing it as a plain-text string in your source is a bad idea, you need to write a function that generates the right password on the fly and doesn't keep that password in memory too long. Otherwise someone with a simple string extractor or memory editor might just extract your MySQL password/username and have a field day with the data directly.
Yeah I'd already thought about users using crap like CheatEngine and other programs to abuse their character.

Never thought about the mysql password though, I would of just shot that in there as a text string. Thanks I'll be sure to write a function to help security, and do some research on more security to try prevent extractors, etc..
If you do decide to include the mysql username/password, ensure your database security is setup.

#1 Create an account that can only access the objects needed for the game.

#2 Try to use routines rather than inline SQL. This will allow you to remove SELECT/INSERT/UPDATE permissions, and also validate the data before the updates are made.
Sort of on topic question, is there a way to check if the player has an internet connection when they Login? That way you can offer the player the choice of saving to the local computer or the database (not the latter if they have no connection obviously).

It's something I like about some of the flash games I've downloaded, of course most of them also check if you have an account on whatever site you got the game from (armorgames for example).
world.internet_address will be null (if I remember correctly) if there is no address.