Author Topic: SetServerData / GetServerData  (Read 2557 times)

IIIDeFeKtIII

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
SetServerData / GetServerData
« on: March 14, 2016, 06:51:27 PM »
I am confused on a few things and maybe how this should work. I have a scene with auto join.
In the OnConnect I am using TNManager.SetServerData("Example", 1);
 - Right now I have it setting as an int. Can it also be set as a string?

Then After it loads the new scene I am trying to grab this value with int myValue =  TNManager.GetServerData<int>("Example");
 - This always returns 0 instead of 1.

I guess I am confused as to where I would use GetServerData that is causing the problem? The biggest thing I am trying to do is set a variable that another player has access to and can see. Maybe this isn't the way to go?
« Last Edit: March 14, 2016, 07:16:24 PM by IIIDeFeKtIII »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SetServerData / GetServerData
« Reply #1 on: March 16, 2016, 08:25:53 PM »
Server data is global, and is server-wide -- and can only be set after you're connected to the server. In addition, only administrators can set this. As such, it's not recommended for what you are trying to do. For what you're doing, set the player data instead.

IIIDeFeKtIII

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: SetServerData / GetServerData
« Reply #2 on: March 17, 2016, 03:12:31 PM »
Can I set the other players data like broadcast to everyone else? Or will this only set that 1 players data that is setting it? Basically. There will only be 2 players available. The person on the tablet setting the data and the person on PC that needs to receive the info from the tablet player. If these two are the only ones in that channel would it be better to use SetChannelData if SetPlayerData is only setting the tablet players data?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SetServerData / GetServerData
« Reply #3 on: March 18, 2016, 05:40:17 PM »
No, each player can only set their own data. If you want to change some other player's data, send an RFC to that player and have that player change their own data as a result of that RFC.

You can certainly use SetChannelData, yes. Both players will be able to set that.