Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: How to implement an online high score table?

  1. #1

    How to implement an online high score table?

    I wonder how to implement an online high score table. I think I could use a PHP script on the server side and communicate with my Pascal game. I have no clue about PHP, though. Has anyone a hint? Maybe even a ready-to-use script? Or am I totally wrong?
    Best regards,
    Cybermonkey

  2. #2
    I once did this for Alexland. Since I didn't really want to dwell into how to send proper HTTP requests and send data via POST, I used some unit for simple web fetching and passed all the data through GET. So it was kind like

    Unit.ConnectToSite('http://mysite.com');
    Unit.GetDocument('http://mysite.com/scores/mygame/script.php?data1=value1&data2=value2');

    I had three scripts on the server side:
    info.php - this one returned the modification date of the high-scores - no need to download them if nothing changed, eh?
    get.php - as can be guessed, this one returned the high-score table
    submit.php - used to send the scores

    Whereas what info.php and get.php should return is obvious, my submit.php returned one of the following:
    <a number> - means the score you submitted made it into the table and holds the <number> place
    sorry - the score did not make it to the table
    error - the score is lacking data or somehow else damaged
    gtfo - the score has already been submitted or it's checksum is wrong - you're probably cheating
    version - wrong game version

    'error' and 'version' could also be returned by info.php and get.php, to signalize errors.

    If you want, I could send You the script I used, of course after modyfing it a bit (so I won't give out much of the game ) and adding some comments.

  3. #3
    I think that's exactly what I need. If you would be so kind to send me the script(s), I'll be more than thankful.
    Oh, another question: on the Freepascal side, do you use Synaptic or anything else? (SDL_net?)
    EDIT: Sorry, I meant Synapse ...
    Last edited by Cybermonkey; 15-08-2012 at 01:15 PM.
    Best regards,
    Cybermonkey

  4. #4
    Sorry for the delay, I was a bit busy yesterday evening.

    http://svgames.pl/trash/netscores.zip
    I hope everything's commented clearly enough. As for the FP side, the game was made using SDL, so I went with SDL_net.

  5. #5
    Quote Originally Posted by Super Vegeta View Post
    Sorry for the delay, I was a bit busy yesterday evening.

    http://svgames.pl/trash/netscores.zip
    I hope everything's commented clearly enough. As for the FP side, the game was made using SDL, so I went with SDL_net.
    Okay, thanks a lot. I will have a look into it at this evening.
    Best regards,
    Cybermonkey

  6. #6
    Did you take security into account, so that not anyone can open the link and add nonsense-scores?

  7. #7
    In the downloadable script there's no such thing. In my game I used a simple hash that was calculated by the game and attached to the values sent, the script then calculated the hash again and checked if they matched.

  8. #8
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Very cool topic!

    If you had purchased a web hosting package you could use the domain and access the database server that the hosting uses. There are a lot of libraries that will allow you to access various database servers. PHP is not really necessary unless you want to add some interaction with the game it's self and a website. ie. displaying highscores or some kind of weekly or monthly stats on a site you designed for the game.

    You can however do a lot of neat things if you did setup a databse to receive data from your game such as hosting exciting screenshots from players once they hit a new top highscore and create user accounts for your game kind of like Blizzard does.

    Free hosting can be a problem if you want stability so you should consider the low cost of paying a more solid hosting provider if you try this option.

    Besides the web hosting options they do have other highscore/award system services for different platforms such as iOS, Mac OS X (with the new Mountain Lion 10.8 version) and Android. Using these would depend on the API or libraries they provide to developers to use. Only C-based headers/libraries would of course mean translation too.

    BTW Would anybody be interested in such a library/service if it were provided to Pascal game developers as a simple library file they could add to their games?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  9. #9
    Yes, I thought about using it on my web host (not free but paid).
    And I would be very interested in such a simple library!
    Best regards,
    Cybermonkey

  10. #10
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    To make your own custom you'd want to find a decent and easy to use library (no dynamic libraries if possible) for accessing a MySQL database from your webserver.

    What comes with the standard install of FPC?
    Jason McMillen
    Pascal Game Development
    Co-Founder





Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •