Search Unity

Best way to implement persistence on an existing server?

Discussion in 'Multiplayer' started by Addyarb, May 4, 2014.

  1. Addyarb

    Addyarb

    Joined:
    Mar 2, 2014
    Posts:
    43
    Hi Unity,

    I'm researching a way to implement persistence on a multiplayer game I have set up. I currently am using player prefs to store things like the player's skill point placement and their name when they log in, but I'm looking to store things like how much money they have, what weapons they've earned, and where they were when they last logged out. Is PlayerPrefs going to work with these bits of info, or should I switch to a PHP/MySQL setup? What are the advantages and disadvantages of doing so, what what are the limitations of PlayerPrefs?

    Also, can I create an account system like this? Obviously I'd hope to make a system where they can log-in from anywhere, and I don't think PlayerPrefs works like that unless it somehow knows the player by their name.
    Thanks for your thoughts!
     
  2. P_Hansson

    P_Hansson

    Joined:
    Jul 4, 2012
    Posts:
    31
    Whatever you do, do yourself a favor and choose a proper database system (regardless if it's an SQL or NoSQL database). PlayerPrefs has very clear limitations ;)
     
    Last edited: May 5, 2014
  3. Addyarb

    Addyarb

    Joined:
    Mar 2, 2014
    Posts:
    43
    Thanks for the reply, any suggestions on tutorials or how to go about implementing it? I'm kind of in the dark as of now since I don't know anything beyond monodevelop's versions of C# and JS.
     
  4. P_Hansson

    P_Hansson

    Joined:
    Jul 4, 2012
    Posts:
    31
    If you're an absolute beginner and don't have any specific performance requirements, you can probably pick whatever you like (e.g. some SQL variant) and do it for the learning experience. To be specific, you'd place your SQL client logic in your game server, because you don't want players having access to the database. There should be multiple SQL clients on the asset store. As for the database, you can either host your own or rent cloud service.

    Note for the future; if you need to have something that's guaranteed to scale to a huge number of players, it becomes a bit more complicated, in that case you need to spend some time doing research on performance/scalability issues of SQL and NoSQL.
     
    Last edited: May 6, 2014
  5. Erisat

    Erisat

    Joined:
    Jan 31, 2013
    Posts:
    88
  6. P_Hansson

    P_Hansson

    Joined:
    Jul 4, 2012
    Posts:
    31
    ^Works if you're content with keeping a normal file with limited amount of data that doesn't need to be indexed in particularly clever ways. It's already way better than PlayerPrefs since it's interchangeable. :)
     
  7. GetLitGames

    GetLitGames

    Joined:
    Sep 24, 2014
    Posts:
    11
    PlayerPrefs and XML files are editable by the user though, so not secure for any kind of multiplayer gaming (i.e. edit a file and give myself 1000000 dollars and every gun)
     
  8. 3D Omelette Studio

    3D Omelette Studio

    Joined:
    Oct 1, 2013
    Posts:
    130
    well, storing persistent data thru XML is very valid, in fact that is how some known mmorpgs store their data, but the xml data needs to be server side, not client side , being server side the user do not have a way to edit it and cheat.