Author Topic: Server-Side player.data sync  (Read 3782 times)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Server-Side player.data sync
« on: January 12, 2015, 04:31:52 AM »
im using the packaged TNetServer.zip as an authentication server.  works great!

after the player connects to the server and is authenticated, i would like to populate the player.data variable with player specific data.

i created a new packet that deals with this task nicely:

  1. //TNGameServer.cs
  2. case Packet.RequestLogin:
  3. {
  4.    //login verified
  5.  
  6.    //sync mysql data to player.data here
  7.  
  8.    //gold = 500;
  9.    //profession = "Wizard";
  10.    //etc
  11. }
  12.  

the end goal would be to access the data via:
(or the preferred method)

TNManager.playerDataNode.GetChild<int>("gold");

my question is, how do i set the player.data variable on the server?  and then, sync it to the player?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Server-Side player.data sync
« Reply #1 on: January 13, 2015, 05:20:02 PM »
You won't be setting it on the server. The client must be the one that sets it. When you receive OnNetworkConnect, do a TNManager.LoadFile to load a file where your player's data is stored. When you get the data back, use TNManager.playerDataNode = DataNode.Read(bytes, isBinary); followed by TNManager.SyncPlayerData();