Hi guys,i havee a script that takes xp from my database and just sets it on the player
public void GetXp(string User)
{
Debug.Log ("GetXp Successful");
WWWForm www = new WWWForm ();
www.AddField ("user", User);
WWW w = new WWW ("http://www.reactivestudios.comuv.com/Exp.php",www);
StartCoroutine (Xp(w));
}
IEnumerator Xp(WWW w)
{
yield return w;
if (w.error == null)
{
Debug.Log (w.text);
Debug.Log ("Working Stats");
int i;
if (int.TryParse(w.text, out i))
PlayerPrefs.SetInt ("xp",i);
Debug.Log("Set int xp");
}
else
{
Debug.Log ("Parsing Failed");
}
}
but i have a problem.I received the xp from the internet because i (debug.log) it (“Set int xp”)line 20)and it sets it as an int(line 19 i think so).But then my other script (rank manager) takes the int and set it as exp(line 9 and 53)But the one on line (53) does not (debug.log)"rankmanager getting int"line 54) and i think that is causing the problem that i cant set my exp but i dont have any idea why this is happening.please help.thanks
public int Exp;
public static RankManager Inst;
public int MaxLevel;
public WeaponManager Player;
// Use this for initialization
void Start () {
Debug.Log ("Getting xp");
Exp = PlayerPrefs.GetInt ("xp");
Debug.Log ("Got xp");
NextLevel = CurLevel + 1;
Inst = this;
}
// Update is called once per frame
void Update () {
if (NetworkManager.Instance.MyPlayer.PlayerName != "")
{
Player = NetworkManager.Instance.MyPlayer.Manager.FirstpersonCont;
foreach(Gun g in Player.Weapons)
{
if(CurLevel > g.UnlockLevel)
{
g.Unlocked = true;
}
else
{
g.Unlocked = false;
}
foreach(Sight s in g.Sights)
{
if(s.UnlockKills >= g.Kills)
{
s.Unlocked = true;
}
else
{
s.Unlocked = false;
}
}
}
}
if (CurLevel < MaxLevel)
{
if (Exp >= ExpToLevel)
{
CurLevel++;
ExpToLevel *= 2;
if(Network.peerType != NetworkPeerType.Disconnected)
NetworkManager.Instance.MyPlayer.Manager.networkView.RPC("UpdateRank",RPCMode.All,CurLevel);
PlayerPrefs.GetInt("xp" + NetworkManager.Instance.PlayerName, Exp);
Debug.Log("RankManager Getting Int");
}
}
}
}
I hope you guys understand my question.Thanks