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 trinitysj96 · Jan 27, 2013 at 08:08 AM · javascriptplayerprefsphpxp

trouble with db and playerPrefs

here is my script:

 private var secretKey="RomanIsGod"; // Edit this value and make sure it's the same as the one stored on the server
 var highscoreUrl="http://www.mysite.com/folder/game/file.php?";    
 
 var curExp : float;
 var maxExp : float;
 var level : float = 1;
 var expTexture : Texture;
 var w : float = 900;
 var style : GUIStyle;
 
 function Start() {
     SetPlayerName = PlayerPrefs.GetString("playerName");
     //style.normal.textColor = Color.yellow;
     //style.fontSize = 10;
     getScores(SetPlayerName);
     
 }
 
 function Update() {
     SetPlayerName = PlayerPrefs.GetString("playerName");
     getScores(SetPlayerName);
 }
 
 // Get the scores from the MySQL DB to display in a GUIText.
 function getScores(SetPlayerName) {
     var highscore_url;
     //var highscore_url = highscoreUrl + "name=" + SetPlayerName + "";
     Debug.Log (highscore_url);
     gameObject.guiText.text = "";
     hs_get = WWW(highscoreUrl);
     yield hs_get;
  
     if(hs_get.error) {
         print("There was an error getting the high score: " + hs_get.error);
     } else {
         gameObject.guiText.text = hs_get.text; // this is a GUIText that will display the scores in game.
         Debug.Log (hs_get.text);
         var getXP : int = hs_get.text.string;
         curExp = getXP;
     }
 }
 
 function OnGUI () {
         
     GUI.depth = 200;
     Debug.Log ("scores: " + getScores);
     GUI.DrawTexture(Rect(Screen.width / 2 - 450, Screen.height - 48, w *(curExp/maxExp), 30), expTexture);
 }
 
 function waitTen()
 {
     yield WaitForSeconds(10);
 }


the problem is here:

 var highscore_url;
 //var highscore_url = highscoreUrl + "name=" + SetPlayerName + "";

which is supposed to do:

 GUI.DrawTexture(Rect(Screen.width / 2 - 450, Screen.height - 48, w *(curExp/maxExp), 30), expTexture);

this is the line bar that shows your current level progress in xp.

when I change the the "highscore_url" to the one that sets the "SetPlayerName" line the whole thing breaks, and I am pretty good with php.. that part of the code and the database are fine and I get the return variables that I am looking for.

I am trying to set the curExp and the maxExp which come from the database as curExp/score and maxExp/level.

what am I doing wrong?

Comment
Add comment · Show 1
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 trinitysj96 · Jan 29, 2013 at 06:47 AM 0
Share

anyone want to take a stab at this?

0 Replies

· Add your reply
  • Sort: 

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

9 People are following this question.

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

Related Questions

Playerprefs not saving 1 Answer

How do you run multiple Playerprefs scripts (JS)? 1 Answer

UI Slider, Save Values and Change Them 0 Answers

How to save the best score 1 Answer

Highscoring and changing scripts (Java/UnityScript) 1 Answer


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