Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.96 / 5.00 8,981 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.02 / 5.00 43,355 ViewsThis is a basic tutoarial using the following:
This is mainly an ActionScript tutorial, the PHP and MySQL part is minimized to "copy and paste"
Stages
1)Getting a server
2)Setting the files and writing them
3)Setting the actionscript
WARNING: This scoreboard tutorial will produce a working but hackable scoreboard, you'll need to protect it better if you want it practically used , I might write a follow up tutorial or I might get Denvish to :P
Getting a server
The first thing you need to do is get a server that supports both PHP and MySQL there are plenty of free servers providing these services and you shouldn't care about ADs since you aren't using the pages themselves (you're loading them directly to flash), if you want to get something professional you should get a payed server, 3qhost are fair and trustworthy (I used them twice) and apthosting are pretty good too.
Setting the script
This script will include 1 php file and 1 sql table, let's start with the tricky sql part, your host should have some form of SQL access (preferable CPanel with PhpMyAdmin which is best to use). connect to your SQL (as provided) and create a new scores table:
CREATE TABLE `scores` ( `name` VARCHAR( 30 ) NOT NULL , `score` INT NOT NULL , `id` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY ( `id` ) );
basically I created a table with a place for names and a place for scores, names are limited to 30 chars but you can use more if you'd like
now make sure you have the sql connection script ready, it's
mysql_connect(<server>,<username><userpass
>);
select_db(<database name>);
create a new php file, name it highscores.php or something similar, and put the following script in it, costumizable parts have <>'s
<?
$action=$_POST['action'];
echo "returned=1";
echo $_POST['lolk'];
function spitScores($n){
$result=mysql_query("SELECT * FROM `scores` WHERE 1 ORDER BY `score` DESC");
for($i=0;$i<10;$i++){
$row = mysql_fetch_array($result, MYSQL_BOTH);
echo "&row" . $i . "=" . $row['name'] . "&score" . $i . "=" . $row['score'];
}
}
function insertScore($name,$value){
if($value<100000){
mysql_query("INSERT INTO `scores` ( `name` , `score` , `id` ) VALUES ('$name', '$value', '');");
}
}
function clearDB(){
mysql_query("DELETE * FROM 'scores'");
}
if($action!=null){
mysql_connect(<server>,<username><userpass
>);
mysql_select_db(<database name>);
}else{
die ("I cannot find the action");
}
if($action=="view"){
spitScores(10);
}else if($action=="insert"){
$name=$_POST['name'];
$score=$_POST['score'];
$domain=$_POST['domain'];
//if(($domain=="http://www.gamesofgondor.c
om") || ($domain=="http://uploads.ungrounded.net")
){
insertScore($name,$score);
// }else{
// echo "Stop trying to cheat the system";
// }
}else if($action=="clear"){
$pass=$_POST['password'];
if($pass=="<myclearpasshere(give it to noone)>"){
clearDB();
}
}else{
"Please don't hack this, if scoring high REALLY means that much to you just email us and we'll give you a highscore, just don't be such a godamn lamer and ruin someone's hard work" ;
}
?>
once you have this code you're pretty much set, all you have to do is fetch the scores from flash...
you'll notice you have a domain check with a remark bound before it at a point, you can unremark it and alter it as you need
The Actionscript
You have 3 actions in this scoreboard script, view insert and clear, you only need to mess with view and insert, for example to insert a score you can do
action="insert";
name="Inglor"
score=2000;
loadVariablesNum("www.site.suffix/path/hig
hscores.php",1,"POST");
to view the scores you need to do
action="view";
loadVariablesNum("www.site.suffix/path/hig
hscores.php",1,"POST");
Again, this script is not secure, only use it for education and learning how highscores work, the view action loads the variables into _level1, toy with it to check the format, it loads 10 scores (configurable)
enjoy!
Great work! Too bad so many people are desperate for highscores though >:-(
Oh, and also check out AS: Load External Data/Cross-Domain for information about using cross-domain scoreboards. If you're planning on using a scoreboard in a Flash submitted to NG, it WON'T WORK unless you sort out the crossdomain.xml on the database domain.
At 8/26/05 05:27 PM, Denvish wrote: Cool. I've not used PHP much, but I wrote a tut for a Flash/ASP scoreboard
that's cute but ASP is dead :P
too bad i cant put php on freewebs. cuz i reeeeeaaly want to learn xml server crap with flash.
At 8/26/05 05:38 PM, ImpotentBoy2 wrote: too bad i cant put php on freewebs. cuz i reeeeeaaly want to learn xml server crap with flash.
go on [=Arroways!=] ^^
At 3/31/06 12:57 PM, Zielak wrote: go on [=Arroways!=] ^^
I bet he found a solution, that was like 7 monthes ago. :p
Doesn’t work.
Database remains empty after i press the button with the code, even in its original form.
I used the php code from some other tutorial and used Inglor’s AS. It now submits the score but the username is: _level0.post or undefined. So how do I fix this?
I have tried many methods and this is the last one:
on (release){
action= "insert";
userName = _parent.post_game.player_name;
myScore = _root.total_score;
loadVariablesNum("addScore.php",1,"POST");
}
“player_name” is the instance name of the player name input. “post_game” is the MC where the input box and the “send score” button resides.
Any suggestions?
alright, lets say that i have 20 dynamic text boxes, 10 named "name0" through "name9" the other ten "score0" though "score9" how do i take the data from the php file, and make the scores and names display in their desired text boxes?
At 1/15/07 03:12 AM, Inglor wrote: http://www.armorbot.com
you all get redeemed for free
Only those using MX+ :(
:::Electric Earth Collab:::::::::Review Request Club:::::::::NG Calendar:::::::::Life is a playground so get out and play.:::
At 5/30/06 09:35 PM, EclipseNine wrote: alright, lets say that i have 20 dynamic text boxes, 10 named "name0" through "name9" the other ten "score0" though "score9" how do i take the data from the php file, and make the scores and names display in their desired text boxes?
Why the heck did this never get answered?