Hi all.
I would like to host an online score directly from my website. So basically you have a high score and submit to site, then it gets updated. Voila! :enc:
I can read contents from the webpage with netwebget command but obviously not write to it.
Is this doable with Glbasic alone or do I need to bring in another programming language to the scene?
Also can scores be submitted to facebook, I'm pretty sure you need PHP or another appropriate language for this? though my main concern at the moment is the online score, and not the facebook part ! Any pro help is more than welcome.
Thanks all,
regards
-Joe
I did find an online hiscore routine on one of my backup disks - will have to find it :)
Its easy enough to send values using NETWEBGET$. However, communicating with Facebook is an unknown quantity - they provide examples for various languages, but to me, none of it makes much sense and it all looks overly complicated...
On my homepage there is examples for usage with PHP on a website. I also think there is something in the forums flying around.
the scramble example game does that. I think the php code is attached. No?
Hey all.
I have my scores in a.txt file on my webspace. "www.xxxxxxxx"
with netwebget I can read the file and output it from within Glbasic with no problems.
Now I want to write back to this .txt from Glbasic. How can I do this. netwebget just reads.
Thanks all
You would need some PHP code to update the text file using vales being passed.
Here is the code for an old one I used to use (requires a SQL database though) :
<html>
<head>
<title>Online Scoreboard For BallZ II - Nicholas Kingsley ©2008</title>
</head>
<body>
<?php
$name = $_GET['name'];
$score = $_GET['score'];
$typeOfGame=$_GET['type'];
$computerType=$_GET['os'];
$service = "localhost";
$username = "nicholaskingsle";
$password = "burpmachine12";
$database = "nicholaskingsle";
mysql_connect($service, $username, $password);
@mysql_select_db($database) or die( "Unable to select database");
if (($name != "") && ($score > 0))
{
$query="INSERT INTO BallZIITable VALUES (null, '$name', '$score',CURRENT_TIMESTAMP,'$typeOfGame','$computerType')";
$result=mysql_query($query);
echo("Score submitted! Name: $name, Score: $score");
}
$query = "SELECT * FROM BallZIITable ORDER BY score DESC";
$result = mysql_query($query);
$num = mysql_numrows($result);
?>
<table>
<tr class="header"><td>Pos</td><td>Name</td><td>Score</td><td>Type Of Game</td><td>Date Submitted</td><td>Operating System</td></tr>
<?php
$loopindex = 0;
while ($loopindex < $num) {
$thisname = mysql_result($result, $loopindex, "name");
$thisscore = mysql_result($result, $loopindex, "score");
$thisdate = mysql_result($result, $loopindex, "datesubmitted");
$thisTypeOfGame=mysql_result($result,$loopindex,"typeofgame");
$thisComputerType=mysql_result($result,$loopindex,"computertype");
$thispos = $loopindex+1;
echo ("<tr><td align=left><p>$thispos</p></td>
<td align=center><p>$thisname</p></td>
<td align=center><p>$thisscore</p></td>
<td align=center><p>$thisTypeOfGame</p></td>
<td align=center><p>$thisdate</p></td>
<td aligh=center><p>$thisComputerType</p></td></tr>\n");
$loopindex++;
}
?>
</table>
</body>
</html>
Thanks TAToad you always around hehe.
Ouch just what I feared!
Never used php or SQL. isn't there an easier way and why cant it be done with Glbasic :rant: its just something simple at the end of the day. Anyone please :P
Unless you can write your own program to run on the server - which wouldn't be a good idea anyway - PHP is the easiest way.
If you haven't used it before, just look online for a simple example of writing to a text file or MySQL database, then adapt it slightly to suit your needs. This is the easiest way as you can just call NETWEBGET to something like:
"www.mysite.com/newscore.php?Score="+Score"&Name="+Name$
It's what I did - borrowed the above code and modified it appropriately... With a bit of trial and error I managed to get it working.
In addition, this site (http://www.flashkit.com/tutorials/Games/High-sco-Glen_Rho-657/index.php) has some good ideas too
If this helps I've attached the code I've worked with.
'savescore.php' will write a first name, last name, time (aka. score of user), and time & date into a MySQL databse.
'listscore.php' will produce a comma delimited list with the values for each 'record' (aka. score) on a new line for your program to read.
'tablescore.php' produces a table of results from the data for viewing in a web browser.
In order to use these, you need to create a MySQL database with a table for highscores, and then modify 'savescore.php' to use the fields you've put in the database (i.e. change 'time' to 'score', remove date and time info, use 'name' instead of 'firstname' and 'lastname').
Then, you just need to change "$mysql_host" etc. to match your details.
That's about all I can say. Similar code could be used to save scores in a text file if you don't want to use MySQL, but I'm not sure how - my PHP knowledge is limited to what I've had to learn for highscores.
[attachment deleted by admin]
If you rather save to txt files on your host, then I can upload my files that I'm using for Hit the Deck Baseball.
One thing that has been forgotten is that if you add your program to the Showroom, KittyHello can provide a hiscore table for you.
Then all you would need to use is NETWEBGET$ to upload your hiscores