View Full Version : Internet high score list

01-06-2003, 05:40 AM
Anyone do this?

Would like to have the game post high scores to a website, anyone?

01-06-2003, 01:13 PM

Yup, I'm doing it in FreeStrike ( http://www.jdsgames.com/freestrike ). The highscore server has an option to gen html so that top ten scores can be viewed from the web. I had it working at one point but could not fig out the cache problem in Internet Explorer. I would always have to manually go in an clear the cache to see the updated scores. Anyone know a way to tell IE not to cache a page? Other than that little problem my net high score stuff works ingame and can work at the website as it just streams back to you the data and you display it like you need. Email me ( support@jarroddavis.com ) and I can send you the server code. Its just a small console app, works great for me.

01-06-2003, 03:06 PM
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">

Try both of these.

The first one makes the browser rerequest the document all the time, while the second prevents it from showing up in the cache. I don't really understand the difference of them myself, but if you put them both in your page, it surely will work :P (Oh ya, they gotta be placed inside the <head>..</head> tags :) )

Good luck :)

01-06-2003, 03:59 PM
Hi. Coolness. I will try this. Thanks man.

Harry Hunt
01-06-2003, 05:11 PM
Anyone do this?

Would like to have the game post high scores to a website, anyone?

Here's one way of doing this:

First of all, you need a webserver that supports either CGI, PHP, ASP or any other server-sided scripting language. MySQL or any other database server software running on your webserver is very helpful but optional.

Write a script in Perl/PHP/ASP/Cold Fusion/Whatever that accepts Query-string and processes them.

I'm only familiar with PHP so I can tell you how it works in PHP:

PHP handles query strings like this

score, name and password are available to your PHP script as variables which then allows you to store these in a highscore list. If you use MySQL, that's super easy. If you don't have access to a database, store the variables in a text file.

In your game, whenever you submit the scores to your website, use a HTTP component (for example the Indy HTTP client component) and "Get" your PHP script like this:


Make sure that you replace spaces (" ") with %20 or it may not work properly. For every score that you submit, "GET" th PHP script on your website once. Make sure you use a password system of some sort to protect the online scores from abuse. You may even want to encrypt the name and score.

To retrieve the online scores and display them within your program, write a server-sided script that opens your text-file or database table and simply lists it in a way that is easily to parse, like this:

The Uber-player#32452
John the cool guy#4242
Some guy#3232
Another guy#2424
Loser guy#13

Like this. When you use your HTTP component to "GET" that PHP script, it will return the list of scores as a string or TStrings.

It's really very straightforward.

Also, if you want people to view the highscores on your website directly, simply write a script that displays the scores from the text file/database in a nice way (e.g. in a table).

It's also a good idea to write the script in a way that it only allows a certain number of entries in the score list. This could be as low as 10 (top ten) and as high as 1000. Whichever you prefer. Your script would then check if a score submitted by your game is high enough to be listed in the high scores and then, if the list is long enough, remove the lowest score and insert the new score at the right position. This is very easy with MySQL and requires some array juggling if you are using text files.

If you don't know PHP/Java Servelets/ASP/Perl/Cold Fusion/Whatever, here's a very dirty way of doing the online high score thing that will definitely result in a lot of trouble...

Create a public FTP account on your webspace and store your high score list text file there. Your game will then use an FTP client component (-> Indy) to download that file, add a score to the list and then upload it again.
Problems: Easy to manipulate, creates conflicts when to people upload their scores at the same time, etc....