highscores

can i make highscores??
i think when is the end of game, scores are saved to file
is there any example of highscores?

Hi I making a High score based on Internet!

It using PHP!
Tested on B 2.25!!!

import urllib

cont = GameLogic.getCurrentController()
own = cont.getOwner()


if own.delay > 0.1:
	try:
		urllib.urlopen("http://yourpathtophp.php?score=10")
	except:
		print "Bad link or no conect!!! Pleasy try again" 	

if own.delay > 0.2:
	try:
		file = urllib.urlopen("http://yourpathtofile" ,"read+()")
		line = file.readline()
		print line
		own.delay = 0
	except:
		print "shit, not read!!!"

http://milisoft.czweb.org/odpad/score2.jpg

It work fine!!!
If you can PHP

PHP: for score!!!

<HTML>
<HEAD>
<TITLE>Top 10</TITLE>
</HEAD>
<BODY bgColor=#000000 leftMargin=0 text=#ffffff topMargin=0>
<p align="Left">
<?
$x=$_GET['x'];
$y=$_GET['y'];

$fw=fopen("last.txt","w");
fputs($fw,"$x",20);
fclose($fw);

#####################
#  Reading score  #
#####################

$fp=fopen("1.txt","r");
$a=fread($fp,6);

$fp=fopen("2.txt","r");
$b=fread($fp,6);

$fp=fopen("3.txt","r");
$c=fread($fp,6);

$fp=fopen("4.txt","r");
$d=fread($fp,6);

$fp=fopen("5.txt","r");
$e=fread($fp,6);

$fp=fopen("6.txt","r");
$f=fread($fp,6);

$fp=fopen("7.txt","r");
$g=fread($fp,6);

$fp=fopen("8.txt","r");
$h=fread($fp,6);

$fp=fopen("9.txt","r");
$i=fread($fp,6);

$fp=fopen("10.txt","r");
$j=fread($fp,6);

#####################
#   Readong names   #
#####################

$fp=fopen("1.txt","r");
fseek($fp, 6);
$an=fread($fp,10);

$fp=fopen("2.txt","r");
fseek($fp, 6);
$bn=fread($fp,10);

$fp=fopen("3.txt","r");
fseek($fp, 6);
$cn=fread($fp,10);

$fp=fopen("4.txt","r");
fseek($fp, 6);
$dn=fread($fp,10);

$fp=fopen("5.txt","r");
fseek($fp, 6);
$en=fread($fp,10);

$fp=fopen("6.txt","r");
fseek($fp, 6);
$fn=fread($fp,10);

$fp=fopen("7.txt","r");
fseek($fp, 6);
$gn=fread($fp,10);

$fp=fopen("8.txt","r");
fseek($fp, 6);
$hn=fread($fp,10);

$fp=fopen("9.txt","r");
fseek($fp, 6);
$in=fread($fp,10);

$fp=fopen("10.txt","r");
fseek($fp, 6);
$jn=fread($fp,10);

############################
# making string as Integer  #
############################

settype($a, "integer");
settype($b, "integer");
settype($c, "integer");
settype($d, "integer");
settype($e, "integer");
settype($f, "integer");
settype($g, "integer");
settype($h, "integer");
settype($i, "integer");
settype($j, "integer");
settype($x, "integer");

############################
# sort by score  #
############################

if ($x > $a) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $f;
	$f = $e;
	$e = $d;
	$d = $c;
	$c = $b;
	$b = $a;
	$a = $x;
	
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $fn;
	$fn = $en;
	$en = $dn;
	$dn = $cn;
	$cn = $bn;
	$bn = $an;
	$an = $y;

} 	

if (($x > $b) && ($x < $a)) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $f;
	$f = $e;
	$e = $d;
	$d = $c;
	$c = $b;
	$b = $x;
		
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $fn;
	$fn = $en;
	$en = $dn;
	$dn = $cn;
	$cn = $bn;
	$bn = $y;
}

if (($x > $c) && ($x < $b)) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $f;
	$f = $e;
	$e = $d;
	$d = $c;
	$c = $x;
			
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $fn;
	$fn = $en;
	$en = $dn;
	$dn = $cn;
	$cn = $y;
}

if (($x > $d) && ($x < $c)) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $f;
	$f = $e;
	$e = $d;
	$d = $x;
			
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $fn;
	$fn = $en;
	$en = $dn;
	$dn = $y;
}

if (($x > $e) && ($x < $d)) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $f;
	$f = $e;
	$e = $x;
			
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $fn;
	$fn = $en;
	$en = $y;
}

if (($x > $f) && ($x < $e)) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $f;
	$f = $x;
			
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $fn;
	$fn = $y;
}

if (($x > $g) && ($x < $f)) {
	$j = $i;
	$i = $h;
	$h = $g;
	$g = $x;
			
	$jn = $in;
	$in = $hn;
	$hn = $gn;
	$gn = $y;
}

if (($x > $h) && ($x < $g)) {
	$j = $i;
	$i = $h;
	$h = $x;
			
	$jn = $in;
	$in = $hn;
	$hn = $y;
}

if (($x > $i) && ($x < $h)) {
	$j = $i;
	$i = $x;
			
	$jn = $in;
	$in = $y;
}

if (($x > $j) && ($x < $i)) {
	$j = $x;
			
	$jn = $y;
}

######################
# Name  #
######################

fclose($fp);

#####################
# Writing Top 10   to HTML   #
#####################
echo '![menu.jpg](menu.jpg)

';
echo '<tr><td width="100%"><font face="Arial">   ' , $a," - ", $an , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $b," - ", $bn , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $c," - ", $cn , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $d," - ", $dn , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $e," - ", $en , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $f," - ", $fn , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $g," - ", $gn , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $h," - ", $hn , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $i," - ", $in , "</font></td></tr>
";
echo '<tr><td width="100%"><font face="Arial">   ' , $j," - ", $jn , "</font></td></tr>
";

#######################
# Writing Top 10        #
#######################
$fw=fopen("top.txt","w+");
fputs($fw,"t=",5);
fclose($fw);

$fw=fopen("top.txt","a");
fputs($fw,"$a",6);
fclose($fw);

$fw=fopen("top.txt","a");
fputs($fw," - $an",20);
fputs($fw,"
",2);

fputs($fw,"$b",6);
fputs($fw," - $bn",20);
fputs($fw,"
",2);

fputs($fw,"$c",6);
fputs($fw," - $cn",20);
fputs($fw,"
",2);

fputs($fw,"$d",6);
fputs($fw," - $dn",20);
fputs($fw,"
",2);

fputs($fw,"$e",6);
fputs($fw," - $en",20);
fputs($fw,"
",2);

fputs($fw,"$f",6);
fputs($fw," - $fn",20);
fputs($fw,"
",2);

fputs($fw,"$g",6);
fputs($fw," - $gn",20);
fputs($fw,"
",2);

fputs($fw,"$h",6);
fputs($fw," - $hn",20);
fputs($fw,"
",2);

fputs($fw,"$i",6);
fputs($fw," - $in",20);
fputs($fw,"
",2);

fputs($fw,"$j",6);
fputs($fw," - $jn",20);
fputs($fw,"
",2);

fclose($fw);

#######################
# Generating file #
#######################

$fw=fopen("1.txt","w");
fputs($fw,"$a       ",6);
fclose($fw);

$fw=fopen("1.txt","a");
fputs($fw,"$an           ",10);
fclose($fw);

$fw=fopen("2.txt","w");
fputs($fw,"$b       ",6);
fclose($fw);

$fw=fopen("2.txt","a");
fputs($fw,"$bn           ",10);
fclose($fw);

$fw=fopen("3.txt","w");
fputs($fw,"$c       ",6);
fclose($fw);

$fw=fopen("3.txt","a");
fputs($fw,"$cn           ",10);
fclose($fw);

$fw=fopen("4.txt","w");
fputs($fw,"$d       ",6);
fclose($fw);

$fw=fopen("4.txt","a");
fputs($fw,"$dn           ",10);
fclose($fw);

$fw=fopen("5.txt","w");
fputs($fw,"$e       ",6);
fclose($fw);

$fw=fopen("5.txt","a");
fputs($fw,"$en           ",10);
fclose($fw);

$fw=fopen("6.txt","w");
fputs($fw,"$f       ",6);
fclose($fw);

$fw=fopen("6.txt","a");
fputs($fw,"$fn           ",10);
fclose($fw);

$fw=fopen("7.txt","w");
fputs($fw,"$g       ",6);
fclose($fw);

$fw=fopen("7.txt","a");
fputs($fw,"$gn           ",10);
fclose($fw);

$fw=fopen("8.txt","w");
fputs($fw,"$h       ",6);
fclose($fw);

$fw=fopen("8.txt","a");
fputs($fw,"$hn           ",10);
fclose($fw);

$fw=fopen("9.txt","w");
fputs($fw,"$i       ",6);
fclose($fw);

$fw=fopen("9.txt","a");
fputs($fw,"$in           ",10);
fclose($fw);

$fw=fopen("10.txt","w");
fputs($fw,"$j       ",6);
fclose($fw);

$fw=fopen("10.txt","a");
fputs($fw,"$jn           ",10);
fclose($fw);
?>
</BODY>
</HTML>

I need read all file!

Sample for writing to server:

<?
$x=$_GET[x];
$y=$_GET[y];
$fr = fopen("$x.txt", "w");
$fw = fwrite($fr, "$y");
fclose($fr);

x = Text to write
y = Name of file

example : http://blender.borec.cz/multi/my.php?x=This_is_sample_text&y=my.txt
saved file : http://blender.borec.cz/multi/my.txt

Warning!!! Its realy harcore Method!!

i havent got server with php :frowning: :frowning: :frowning:

can i save to text file
i think only this… your nick and scores, for examle
asdf 2500
[in the next line ]googre 1500
[in next line of file] tgfff 1001
fff 654
rtdfh 653

only save nick and scores

???

Hey man! I use freehosting server and work nice!!!
For next line :

line1
line2
line3

if loded text into blender. Automaticaly repalce \ as new line!!!

Net wariant is :

[line1,line2,line3]

and reading as Array

line1=array[0]
line2=array[1]
line3=array[2]

Blender have many function for editing text!!!
Use your variant!

http://blender.borec.cz/multi/new.php?fname=score.txt&l1=howno&l2=neco&l3=bububu&l4=prodlajs&l5=neco

http://blender.borec.cz/multi/score.txt

<? 
$fname=$_GET[fname]; 
$l1=$_GET[l1];
$l2=$_GET[l2];
$l3=$_GET[l3];
$l4=$_GET[l4];
$l5=$_GET[l5]; 
$fr = fopen("$fname", "w"); 
$fw = fwrite($fr, "$l1
"); 
fclose($fr);
$fr = fopen("$fname", "a+");
$fw = fwrite($fr, "$l2
");
$fw = fwrite($fr, "$l3
");
$fw = fwrite($fr, "$l4
");
$fw = fwrite($fr, "$l5
");
fclose($fr);
echo "$l1";
echo "$l2";
echo "$l3";
?> 

i have php on lycos now.

you wrote:


import urllib

cont = GameLogic.getCurrentController()
own = cont.getOwner()


if own.delay > 0.1:
   try:
      urllib.urlopen("http://yourpathtophp.php?score=10")
   except:
      print "Bad link or no conect!!! Pleasy try again"    

if own.delay > 0.2:
   try:
      file = urllib.urlopen("http://yourpathtofile" ,"read+()")
      line = file.readline()
      print line
      own.delay = 0
   except:
      print "shit, not read!!!"

but where is a property with scores?

import urllib 

cont = GameLogic.getCurrentController() 
own = cont.getOwner() 


if own.delay > 0.1: 
   try: 
      urllib.urlopen("http://yourpathtophp.php?x=your_file&y=any to write") 
   except: 
      print "Bad link or no conect!!! Pleasy try again"    

if own.delay > 0.2: 
   try: 
      file = urllib.urlopen("http://yourpathtofile" ,"read+()") 
      line = file.readline() 
      print line 
      own.delay = 0 
   except: 
      print "shit, not read!!!"

with owner:

import urllib 

cont = GameLogic.getCurrentController() 
own = cont.getOwner() 


if own.delay > 0.1: 
   try: 
      urllib.urlopen("http://localhost/my.php?x=" + str(own.name) + "&y=" + str(own.score)) 
   except: 
      print "Bad link or no conect!!! Pleasy try again"    

if own.delay > 0.2: 
   try: 
      file = urllib.urlopen("http://localhost/" + str(own.name) ,"read+()") 
      line = file.readline() 
      print line 
      own.delay = 0 
   except: 
      print "shit, not read!!!"

Here is example *.blend

http://refraktorygames.unas.cz/MiliKiller/pyphp.zip