-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|376|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Article Home -> Website Information


 
Jayenkai
Created : 22 August 2008
Edited : 02 October 2008

Online Highscores

How they work, and how to work them.

To create an online scoreboard for your own games.

Step 1.
Create a scoreboard.
Click here, stick in the details, submit.

Step 2.
Download this example.
Use the Highscores.bb file from it, and include it into your code.
You can also read through and try out the example... That's why it's there, after all!

Step 3
Define the following five globals at the top of your code.

These should point to the table's number, password, and encryption passes that you defined within it's settings. (The number's in the board's url!)
They'll also hold the table and MOTD if you have one.

Step 4
Give each player a (roughly!) unique number, and then try to keep hold of it for future reference!

You'll want to save this number somewhere safe, along with the player's highscore, and things like that.
You can use the Encrypt(Txt$,Hashkey$) and Decrypt(txt$,Hashkey$) functions to keep things relatively secure in your save files.
The point of this number is to (hopefully!) stop a single player from flooding the scoreboards.
It should do the trick, but if not, you can easily edit the current board using it's edit page.

Step 5
When ready, retrieve the scoreboard.

The Returned string will be a "|" seperated list of names and scores.
You can use the SplitText() function to split this up. (See the included example for more details)

Notes

Try not to overdo the connecting stuff. If you make it a "Click here to check online" thing, then it'll help to stop Socoder from getting overwhelmed!

Also, if your scoreboard goes overboard (I'll be checking!) I might have to stop you from using it!

There's some kind of super-weird issue with spaces inside the encrypt/decrypt function, when you save/load data. Probably best not to let the player use any!

 

Comments


Saturday, 23 August 2008, 07:36
flying_cucco
A cobra version, with some changes. The network code and parser rewritten, SplitText dropped in favour of a linked list table, and player ID generation has been simplified.

|edit| Encrypt/Decrypt port provided by Hoboben and now working (thanks!) |edit|

Highscores.cps


Test.cps

Saturday, 23 August 2008, 07:49
Tikihead
Well this should make Wednesday Workshops and such a bit more fun. Nice, Jay.
Saturday, 23 August 2008, 12:16
HoboBen
Nice one, cucco!

Hey Jay - is there a way to delete scoreboards? Mine is messed up!
Saturday, 23 August 2008, 14:51
Jayenkai
Yeah, I can delete them for you, don't worry.

Well done Cucco, assuming that works, can't tell.
I was very very very very tempted to buy a copy of Cobra, yesterday, but you did it for me, so no need now


(PHP Version, Updated to Method 1 Encryption)



That should* be a nice working PHP version of the basic encrypt/decrypt stuff.
If you'd like to use that to create your own scoreboard script, or whatever, then feel free. (Not that you have to, of course!)

* It's mostly a copy+paste, but I had the two functions using global variables, writing to them, and returning int variables instead of the strings.. So, I might've messed up in the tweaking! It's untested!

|edit| Although, Hobo, you can EDIT the scoreboard, and empty the text box that contains the scores..!.. or.. you should be able to, anyway! |edit|
Sunday, 24 August 2008, 09:03
JL235
I'll take a look at making a Java port.
Friday, 05 September 2008, 04:40
Jayenkai
To get the scoreboards working in BlitzMax, throw in these functions.
(Updated to work with Encryption Method 1)

Works in exactly the same way as the BB example, so you still use the same globals and SubmitHighscores(Name+"|"+Number+"|"+Score) setup to send and receive things..



I've included the bit of code from the BB.com code snippets, purely because it actually works!
Thursday, 02 October 2008, 07:15
Jayenkai
OK, Whole thing rejiggered for extra encryption.
The topmost download now contains an updated edition of the highscores.bb file, and it's functions with smush data much more cryptically!

I've also updated the PHP and BlitzMax code posts to work with the new versions.

Cucco and Hobo can fight over who does the Cobra one, 'cos I haven't a clue what I'm doing in that!