collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 793
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: an alternative to smf Arcade Block  (Read 9376 times)

0 Members and 1 Guest are viewing this topic.

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
an alternative to smf Arcade Block
« on: December 05, 2008, 07:06:09 AM »
This is just a simple php code in which you can use to display some Games in the Arcade
we have to give the Names and Numbers of the Games wished to be displayed in the Block, I have chosen 3 games , but the code can be changed of course to display more games.
just add a php Block ,give it the name you wish and include the following Code
Code: [Select]
<?php
//// PROVIDE NAMES AND NUMBERS OF THE GAMES //////
$game1="Warehouse"$g1number=23;
$game2="Poux"$g2number=28;
$game3="zz_3_Foot_Ninja"$g3number=21;
/////////////// END //////////////////////////////
$directory=dir("Games") or die ("Error");
echo 
"<div style='margin-top:10px' align='center'>";
while(
$datei=$directory->read()){
if (
$datei=="." || $datei==".."){ continue; }; 
$directory2=dir('Games/'.$datei) or die ("Error");
while(
$datei2=$directory2->read()){
if (
$datei2=="." || $datei2==".."){ continue; };
if (
preg_match('/.gif/',$datei2)){
$subfolder="Games"."/".$datei."/".$datei2
$data=substr($datei2,0,-4);
$swfdata="Games"."/".$data."/".$data.".swf";
if (
$data==$game1 || $data==$game2 || $data==$game3){
$counter+=1;
if (
$data==$game1) { $gnumber=$g1number; };
if (
$data==$game2) { $gnumber=$g2number; };
if (
$data==$game3) { $gnumber=$g3number; };
echo 
"<div style='margin:5px'><a href='index.php?action=arcade;sa=play;game=$gnumber' >
<img src='
$subfolder' ><br>$data</a></div>";
} else { continue; }
}
}
}
echo 
"</div>";
?>


the Names and Numbers of the Games written above in the code should be changed according to your Games Names and Numbers ,  the Code is based on the fact that the
Games are stored in the 'Games' Folder , and it should have an swf data (flash File) and
also an image of the game with same Name in 'gif' .
if Someone clicks on the Games , it will be played or not played according to your Settings , for Guests and Members.

 

Offline hot rides

  • Semi Newbie
  • *
  • Posts: 42
    • Hot Rides Show & Cruise
Re: an alternative to smf Arcade Block
« Reply #1 on: December 05, 2008, 10:48:51 AM »
A random selection of games would be very nice, maybe when I'm not feeling lazy I can work on this

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #2 on: December 05, 2008, 03:21:14 PM »
Quote
A random selection of games would be very nice, maybe when I'm not feeling lazy I can work on this
Here is a Random Selection , which I have finished Today ..

Code: [Select]
<?php
//////////// CONNECTION TO DATABASE ////////////////////////
mysql_connect("localhost or Server ID","User ID ","Password") or die("Could not connect : ".mysql_error());
mysql_select_db("Database Name") or die("could not select database");

/////////// FINDING HOW MANY GAMES STORED //////////////////
$query mysql_query("SELECT * FROM smf_arcade_games"); 
$numberOfGames=mysql_num_rows($query); 
$numberOfGames=$numberOfGames-1;
/*echo 'Number of Games are : '.$numberOfGames."<br><br>"; */

/////////////////// RANDOM NUMBERS ACCORDING TO NUMBER OF GAMES ////////
srand(time());
$random1 = (rand()%$numberOfGames);
while(
1){
$random2 = (rand()%$numberOfGames);
if (
$random2!=$random1 ){
break;
}

};


while(
1){
$random3 = (rand()%$numberOfGames);
if (
$random3!=$random1 && $random3!=$random2 ){
break;
}
};

$i=-1$count1=0;
$ask=mysql_query("SELECT internalName FROM smf_arcade_games");
while(
$row mysql_fetch_array($askMYSQL_ASSOC)){
$i+=1
if (
$i==$random1){
$game1=$row[internalName]; $count1+=1;
}
if (
$i==$random2){
$game2=$row[internalName]; $count1+=1;
}
if (
$i==$random3){
$game3=$row[internalName]; $count1+=1;
}
if (
$count1==3){
break;
}
};

/////////////// GET THE GAMES IDs //////////////////

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game1'");
$row mysql_fetch_array($askMYSQL_ASSOC) or die (mysql_error());
$g1number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game2'");
$row mysql_fetch_array($askMYSQL_ASSOC);
$g2number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game3'");
$row mysql_fetch_array($askMYSQL_ASSOC);
$g3number=$row[ID_GAME];

//// Finding The Games in The Directory And Displaying Them /////////
$directory=dir("Games") or die ("Error");
echo 
"<div style='margin-top:10px' align='center'>";
$Dir1='Games/'.$game1.'/'.$game1.'.gif';
$Dir2='Games/'.$game2.'/'.$game2.'.gif';
$Dir3='Games/'.$game3.'/'.$game3.'.gif';

echo 
"<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=$g1number'>
<img src='
$Dir1' ><br>$game1</a></div>
<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=
$g2number'>
<img src='
$Dir2' ><br>$game2</a></div>
<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=
$g3number'>
<img src='
$Dir3' ><br>$game3</a></div></div>";

?>


Dont Forget to Insert The Server ID , User ID , Password and Database Name Above



« Last Edit: December 05, 2008, 04:15:19 PM by Nabil »

Offline hot rides

  • Semi Newbie
  • *
  • Posts: 42
    • Hot Rides Show & Cruise
Re: an alternative to smf Arcade Block
« Reply #3 on: December 07, 2008, 10:40:59 PM »
the db connection is uneeded and the $Dir is invalid if you installed the games with gamepack

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #4 on: December 08, 2008, 12:08:30 PM »
Quote
the db connection is uneeded

yes if there is a previous DB Connection , which I think there is in settings.php

Quote
the $Dir is invalid if you installed the games with gamepack
I'm supposing that every game has its own folder inside the 'Games' folder which is Standard I think , because if you use  the Upload Possibility within the Mod it will move the Game's zip data into the 'Games' Folder and unpack it there creating a normal folder of the Game inside the Games folder.


Offline hot rides

  • Semi Newbie
  • *
  • Posts: 42
    • Hot Rides Show & Cruise
Re: an alternative to smf Arcade Block
« Reply #5 on: December 08, 2008, 08:07:32 PM »
I understand that but I took the fast route and downloaded all the games from the arcade website in the gamepacks which installed 5-10 games at a time and created individual folders inside of a folder for each gamepack. Some how the standard arcade block with simpleportal can handle this. I will figure it out when I get on my other computer with the files.

Offline jb3398

  • Semi Newbie
  • *
  • Posts: 29
Re: an alternative to smf Arcade Block
« Reply #6 on: December 31, 2008, 10:22:10 PM »
I couldnt get the first php code to work. I renamed the games, however it the numbers i dont get. I checked my forum for game numbers and there is none.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: an alternative to smf Arcade Block
« Reply #7 on: January 01, 2009, 08:51:36 AM »
Add $db_prefix to globals and you can use db_query() function in your block codes; no need to re-connect to database.
And slowly, you come to realize... It's all as it should be...

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #8 on: January 01, 2009, 09:12:16 AM »
yes you can ignore the first 2 lines in the Code regarding DB Connection .

Code: [Select]
i dont get. I checked my forum for game numbers and there is none.
Every game has a Number but it is saved in the Data Base.

in order to let the above Code work you should customise the Code to suit your Directory where the games are stored , if the files are stored directly in the game's folder change :

$Dir1='Games/'.$game1.'/'.$game1.'.gif';
$Dir2='Games/'.$game2.'/'.$game2.'.gif';
$Dir3='Games/'.$game3.'/'.$game3.'.gif';


to

$Dir1='Games/'.$game1.'.gif';
$Dir2='Games/'.$game2.'.gif';
$Dir3='Games/'.$game3.'.gif';


the above Code is based on the fact that every Game has a .gif file with the same name as the .swf file.

3 games will be chosen randomly





« Last Edit: January 01, 2009, 09:17:33 AM by Nabil »

Offline jb3398

  • Semi Newbie
  • *
  • Posts: 29
Re: an alternative to smf Arcade Block
« Reply #9 on: January 01, 2009, 12:43:35 PM »
I applied the changes you stated, buy something went wrong, because the board message stated  could not connect. Im assuming to the database! In addition my entire portal home page only had the one arcade block. (as if the dimensions were so large it pushed or removed all other blocks.)

Can you check the following to see if I left something undone or incomplete.

<?php
//////////// CONNECTION TO DATABASE ////////////////////////
mysql_connect("localhost or Server ID","User ID ","Password") or die("Could not connect : ".mysql_error());
mysql_select_db("Database Name") or die("could not select database");

/////////// FINDING HOW MANY GAMES STORED //////////////////
$query = mysql_query("SELECT * FROM smf_arcade_games");
$numberOfGames=mysql_num_rows($query);
$numberOfGames=$numberOfGames-1;
/*echo 'Number of Games are : '.$numberOfGames."<br><br>"; */

/////////////////// RANDOM NUMBERS ACCORDING TO NUMBER OF GAMES ////////
srand(time());
$random1 = (rand()%$numberOfGames);
while(1){
$random2 = (rand()%$numberOfGames);
if ($random2!=$random1 ){
break;
}

};


while(1){
$random3 = (rand()%$numberOfGames);
if ($random3!=$random1 && $random3!=$random2 ){
break;
}
};

$i=-1; $count1=0;
$ask=mysql_query("SELECT internalName FROM smf_arcade_games");
while($row = mysql_fetch_array($ask, MYSQL_ASSOC)){
$i+=1;
if ($i==$random1){
$game1=$row[internalName]; $count1+=1;
}
if ($i==$random2){
$game2=$row[internalName]; $count1+=1;
}
if ($i==$random3){
$game3=$row[internalName]; $count1+=1;
}
if ($count1==3){
break;
}
};

/////////////// GET THE GAMES IDs //////////////////

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game1'");
$row = mysql_fetch_array($ask, MYSQL_ASSOC) or die (mysql_error());
$g1number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game2'");
$row = mysql_fetch_array($ask, MYSQL_ASSOC);
$g2number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game3'");
$row = mysql_fetch_array($ask, MYSQL_ASSOC);
$g3number=$row[ID_GAME];

//// Finding The Games in The Directory And Displaying Them /////////
$directory=dir("Games") or die ("Error");
echo "<div style='margin-top:10px' align='center'>";
$Dir1='Games/'.$donkeykong.'.gif';
$Dir2='Games/'.$duckhunt.'.gif';
$Dir3='Games/'.$invaders.'.gif';

echo "<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=$g1number'>
<img src='$Dir1' ><br>$game1</a></div>
<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=$g2number'>
<img src='$Dir2' ><br>$game2</a></div>
<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=$g3number'>
<img src='$Dir3' ><br>$game3</a></div></div>";

?>


Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #10 on: January 01, 2009, 01:19:39 PM »
you have to remove this
Code: [Select]
//////////// CONNECTION TO DATABASE ////////////////////////
mysql_connect("localhost or Server ID","User ID ","Password") or die("Could not connect : ".mysql_error());
mysql_select_db("Database Name") or die("could not select database");


and also you should not write this
Quote
$Dir1='Games/'.$donkeykong.'.gif';
$Dir2='Games/'.$duckhunt.'.gif';
$Dir3='Games/'.$invaders.'.gif';

but this (if the games gif files were directly saved in the Game's Directory )
Code: [Select]
$Dir1='Games/'.$game1.'.gif';
$Dir2='Games/'.$game2.'.gif';
$Dir3='Games/'.$game3.'.gif';

Offline jb3398

  • Semi Newbie
  • *
  • Posts: 29
Re: an alternative to smf Arcade Block
« Reply #11 on: January 01, 2009, 01:52:53 PM »
I followed your instructions and used that block and it kills my home page. It might be my theme that I am using. But when I apply that php block with the code following your instructions it doenst work. The arcade block wont show and all other blocks vanish.

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #12 on: January 01, 2009, 02:29:27 PM »
now we have to ask the following questions :
are you sure that there are Games Installed? , if yes are they saved in the table smf_arcade_games of your Database ?
'smf_arcade_games' is the Standard name where game's Names are stored .
if you have givin your smf prefix another name than the Standard prefix (smf_ ) then this Code wont work
look in your Data base and see if there is a table with the name  'smf_arcade_games' .
« Last Edit: January 01, 2009, 02:34:04 PM by Nabil »

Offline jb3398

  • Semi Newbie
  • *
  • Posts: 29
Re: an alternative to smf Arcade Block
« Reply #13 on: January 01, 2009, 02:40:26 PM »
no it is a different prefix

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #14 on: January 01, 2009, 02:46:31 PM »
what is the name of the Table where you games are saved in the Data base ?

Offline Saga

  • Semi Newbie
  • *
  • Posts: 6
    • Dream For Ever
Re: an alternative to smf Arcade Block
« Reply #15 on: January 02, 2009, 02:50:24 AM »
Thanks for this block !!
i've made some little change but it's working

is it possible to have more info in Arcade Block ?
top rated Games ?
last added Games ?

Offline Nabil

  • Full Member
  • ***
  • Posts: 110
  • SMF Version: 1.1.7
  • SP Version: 2.2.1
Re: an alternative to smf Arcade Block
« Reply #16 on: January 02, 2009, 06:55:32 AM »
Quote
is it possible to have more info in Arcade Block ?
top rated Games ?
last added Games ?


use this Code to add Total Games, Top Rated Game , Latest Game

Code: [Select]
<?php

/////////// FINDING HOW MANY GAMES STORED //////////////////
$query mysql_query("SELECT * FROM smf_arcade_games"); 
$numberOfGames=mysql_num_rows($query); 
$numberOfGames=$numberOfGames-1;
/*echo 'Number of Games are : '.$numberOfGames."<br><br>"; */

/////////////////// RANDOM NUMBERS ACCORDING TO NUMBER OF GAMES ////////
srand(time());
$random1 = (rand()%$numberOfGames);
while(
1){
$random2 = (rand()%$numberOfGames);
if (
$random2!=$random1 ){
break;
}

};


while(
1){
$random3 = (rand()%$numberOfGames);
if (
$random3!=$random1 && $random3!=$random2 ){
break;
}
};

$i=-1$count1=0;
$ask=mysql_query("SELECT internalName FROM smf_arcade_games");
while(
$row mysql_fetch_array($askMYSQL_ASSOC)){
$i+=1
if (
$i==$random1){
$game1=$row[internalName]; $count1+=1;
}
if (
$i==$random2){
$game2=$row[internalName]; $count1+=1;
}
if (
$i==$random3){
$game3=$row[internalName]; $count1+=1;
}
if (
$count1==3){
break;
}
};

/////////////// GET THE GAMES IDs //////////////////

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game1'");
$row mysql_fetch_array($askMYSQL_ASSOC) or die (mysql_error());
$g1number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game2'");
$row mysql_fetch_array($askMYSQL_ASSOC);
$g2number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game3'");
$row mysql_fetch_array($askMYSQL_ASSOC);
$g3number=$row[ID_GAME];

//// Finding The Games in The Directory And Displaying Them /////////
$directory=dir("Games") or die ("Error");
echo 
"<div style='margin-top:10px' align='center'>";
$Dir1='Games/'.$game1.'.gif';
$Dir2='Games/'.$game2.'.gif';
$Dir3='Games/'.$game3.'.gif';

//////////// Which one is Highly Rated /////////////////////
$searchedGame=""$rated=0;
$gamesdir1=opendir("Games");

while(
$file2=readdir($gamesdir1)){
if (
substr($file2,-3)!='swf') { continue; };
$thegame=substr($file2,0,-4);
$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$thegame'");
$row mysql_fetch_array($askMYSQL_ASSOC); $gameid1=$row[ID_GAME];
$ask1=mysql_query("SELECT rating FROM smf_arcade_rates WHERE ID_GAME='$gameid1'");
$row mysql_fetch_array($ask1MYSQL_ASSOC); $theRate=$row[rating];
if (
$rated<$theRate){$rated=$theRate$ratedGame1=$thegame$searchedGameid=$gameid1; }
};
closedir($gamesdir1); $Dir4='Games/'.$ratedGame1.'.gif';

/// The Last Game Added is in the Last Row of the Table ////////
$totalgames=$numberOfGames+1;
$ask=mysql_query("SELECT ID_GAME,internalName FROM smf_arcade_games LIMIT $numberOfGames,1");

$row mysql_fetch_array($askMYSQL_ASSOC); 
$latestGname=$row[internalName]; $latestGid=$row[ID_GAME];
$Dir5='Games/'.$latestGname.'.gif';

echo 
"<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=$g1number'>
<img src='
$Dir1' ><br>$game1</a></div>
<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=
$g2number'>
<img src='
$Dir2' ><br>$game2</a></div>
<div style='margin:10px'><a href='index.php?action=arcade;sa=play;game=
$g3number'>
<img src='
$Dir3' ><br>$game3</a></div>
<hr width='90%'>
<div style='margin:10px'>
<b>Total Games</b><br>
$totalgames</div>

<div style='margin:10px'>
<b>Top Rated Game</b><br>
<a href='index.php?action=arcade;sa=play;game=
$searchedGameid'>
<img src='
$Dir4' style='margin-top:5px'><br>$ratedGame1</a></div>

<div style='margin:10px'>
<b>Latest Game</b><br>
<a href='index.php?action=arcade;sa=play;game=
$latestGid'>
<img src='
$Dir5' style='margin-top:5px'><br>$latestGname</a></div>

</div>"
;

?>



if you want to display only the 3 information above then use this Code :
Code: [Select]
<?php

/////////// FINDING HOW MANY GAMES STORED //////////////////
$query mysql_query("SELECT * FROM smf_arcade_games"); 
$numberOfGames=mysql_num_rows($query); 
$numberOfGames=$numberOfGames-1;
/*echo 'Number of Games are : '.$numberOfGames."<br><br>"; */

/////////////////// RANDOM NUMBERS ACCORDING TO NUMBER OF GAMES ////////
srand(time());
$random1 = (rand()%$numberOfGames);
while(
1){
$random2 = (rand()%$numberOfGames);
if (
$random2!=$random1 ){
break;
}

};


while(
1){
$random3 = (rand()%$numberOfGames);
if (
$random3!=$random1 && $random3!=$random2 ){
break;
}
};

$i=-1$count1=0;
$ask=mysql_query("SELECT internalName FROM smf_arcade_games");
while(
$row mysql_fetch_array($askMYSQL_ASSOC)){
$i+=1
if (
$i==$random1){
$game1=$row[internalName]; $count1+=1;
}
if (
$i==$random2){
$game2=$row[internalName]; $count1+=1;
}
if (
$i==$random3){
$game3=$row[internalName]; $count1+=1;
}
if (
$count1==3){
break;
}
};

/////////////// GET THE GAMES IDs //////////////////

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game1'");
$row mysql_fetch_array($askMYSQL_ASSOC) or die (mysql_error());
$g1number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game2'");
$row mysql_fetch_array($askMYSQL_ASSOC);
$g2number=$row[ID_GAME];

$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$game3'");
$row mysql_fetch_array($askMYSQL_ASSOC);
$g3number=$row[ID_GAME];

//// Finding The Games in The Directory And Displaying Them /////////
$directory=dir("Games") or die ("Error");
echo 
"<div style='margin-top:10px' align='center'>";
$Dir1='Games/'.$game1.'.gif';
$Dir2='Games/'.$game2.'.gif';
$Dir3='Games/'.$game3.'.gif';

//////////// Which one is Highly Rated /////////////////////
$searchedGame=""$rated=0;
$gamesdir1=opendir("Games");

while(
$file2=readdir($gamesdir1)){
if (
substr($file2,-3)!='swf') { continue; };
$thegame=substr($file2,0,-4);
$ask=mysql_query("SELECT ID_GAME FROM smf_arcade_games WHERE internalName='$thegame'");
$row mysql_fetch_array($askMYSQL_ASSOC); $gameid1=$row[ID_GAME];
$ask1=mysql_query("SELECT rating FROM smf_arcade_rates WHERE ID_GAME='$gameid1'");
$row mysql_fetch_array($ask1MYSQL_ASSOC); $theRate=$row[rating];
if (
$rated<$theRate){$rated=$theRate$ratedGame1=$thegame$searchedGameid=$gameid1; }
};
closedir($gamesdir1); $Dir4='Games/'.$ratedGame1.'.gif';

/// The Last Game Added is in the Last Row of the Table ////////
$totalgames=$numberOfGames+1;
$ask=mysql_query("SELECT ID_GAME,internalName FROM smf_arcade_games LIMIT $numberOfGames,1");

$row mysql_fetch_array($askMYSQL_ASSOC); 
$latestGname=$row[internalName]; $latestGid=$row[ID_GAME];
$Dir5='Games/'.$latestGname.'.gif';

echo 
"
<div style='margin-top:-2px'>
<b>Total Games</b><br>
$totalgames</div>

<div style='margin:10px'>
<b>Top Rated Game</b><br>
<a href='index.php?action=arcade;sa=play;game=
$searchedGameid'>
<img src='
$Dir4' style='margin-top:5px'><br>$ratedGame1</a></div>

<div style='margin:10px'>
<b>Latest Game</b><br>
<a href='index.php?action=arcade;sa=play;game=
$latestGid'>
<img src='
$Dir5' style='margin-top:5px'><br>$latestGname</a></div>

</div>"
;

?>

« Last Edit: January 02, 2009, 04:49:33 PM by Nabil »

Offline FrizzleFried

  • Full Member
  • ***
  • Posts: 114
  • SMF Version: 2.0.5
  • SP Version: 2.3.5
Re: an alternative to smf Arcade Block
« Reply #17 on: April 04, 2012, 03:13:32 PM »
I hate to bump such an old topic but the code in the final reply appears to be for SMF 1.x?  It does not work in 2.0.2... would love to find something that does...

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: an alternative to smf Arcade Block
« Reply #18 on: April 04, 2012, 05:50:01 PM »
You do realise there is an arcade block already?
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast