IEnumerator DeletePreviousError() { string name = PlayerPrefs.GetString("error_on_delete_name"); int score = PlayerPrefs.GetInt("error_on_delete_score_A", 0); //int score_B = PlayerPrefs.GetInt("error_on_delete_score_B", 0); WWWForm form = new WWWForm(); form.AddField("playerName", name); form.AddField("score_A", score); form.AddField("game", WWWConfig.gameName); string stringHashed = CryptoUtilities.MD5Sum(WWWConfig.gameName + name + score.ToString() + WWWConfig.hashKey); form.AddField("hash", stringHashed); WWW answer = new WWW(WWWConfig.setHighscoresInactivesURL, form); // Wait until the download is done yield return(answer); if (!string.IsNullOrEmpty(answer.error)) { Debug.Log("Error downloading: " + answer.error);; } else { Debug.Log(answer.text); PlayerPrefs.DeleteKey("error_on_delete_score_A"); PlayerPrefs.DeleteKey("error_on_delete_score_B"); PlayerPrefs.DeleteKey("error_on_delete_name"); } }
// Use this for initialization IEnumerator Upload() { if (PlayerPrefs.GetInt("active_mode", 1) == 2) { highscore_url = WWWConfig.highscoreURL_B; scoreToAskFor = "highscore_b"; } playName = PlayerPrefs.GetString("name", ""); score = PlayerPrefs.GetInt(scoreToAskFor, 0); if ((playName != "") && (score != 0)) { // Create a form object for sending high score data to the server WWWForm form = new WWWForm(); // Assuming the perl script manages high scores for different games form.AddField("game", WWWConfig.gameName); // The name of the player submitting the scores form.AddField("playerName", playName); // The score form.AddField("score", score); // The hash string stringHashed = CryptoUtilities.MD5Sum(WWWConfig.gameName + playName + score.ToString() + WWWConfig.hashKey); form.AddField("hash", stringHashed); // Create a download object WWW download = new WWW(highscore_url, form); // Wait until the download is done yield return(download); if (!string.IsNullOrEmpty(download.error)) { Debug.Log("Error downloading: " + download.error); } else { Debug.Log(download.text); } } else { Debug.Log("PlayerName vacío o Highscore = 0"); } }