Online High Score Table Tutorial

Learn how to make certain types of games and use gameEditor.

Online High Score Table Tutorial

Postby jimmynewguy » Mon May 02, 2011 9:03 pm

Okay this will walk you through a very simple way to create a text table that holds scores online.

*READ CAREFULLY THERE IS ONLY TEXT AS I'M TOO LAZY FOR PICTURES WITH WHAT TIME I HAVE*

oh and feel free to ask questions. ill do my best to make sure i didn't make any mistakes typing this

Make a free account here http://freehostingphpmysql.com/ with a free hosting plan and click on website manager in the top horizontal bar

from there you will see a side bar, click on My SQL Manager create a database name and password and remember it/write it down.

**Make sure you remember the full database number, not just the part you pick**

Click on the hyperlink that is your database number you just created and login using the database and password you just created

Once again, you will see your database number on the left hand side and click on it from here name your table "highscores" or something simple to remember and make the "number of fields" 3

**Picture shows this better than text, see it below**

in the first field put "Name" make it a "char" type "64" length "latin1-bin" collation
in the second put "Score" "BIGINT" type
in the third put "Id" "INT" type "UNSIGNED" attribute "auto_increment" for extras and pick the first radio button on the fire right

example.PNG


now return to the page where you signed up first and clicked on "website manage" and choose "subdomain manager" from the sidebar

simply create a subdomain and choose one of the dropdown options and remember this once again

now on the side bar go to file manager and click that folder that has your subdomain name

minimize your internet explorer and create a new text document

inside here put this code and we will change some lines
Code: Select all
<?
echo "<h5>High Scores</h5>";
$con = mysql_connect("fdb3.runhosting.com","databse","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("database", $con);
$result = mysql_query("SELECT * FROM highscores  ORDER BY Score  DESC LIMIT 10");
while($row = mysql_fetch_array($result))
  {
  echo $row['Name'] . " | " . $row['Score'];
  echo "<h5> </h5>";
  }

mysql_close($con);
?>

now find this line:
Code: Select all
 $con = mysql_connect("fdb3.runhosting.com","database","password");

and input your database number (the FULL one) and password. Also make sure the "fdb3" in the first quotes should be a 3 and not a 2 based on what it says next to your database in the "my SQL manager"

now find these lines:
Code: Select all
mysql_select_db("database", $con);
$result = mysql_query("SELECT * FROM highscores  ORDER BY Score  DESC LIMIT 10");

change the database to your FULL number and change where you see highscores to the name of your table

if you would like to have more than the top 10 change "LIMIT 10" to "LIMIT whatever number you want"

save this as a .php by using the drop down menu and choosing "all file types", and remember the name of it

open now another text document inside here put this code and we will change some lines again
Code: Select all
<?php

 $nam = $_GET["n"];
 $sco = $_GET["s"];

 $con = mysql_connect("fdb3.runhosting.com","database","password");
 if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 mysql_select_db("database", $con);
$result = mysql_query( "INSERT INTO highscores (Name, Score)
 VALUES ( '" . $nam . "', '" . $sco . "' ) " );

 mysql_close($con);
header( 'Location: http://yoursubdomain/1st_textdocument.php' ) ;
?>


now find this line:
Code: Select all
 $con = mysql_connect("fdb3.runhosting.com","database","password");

and input your database number (the FULL one) and password. Also make sure the "fdb3" in the first quotes should be a 3 and not a 2 based on what it says next to your database in the "my SQL manager"

next find these lines:
Code: Select all
 mysql_select_db("database", $con);
$result = mysql_query( "INSERT INTO highscores (Name, Score)

and change the "database" to yours and where you see "highscores" put whatever you named your table

finally find this line:
Code: Select all
header( 'Location: http://yoursubdomain/1st_textdocument.php' ) ;

insert your subdomain and the name of the 1st php text document you created accordingly

save this as a .php by choosing "all file types" when saving named whatever you would like

now return to your untouched internet explorer and upload both of the files

we can now test this to make sure it works before entering GE

http://highscore.mygamesonline.org/dbpost.php?n=Jimmynewguy&s=15000000
change the red to your subdomain and the blue to the name of the second text file and open this webpage, after a little bit of loading I should be on your highscore table with 15000000 points if not retrace this tutorial *carefully* until it does work

now open a .ged file

simply make a way to make score by acquired and a text actor that allows user input (i assume doing this is common knowledge? really shouldn't but this is a lot of typing....)

make a global inter "score" also that will hold the user score and a global string variable "texts"

now, where you want the player to be able to submit their score (mousedown for example)
put this code
Code: Select all
sprintf(texts, "your_subdomain/the_2nd_text_document.php?n=%s&s=%i", texts.text, score);
openUrl(texts);

Enter your subdomain and the name of the 2nd text document we created accordingly again

and test it out/have fun with it, maybe someone better with mySQL and php can throw out other ideas from this??

Anyways, if you get stuck post here and ill do my best to help out. view the example .ged too since i didnt explain well some things there...sorry about that and the fact this only being text will make it quite confusing.

Cheers!
Attachments
Test.zip
(96.54 KiB) Downloaded 627 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Online High Score Table Tutorial

Postby schnellboot » Mon May 02, 2011 10:38 pm

man this is kinda cool!
I had a similar idea using url based score system, but mine was with the GET function which was easy to fake
I'll definitely use this in my future projects
thanks for sharing +1
Last edited by schnellboot on Mon May 02, 2011 11:19 pm, edited 1 time in total.
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Online High Score Table Tutorial

Postby Game A Gogo » Mon May 02, 2011 11:16 pm

This is great! I bet Again will be all over this too!
+1 point again! I've already done it yesterday :P
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Online High Score Table Tutorial

Postby jimmynewguy » Mon May 16, 2011 11:20 pm

Thanks guys! Kinda hoped this would generate a little more "vibe" though :lol: Just want to see what people can do with it.
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Online High Score Table Tutorial

Postby tintran » Thu Feb 16, 2012 8:13 pm

the Submit doesn't do anything on my computer.
is it because i am running Linux(Fedora)? anyone else have the same problem?
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Online High Score Table Tutorial

Postby skydereign » Thu Feb 16, 2012 8:18 pm

Yeah, the openUrl function has to work for this to actually submit the score (which doesn't work for Linux).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Online High Score Table Tutorial

Postby Lacotemale » Fri Feb 17, 2012 3:19 pm

Yeah unfortunately the Linux version of GE needs alot of fixing! :roll:
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: Online High Score Table Tutorial

Postby ayu04 » Thu Mar 15, 2012 4:13 pm

Hello. Does the one that you made regarding the high score will be saved on the database online? Because Im trying to imitate what you are doing but there's no data like scores and name recording on my database?
ayu04
 
Posts: 20
Joined: Fri Nov 18, 2011 1:47 pm
Score: 0 Give a positive score

Re: Online High Score Table Tutorial

Postby tintran » Thu Mar 15, 2012 8:09 pm

When i was following this tutorial, i had to wait to a while before the my domain name became active and my pages started working.

I added an extra column in my table called "Game".

you're free to use my database for your game (just change the 'myFirstGame' to any game name you'd like)
here's the link:
http://hiscore.mygamesonline.org/insertgame.php?n=player2&s=30&game=myFirstGame

to delete all entries for a certain game just use this link
http://hiscore.mygamesonline.org/deletegame.php?game=myFirstGame
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Online High Score Table Tutorial

Postby tintran » Thu Mar 15, 2012 10:53 pm

to view top 100 high scores for a certain game use this link
http://hiscore.mygamesonline.org/fetch.php?game=myFirstGame

to view all entries for all games use this link
http://hiscore.mygamesonline.org/fetchall.php
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Online High Score Table Tutorial

Postby knucklecrunchgames » Wed Feb 05, 2014 8:23 am

I get an error here. what am I doing wrong?
http://knucklecrunchgameshighscores.atw ... s=15000000
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Online High Score Table Tutorial

Postby schnellboot » Wed Jul 29, 2015 7:48 am

schnellboot wrote:man this is kinda cool!
I had a similar idea using url based score system, but mine was with the GET function which was easy to fake
I'll definitely use this in my future projects
thanks for sharing +1


lol what did I say years ago
I talk about GET when this is actually using the GET method
i was so dumb back then hahaha
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest