| View previous topic :: View next topic |
| Author |
Message |
dakota
Joined: 20 Feb 2007 Posts: 10
|
Posted: Tue Mar 27, 2007 11:10 pm Post subject: high score list |
|
|
hello,
How do you make a high scrore list for a flash game? Is it more secure to view the high score list in a swf file or in html? thanks |
|
| Back to top |
|
 |
|
|
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Wed Mar 28, 2007 11:25 am Post subject: Re: high score list |
|
|
Ive made highscore lists which are displayed in either html or swf, but both are relatively easy to hack (as my friend demonstrated). It passes the values to a php file which then adds the value to a SQL. I believe it is more secure to display them in flash because there is no addresses to give them a hint to where they are stored. I will dig the code out for you if you want?
Flabby Rabbit |
|
| Back to top |
|
 |
dakota
Joined: 20 Feb 2007 Posts: 10
|
Posted: Wed Mar 28, 2007 11:44 am Post subject: Re: high score list |
|
|
| that would be cool eh, as long as its easy coz ive tried other ones and failed. cheers |
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Wed Mar 28, 2007 11:57 am Post subject: Re: high score list |
|
|
Yeah i had that problem so i mixed to gether loads of tutorials. Do you have a SQL host?? If not i have another version that just runs on php, but you can only have a certain number of records.
Flabby Rabbit |
|
| Back to top |
|
 |
dakota
Joined: 20 Feb 2007 Posts: 10
|
Posted: Thu Mar 29, 2007 6:35 am Post subject: Re: high score list |
|
|
| yeah ive got that mssql manager |
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Thu Mar 29, 2007 5:29 pm Post subject: Re: high score list |
|
|
I will first show you the pure php one as the SQL takes longer to set up.
I cant remember where i got this code from or i would thank them, sorry .
You will first need a php file called scores.php, with the code:
| Code: |
<?php
$winscore - (int)$winscore
// Create a Blank File if it doesn't already exist
if (!file_exists($filename))
{
$file=fopen($filename, "w");
fclose ($file);
}
// Read the file in
$oscores = file ($filename);
$numreadin = count($oscores);
// Break out the data into a new 2-d array called $tscores
for ($i = 0; $i < $numreadin; $i++)
{
$g = unserialize($oscores[$i]);
$tscores[$i][0] = $g[0];
$tscores[$i][1] = $g[1];
}
// Fill in any missing data with none/0
for ($i = $numreadin; $i < $scoresize; $i++)
{
$tscores[$i][0] = 0;
$tscores[$i][1] = "AAA";
}
// Process the actions
// Insert a score/name
if ($action == "INSERT")
{
// Add name to end of list, and sort
$tscores[$scoresize + 1][0] = $winscore;
$tscores[$scoresize + 1][1] = $winname;
rsort ($tscores);
$file=fopen($filename, "w");
// Write them out
for ($i = 0; $i < $scoresize; $i++)
{
$st = serialize($tscores[$i]) . "\n";
fputs($file, $st);
}
fclose($file);
}
// Clear the list
if ($action == "CLEAR")
{
$k[0] = 0;
$k[1] = "none";
$ser = serialize($k);
$file=fopen($filename, "w");
for ($i = 0; $i < $scoresize; $i++)
{
$st = $ser . "\n";
fputs($file, $st);
}
fclose($file);
}
// Process the OUTPUT options
if ($viewtype == "HTML")
{
// HTML PAGE CREATED HERE
?>
<table cellpadding=2 cellspacing=2 border=0 width="152">
<tr align=center>
<th bgcolor="#000033"><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">#</font></th>
<th bgcolor="#000033"><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Name</font></th>
<th bgcolor="#000033"><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Score</font></th>
</tr>
<?
for ($i = 0; $i < $scoresize; $i++)
{
echo ("<tr bgcolor='#666666' align='center'><td><font size='2' face='Arial, Helvetica, sans-serif'>");
echo ($i + 1);
echo ("</font></td><td><font size='2' face='Arial, Helvetica, sans-serif'>");
echo ($tscores[$i][1]);
echo ("</font></td><td><font size='2' face='Arial, Helvetica, sans-serif'>");
echo ($tscores[$i][0]);
echo ("</font></td></tr>");
}
?>
</table>
<?
}
// FLASH DATA CREATED HERE
if ($viewtype == "FLASH")
{
for ($i = 0; $i < $scoresize; $i++)
{
echo ("NAME" . $i . "=");
echo ($tscores[$i][1]);
echo ("&SCORE" . $i . "=");
echo ($tscores[$i][0]);
echo ("&");
}
}
?> |
this will then need to be uploaded to your server along with a file called scores.sco, which is just a .txt with the extension changed to .sco:
| Code: |
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";} |
Flash time:
When the user submits a score they will click a button, with the code:
| Code: |
on (release) {
_root.scoretable.filename = "scores.sco";
_root.scoretable.scoresize = 10;
_root.scoretable.action = "INSERT";
_root.scoretable.viewtype = "FLASH";
_root.scoretable.winname = _root.name;
_root.scoretable.winscore = _root.score;
_root.scoretable.loadVariables("scores.php", "GET");
gotoAndStop("scores", 1);
} |
Change the GotoAndStop to where your highscores will be, then where you want the highscores to be viewed you have to create a movieClip with the variable name 'scoretable'. This movieClip must include 20 variable text boxes name 'NAME0' upto 'NAME9' and 'SCORE0' upto 'SCORE9'. This is abit time consuming, sorry. The last thing in flash is to put some code on that frame:
| Code: |
stop();
_root.scoretable._visible = "true"; |
This should now work as long as everything is uploaded to the same directory on your server. Hope this works, dont hesitate to ask any questions if you dont understand somthingl. I check posts most days so should be fairly quick response.
Flabby Rabbit |
|
| Back to top |
|
 |
dakota
Joined: 20 Feb 2007 Posts: 10
|
Posted: Fri Mar 30, 2007 8:01 am Post subject: Re: high score list |
|
|
| doesnt seem to be working yet. should there be some information in scores.sco if its to work? |
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Fri Mar 30, 2007 12:10 pm Post subject: Re: high score list |
|
|
.sco should have:
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
which is the default scores. |
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Fri Mar 30, 2007 8:47 pm Post subject: Re: high score list |
|
|
Also are you sure that the your scores and names are in the variables '_root.name' and '_root.score'? The second thing to try is to run the code and then check the .sco and see if nything has changed, if it has but isnt displaying in flash then there is somthing wrong with thte scoretable movie clip. If it hasnt changed then there is somthing wrong in the code. Check that then get back to me.
Flabby Rabbit |
|
| Back to top |
|
 |
dakota
Joined: 20 Feb 2007 Posts: 10
|
Posted: Fri Mar 30, 2007 10:07 pm Post subject: Re: high score list |
|
|
my variables are defintely _root.name and _root.score
i opened the score.sco and it was
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";}
a:2:{i:0;i:0;i:1;s:3:"AAA";} |
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Sun Apr 01, 2007 11:48 am Post subject: Re: high score list |
|
|
kk, try chaning the code:
_root.scoretable.loadVariables("scores.php", "GET");
Instead of putting scores.php put the absolute address of scores.php and the same with:
_root.scoretable.filename = "scores.sco";
Hopefully that will work
Flabby Rabbit |
|
| Back to top |
|
 |
dakota
Joined: 20 Feb 2007 Posts: 10
|
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Tue Apr 03, 2007 9:58 pm Post subject: Re: high score list |
|
|
Whats the address of the .sco file, i will try and add somthing to it. Ill also dig out the original tutorial and send it you.
Flabby Rabbit |
|
| Back to top |
|
 |
flabbyrabbit 500+ Club

Joined: 25 Jan 2007 Posts: 623 Location: Midlands, England
|
Posted: Tue Apr 03, 2007 10:35 pm Post subject: Re: high score list |
|
|
But on the other hand ive checked and there is no file 'www.famousconflicts.com/scores.php'??
Flabby Rabbit |
|
| Back to top |
|
 |
Ezdo 50+ Club
Joined: 19 Apr 2007 Posts: 53
|
Posted: Sun Apr 22, 2007 9:34 pm Post subject: Re: high score list |
|
|
| flabbyrabbit wrote: |
| Ive made highscore lists which are displayed in either html or swf, but both are relatively easy to hack (as my friend demonstrated). |
What a skilled individual!!
Ezdo |
|
| Back to top |
|
 |
|