gpt4 book ai didi

javascript - 意外的标识符 'hs_post'

转载 作者:行者123 更新时间:2023-12-03 04:35:01 25 4
gpt4 key购买 nike

我正在将 Unity 中的一些代码实现到我的学校项目中,以添加服务器端高分。 http://wiki.unity3d.com/index.php?title=Server_Side_Highscores

但是我的浏览器返回此错误 -语法错误:意外的标识符“hs_post”

我的项目的网址 https://oege.ie.hva.nl/~osengam001/grijptitus/

我的 JS 文件中的片段

var secretKey = "jonathantitus"; // Edit this value and make sure it's the same as the one stored on the server
var addScoreUrl = "https://oege.ie.hva.nl/~osengam001/grijptitus/php/addscore.php?"; //be sure to add a ? to your url
var highscoreUrl = "https://oege.ie.hva.nl/~osengam001/grijptitus/php/display.php";

function postScore(username, score) {
//This connects to a server side php script that will add the name and score to a MySQL DB.
// Supply it with a string representing the players name and the players score.
var hash = Md5.Md5Sum(username + titusGevangen + secretKey);

var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(username) + "&score=" + titusGevangen + "&hash=" + hash;

// Post the URL to the site and create a download object to get the result.
hs_post = WWW(highscore_url);
yield hs_post; // Wait until the download is done
if (hs_post.error) {
print("There was an error posting the high score: " + hs_post.error);
}
}

// Get the scores from the MySQL DB to display in a GUIText.
function getScores() {
gameObject.guiText.text = "Loading Scores";
hs_get = WWW(highscoreUrl);
yield hs_get;

if (hs_get.error) {
print("There was an error getting the high score: " + hs_get.error);
} else {
document.getElementById("beginTekst").innerHTML = hs_get.text; // this is a GUIText that will display the scores in game.
}
}

最佳答案

谢谢梅尔波梅内。只有 Firefox 支持使用 function 定义的函数中的 Yield。 ES6 需要 function* .

关于javascript - 意外的标识符 'hs_post',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43331302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com