Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Albert-han · Jul 14, 2014 at 12:52 PM · errorunexpected

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.

Comment
Add comment · Show 14
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Landern · Jul 14, 2014 at 01:16 PM 0
Share

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).

avatar image Albert-han · Jul 14, 2014 at 01:32 PM 0
Share

The console tells me my exp but when it try set the player prefs it debugs parsing failed so it doesnt set it.

avatar image Landern · Jul 14, 2014 at 01:37 PM 0
Share

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?

avatar image Albert-han · Jul 14, 2014 at 02:09 PM 0
Share

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)
 

     
 
 



avatar image Albert-han · Jul 14, 2014 at 02:11 PM 0
Share

Sorry if im not giving the information correctly because i dont quite understand your comment.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Albert-han · Jul 15, 2014 at 03:57 AM

http://answers.unity3d.com/questions/748528/receiving-xp-but-not-setting-it.html new thread

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges