Display High Scores from the web
by Hitesh Patel · in Torque Game Builder · 10/26/2009 (9:02 pm) · 5 replies
With the help of www.garagegames.com/community/blogs/view/10202 I have managed to save high scores online. The scores for each level are saved and I can veiw the scores for each level in Internet Explorer by using http://mydomain.com/displayscore.php?Level=1. Now, how do I display the high score in my game. Also from the table i would like to get the top score for the current level and display it on the level.
#2
HTTP/1.1 200 OK
Date: Tue, 27 Oct 2009 20:28:20 GMT
Server: Apache
Cache-Control: no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform
Expires: Tue, 27 Oct 2009 20:28:20 GMT
Vary: Accept-Encoding,User-Agent
Pragma: no-cache
Content-Type: text/html
X-Cache: MISS from demil1.byetcluster.com
Transfer-Encoding: chunked
Via: 1.1 demil1.byetcluster.com:80 (Lusca/LUSCA_HEAD)
1
4
0
The data I want to use is in the second last line (4). How do I get this as and use it in TGB.
10/27/2009 (5:30 pm)
Thanks for the reply. I managed to retrieve some info from the web but when I do echo (%line) i get all this info:HTTP/1.1 200 OK
Date: Tue, 27 Oct 2009 20:28:20 GMT
Server: Apache
Cache-Control: no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform
Expires: Tue, 27 Oct 2009 20:28:20 GMT
Vary: Accept-Encoding,User-Agent
Pragma: no-cache
Content-Type: text/html
X-Cache: MISS from demil1.byetcluster.com
Transfer-Encoding: chunked
Via: 1.1 demil1.byetcluster.com:80 (Lusca/LUSCA_HEAD)
1
4
0
The data I want to use is in the second last line (4). How do I get this as and use it in TGB.
#4
1. In my php script I updated my echo line to echo ("Current HighScore is $thishighscore").
2. Then in my tgb script i did the following:
10/27/2009 (9:07 pm)
Wow that was a quick reply, thanks. I tried your method but it didnt work as each line is seperate line hence the wordcount returns the number of words in each line. After revisitng Willliams suggestion here is what i did.1. In my php script I updated my echo line to echo ("Current HighScore is $thishighscore").
2. Then in my tgb script i did the following:
function TCPScoreReciever::onLine(%this, %line)
{
if(firstWord(%line) $= "Current")
{
%myData = getWord(%line, 3);
echo (%mydata);
}
}
#5
Thanks
-Joe
04/01/2010 (10:35 am)
I've been toying with the idea of building a "high scores" service for game devs. It would provide an API that could be called from the game as well as the web. Would you find this useful, and if so, what kinds of features would you be looking for?Thanks
-Joe
Associate William Lee Sims
Machine Code Games
You'll probably want to use a different first word in your PHP file so that you can tell the difference between an upload and a download. (Or you can use a different class name that has its own code for "onLine".)