Tasharen Entertainment Forum
Support => TNet 3 Support => Topic started by: krvc on October 26, 2016, 07:07:20 AM
-
Hi, i connect to my project with TNAutoJoin. I change "public bool persistent" to "true";
I create 2 buttons - Set version and Get version. I save info TNManager.SetServerData, it saved, but all my players need to save data, and i change it to SetChannelData, it save too, but after i disconnect all data a missing.... (not saving)
using UnityEngine;
using System.Collections;
using TNet;
public class GameVersion : MonoBehaviour {
private int checkVersion;
//SET SERVER VERSION
public void SetServerGameVersion () {
TNManager.SetChannelData("game version", 20161026);
}
//GET SERVER VERSION
public void GetGameVersion()
{
checkVersion = TNManager.GetChannelData<int>("game version");
print(checkVersion);
}
}
-
Hmm.. i think i not needed all time save channel data in server.
I need added "IF" and check empty data or not when connect to channel, if empty then again Write.
Thanks.
-
SetServerData can only be called by the server's administrator. Channel data can be set by anyone in that channel.
You aren't actually specifying which channel to use there... TNManager.SetChannelData(channelID, "name", value) is what you should be using.
-
try to count players on channel or something else, but something wrong
int playersCounter;
playersCounter = TNManager.GetChannelData<int>(0, "playersOnServer") +1;
TNManager.SetChannelData(0, "playersOnServer", playersCounter);
print("1counterSet" + playersCounter);
playersCounter = TNManager.GetChannelData<int>(0, "playersOnServer");
print("2counterGet" + playersCounter);
print1 = 1 print2 = 0
-
I think i not connected... Try to set data after TNManager.JoinChannel(0, firstLevel, persistent, 10000, null);. Maybe TNManager.JoinChannel need time.
Thanks.
-
Of course it does. It's the case with every single TNet call. They are all delayed, never immediate. You need to wait for the channel join notification. Subscribe to TNManager.onJoinChannel.