Online High Score Table System

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by yavin.

If your working on a game project, is it near complete ?

Want to add an online high score table to your game ? it couldnt be simpler, all you have to do is be able to execute a website url and have the browser open it from your code.

If you can do this and want to have your verry own online high score table for your games then visit http://www.teamrebellion.co.uk/highscore/
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by vanleth.

I have been doing some Hiscore updating my self. Got it to work on my Test system, using PHP scripts and a little PB code.
The PB program sends a request to a php page called score.php. Score.php just create/update a file on the webhost. Simple approach.
Just can't get it to work on in a reallife test. Seem's that I'm stuck with the URI's to my webhost.

The PB code:

Code: Select all

InitNetwork()

EOL$ = Chr(13)+Chr(10)

Name$ = InputRequester("Input your Name", "Name:","") 
Score = Val(InputRequester("Input fake Score", "Score:", ""))
Note$ = InputRequester("Your victory note", "Note:", "")

ScoreString$="GET /score.php?name="+Name$+"&score="+Str(Score)+"&note="+Note$+" HTTP/1.0"+EOL$+EOL$
Length = MemoryStringLength(ScoreString$)
*Buffer = AllocateMemory(1, Length, 0)
PokeS(*Buffer, ScoreString$)

ConnectionID = OpenNetworkConnection("192.168.5.81", 80)
SendNetworkData(ConnectionID, *Buffer, Length)
end
The score.php code

Code: Select all


The showscore.php code

Code: Select all


Scores


\n";
print "\n";
while (!feof ($file)) {
  $name = fgets($file, 4096);
  $score = fgets($file, 4096);
  $note = fgets($file, 4096);
  print "$name$score$note\n";
}
print "\n";

fclose ($file);
?>

But to avoid this trouble, maybe it would be a good idea to look at your suggestion Yavin.
Any others have good ideas for doing server highscores?

Van

[EDIT]Brackets mismatch ect.[/EDIT]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by benny.

Hi,

I have a slightly simpler example ... and it seems to work.
The PB-Side looks like this:

Code: Select all

InitNetwork()

EOL$ = Chr(13)+Chr(10) 

    ConnectionID = OpenNetworkConnection("[url]http://www.yourhost.com[/url]", 80) 

    If ConnectionID 
      SendNetworkString(ConnectionID, "GET [url]http://www.yourhost.com/blabla.php?data=purebasic[/url] HTTP/1.0"+eol$) 
      SendNetworkString(ConnectionID, eol$) 
    EndIf 
   End

This just sends the string "purebasic" to your php-script called blabla.php !

The blabla.php script should look like this:

Code: Select all

 

This creates a file on your server called "blabla.txt" which contains the string "purebasic".
!!! Make sure before you run the script that you temporarily allow write access for creating the file blabla.txt on your server, otherwise it DOES NOT work !!!

Ok, hope I could help you a little...

Greetings, benny!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by vanleth.

ahhh solved my GET / HTTP/1.0 mystery with my own webhost. There server only accepts HTTP/1.1 and above statements. So if you can't get mine or benny's example to work, maybe it's because you need to do change the GET statement to

"GET /index.html HTTP/1.1" + EOL$
"HOST: http://www.domain.net" + EOL$
EOL$ + EOL$

A good link that explains the inner works of HTTP
[LINK]http://www.jmarshall.com/easy/http/[/LINK]

Best regards
Van
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by David.

Looks like somebody there is using PHP an a TXT system to store data. Well, if u have a MySQL database in ur server, try using it.. Cuz it's much better, and it's faster.

Cya.
David
Post Reply