In my script I have an int which equals 0. When a player connects if that int is still equal to 0 they send an RFC that is set to Target.AllSaved to set the int to 1.
Here's is my script:
using UnityEngine;
using System.Collections;
using System.IO;
using TNet;
public class MapLoader : TNBehaviour {
int intToSave;
void Start ()
{
InvokeRepeating("CheckConnection", 0, 2);
}
void CheckConnection ()
{
if(TNManager.isInChannel)
{
CancelInvoke("CheckConnection");
if(intToSave == 0)
{
print("intToSave has the default value");
tno.Send("SaveInt", Target.AllSaved, 1);
print("intToSave is now: " + intToSave);
}
else
{
print("intToSave is: " + intToSave);
}
}
}
[RFC]
void SaveInt (int number)
{
intToSave = number;
}
}
Here is what I want to happen:
- Player A connects and sets intToSave = 1
- Player A disconnects
- Player X connects later and can still see intToSave is = 1
Here is what actually happens:
- Player A connects and sets intToSave = 1
- Player A disconnects
- Player X connects later and intToSave is = 0 for some reason
It seems like the RFC to update intToSave gets deleted when the player that called it disconnects.
Any suggestions?
Thanks.