Author Topic: persisting player.id e.g. to to save position on server?  (Read 2138 times)

ricky

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 15
    • View Profile
persisting player.id e.g. to to save position on server?
« on: September 30, 2015, 12:54:18 PM »
Am i missing something extremely basic here or do I understand that the way TNet works out of the box, there is no saving position/etc of a player, if they disconnect/reconnect, the player will always get a new playerid when reconnecting to the server so their old SaveAll RFC will be lost.

If I want to persist that state, and save the player id, are there built in functions to do that?  Will the server also save the information permanently?

My idea setup is, make playerid SteamID, or subsstring of SteamID... however, it appears tnet always wants to create a new player.id on each client connection.  How can I search on the server, for a previous player id using an alias?  Right now, I just add player alias such as SteamID, but that obviously does nothing for a disconnect reconnect due to the playerid being new when client reconnects.

Where is the proper place to store these alias?  What functions should be called?  Will server save?  Client save?  Should I set playerid on the client, then connect like I set playername on the client?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: persisting player.id e.g. to to save position on server?
« Reply #1 on: October 01, 2015, 03:16:10 AM »
Have you tried TNManager.SetAlias(steamID)? :)

From the server's point of view, every connection is going to be unique. If you want to associate persistent data with players, it must come from the clients as clients are the ones that know what it is. If you simply want to associate a Steam ID with each player, just do it via TNManager.SetAlias(steamID) after establishing a connection. You can also store all kinds of data associated with each player that will be automatically shared with everyone else. For example: inventory / equipment information, achievements, talent specializations, etc. Simply have each player set their TNManager.playerDataNode values and sync it periodically via TNManager.SyncPlayerData().

Since it's a DataNode struct, you can save it/load it client-side by simply doing TNManager.playerDataNode.Write(...) and TNManager.playerDataNode = DataNode.Read(...).

P.S. Note that when you ban someone, all their aliases will be banned as well so make sure that they are unique for each player. In Windward I use Steam ID and machine ID as aliases (SystemInfo.deviceUniqueIdentifier).