- Home /
Not receiving exp
Hi guys, i created a database in a webhost and exp in it but it is bit retrieving my information.Here's my script.I get this error.
FormatException: Input string was not in the correct format System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Int32.cs:629) InternetCalls+c__Iterator2.MoveNext () (at Assets/Scripts/Level/InternetCalls.cs:87) Here's my script
public class InternetCalls : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void DoLogin(string User,string Pass)
{
WWWForm www = new WWWForm ();
www.AddField ("user", User);
www.AddField ("password", Pass);
WWW w = new WWW ("http://reactivestudios.comuv.com/login.php", www);
StartCoroutine (Login(w, User));
GetXp (User);
}
public void DoRegister(string User,string Pass, string Name)
{
WWWForm www = new WWWForm ();
www.AddField ("user", User);
www.AddField ("password", Pass);
www.AddField ("name", Name);
WWW w = new WWW ("http://reactivestudios.comuv.com/register.php", www);
StartCoroutine (Reg(w));
}
IEnumerator Reg (WWW w)
{
yield return w;
if(w.error == null)
{
//PlayerPrefs.SetString("name", User);
Debug.Log ("Working");
Debug.Log (w.text.ToString());
}
}
IEnumerator Login (WWW w, string User)
{
yield return w;
if(w.error == null)
{
if(w.text == "login-SUCCESS")
{
PlayerPrefs.SetString("name",User);
Debug.Log ("Working");
Application.LoadLevel(1);
}
}
else
{
Debug.Log ("Error:" + w.error.ToString());
}
}
public void GetXp(string User)
{
WWWForm www = new WWWForm ();
www.AddField ("user", User);
WWW w = new WWW ("www.reactivestudios.comuv.com/Exp.php",www);
StartCoroutine (Xp (w));
Debug.Log ("Got Exp");
}
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))
{
Debug.Log ("Getting xp Worked Stats");
PlayerPrefs.SetInt("xp",i);
Debug.Log ("Get xp Worked Stats");
}
else
{
Debug.Log("Parsing failed");
Debug.Log(w.text.Length);
}
}
}
}
Eventhough i set my exp in database to 100000 it give me debugs me the length of 169.thanks
NOTE: Someone else formatted your code, you should do it for yourself in the future.. so you know, people can read it.
Give a console read out of what is in w.text, also your line numbers(from the exception) aren't helpful when you don't include everything(like the using statements, etc).
The console tells me my exp but when it try set the player prefs it debugs parsing failed so it doesnt set it.
Thats not helpful, can you please give the literal value of w.text, the variable i would have been set before SetInt on the playerPrefs, something doesn't jive. All it takes for TryParse to fail are literal quotes, a space, etc... in w.text, is w.text in this context always a number but originally as a string?
Exact Copy Paste of the Error.There are a few spaces there.Is that why??
100000
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
UnityEngine.Debug:Log(Object)
<Xp>c__Iterator2:$$anonymous$$oveNext() (at Assets/Scripts/Level/InternetCalls.cs:100)
Sorry if im not giving the information correctly because i dont quite understand your comment.
Your answer
Follow this Question
Related Questions
Another error 0 Answers
Unexpected Token: if 2 Answers
ExpToLevel not increasing 0 Answers
unexpected Token error 1 Answer
WeaponScript not working 0 Answers