Heres some code for a block to display some games from the arcade.
Copy/paste the code in to a phpblock and uncomment the query you want to use, or add 5 blocks, or chop it up to display them all in one block :)
Includes queries for -
Latest games
Most played games (one score versions only)
Least played games (one score versions only)
Best rated games
Longest champ games
global $scripturl,$db_prefix,$modSettings;
//number of games to show
$no=10;
echo '<div align="center">
<table cellpadding="2" cellspacing="5">
<tr>';
//uncomment the query you want to use below
//show the latest games
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY id DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//show most played games (one score version only)
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//show least played games (one score version only)
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//show best rated games
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY rating DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//games with longest champs
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY champion_time ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" title="'.$game['name'].'"/></a>
</td>';
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
AH, saw this on a site yesterday, was about to ask how the did that, but i guess this is the answer :)
Thank you eeek :)
Thanks for sharing eeek
Very cool! I don't use the arcade myself, but I sure know a lot of others do. Thanks for sharing. I'll go add this to the list in the sticky.
Wow cool, thank you very much! ;)
very very cool
is there a way to display the names of the people for "longest held titles" ?
Thanks eeek, I like the idea,Ã, just been having a fiddle with it.
A couple of problems .....
It only displays gif's, some game icons are jpg's.
In a side block the icons don't wrap.
See attached screenshot from IE, in FF & Opera the overflow doesn't move the centre across.
1.3.0RC1+Mods+1Score+2in1, TP 0.95 beta & 1.1 RC3
Quoteis there a way to display the names of the people for "longest held titles" ?
Theres always a way :) and it aint that difficult but thats the one that costs the most overhead, the way it is just now its 1 query. If you want usernames then for 10 games it costs at least 10 more queries every time the page loads and gives you info that is in the statistics page if anyone really wanted to see it. Without going off on a tangent here..this info like champ name, thumbnail and anything else that requires processing should be added to the table when the info is created -process once instead of everytime its needed - the table would be bigger but the arcade would be more efficient.
Its easy to add anything thats in the "Games" table at no extra cost though like Highest Score or in the one score version Number of Plays. To have it display on mouse over modify the title tag in the code like
title="'.$game['name'].' played'.$game['plays'].' times'"title="'.$game['name'].' - score to beat'.$game['champion_score'].' are you up to it? '"QuoteIt only displays gif's, some game icons are jpg's.
All mine are gifs :) the easy answer rename them to gif Im sure it will work.
QuoteIn a side block the icons don't wrap.
I have it in a center block :) You want them to stack one wide move the <tr> and </tr> inside the while loop, html aint my strong point :)
The next plan is to make it random, using all the choices so each time you get something different, like latest games, champs, rated etc.
I think for a sideblock the best compromise is to limit the number to 2. Don't know if that was the intention, but the icons didn't have the game name displaying, so I had a fiddle.
This is the code I have for a side block and attached is the screenshot.
global $scripturl,$db_prefix,$modSettings;
//number of games to show
$no=2;
echo '<div class="smalltext" align="center" valign="top">
<table cellpadding="2" cellspacing="5">
<tr>';
//uncomment the query you want to use below
//show the latest games
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY id DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//show most played games (one score version only)
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
//show least played games (one score version only)
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//show best rated games
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY rating DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
//games with longest champs
/*
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY champion_time ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
*/
while($game = mysql_fetch_array($result))
{
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" /></a><br />
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">'.$game['name'].'</a>
</td>';
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
Ok fiddlers heres Version 2 :)
All the choices in one block. it will pick a random choice of which one to display. <- its random so you might get the same one twice in a row!!
copy all the code below to one phpblock
---------------------------
see next post :)
And version 3
choose how many icons wide - can be used in a side block or a centre block
//number of games to show
$no=10;
//number if icons accross
$icons_per_row = 5;
//do NOT use function 4 and 5 if you have a multi score version of the aracde
// change "rand(1,5);" to "rand(1,3);" on the next line.
$random_games_choice = rand(1,5);
//----------------------------------------------------------------------------
$games_choice = 'games'.$random_games_choice;
$curr_position = 0;
$games_choice($no,$curr_position,$icons_per_row);
Function games3($no,$curr_position,$icons_per_row)
{
global $scripturl,$db_prefix,$modSettings;
//show the latest games
echo '<div align="center">Latest Games<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY id DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" title="Play '.$game['name'].'"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games5($no,$curr_position,$icons_per_row)
{
//show most played games (one score version only)
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Most Played<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" title="'.$game['name'].' played '.$game['plays'].' times"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games4($no,$curr_position,$icons_per_row)
{
//show least played games (one score version only)
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Least Played<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" title="'.$game['name'].' only played '.$game['plays'].' times"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games2($no,$curr_position,$icons_per_row)
{
//show best rated games
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Top Rated<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY rating DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" title="Play '.$game['name'].'"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games1($no,$curr_position,$icons_per_row)
{
//games with longest champs
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Longest Champs<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY champion_time ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="60" height="60" title="'.$game['name'].' - Can you become champ?"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Thank You eeek , i will surely gonna try it :)
That is super eeek, thanks :up:
Thats great. Thanks eeek
Been fiddling again ;D
This is probably more of use to peeps who also have an Arcade as opposed to an Arcade and Games site. As it is below is for a side block, I have stitched eeeks code together with the code from the Top Scores block and reduced the size of the icons.
(geeky bit ;) I renamed the high scores $no to prevent a duplication)
Put it into a php block.
//Arcade Games Info
//Devised by eeek for use with Tiny Portal.
//number of games to show
$no=10;
//number if icons accross
$icons_per_row = 5;
//do NOT use function 4 and 5 if you have a multi score version of the aracde
// change "rand(1,5);" to "rand(1,3);" on the next line.
$random_games_choice = rand(1,5);
//----------------------------------------------------------------------------
$games_choice = 'games'.$random_games_choice;
$curr_position = 0;
$games_choice($no,$curr_position,$icons_per_row);
Function games3($no,$curr_position,$icons_per_row)
{
global $scripturl,$db_prefix,$modSettings;
//show the latest games
echo '<div align="center">Latest Games<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY id DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="20" height="20" title="Play '.$game['name'].'"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games5($no,$curr_position,$icons_per_row)
{
//show most played games (one score version only)
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Most Played<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="20" height="20" title="'.$game['name'].' played '.$game['plays'].' times"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games4($no,$curr_position,$icons_per_row)
{
//show least played games (one score version only)
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Least Played<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY plays ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="20" height="20" title="'.$game['name'].' only played '.$game['plays'].' times"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games2($no,$curr_position,$icons_per_row)
{
//show best rated games
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Top Rated<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY rating DESC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="20" height="20" title="Play '.$game['name'].'"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
Function games1($no,$curr_position,$icons_per_row)
{
//games with longest champs
global $scripturl,$db_prefix,$modSettings;
echo '<div align="center">Longest Champs<br />
<table cellpadding="2" cellspacing="5">
<tr>';
$sql = "SELECT * "
. "FROM {$db_prefix}games "
. "ORDER BY champion_time ASC , name ASC LIMIT 0,{$no}";
$result = db_query($sql,__FILE__,__LINE__);
while($game = mysql_fetch_array($result))
{
if($curr_position == $icons_per_row)
{
echo '</tr><tr>';
$curr_position=0;
}
echo'
<td>
<a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id'].'">
<img src="'.$modSettings['arcade_games_url'].'/'.$game['game'].'.gif" border="0" alt="'.$game['name'].'" width="20" height="20" title="'.$game['name'].' - Can you become champ?"/></a>
</td>';
$curr_position++;
}
mysql_free_result($result);
echo '
</tr>
</table></div>';
}
echo '<hr>';
//Arcade High Scores
// -- SETUP EDITS ---
$db_prefix = 'local_'; //edit this to your your database prefix - usually smf_
$chno = 5; //number of top players to show
// --LANGUAGE EDITS --
$txtplay = "The Top Players";
$txtwin = "Highest Scores :";
$txtlate = "Latest High Score by ";
$txtwit = "with ";
$txton = "on ";
global $scripturl;
require('./Settings.php');
$link = mysql_connect($db_server, $db_user, $db_passwd);
mysql_select_db($db_name, $link);
// --START BLOCK CODE --
$content = ""; //set blank for a start
//Get newest champ or die
$sql = "SELECT m.ID_MEMBER,m.realName,g.id, g.game, g.name,g.champion_score "
. "FROM {$db_prefix}members m , {$db_prefix}games g "
. "WHERE g.champion_score > 0 AND m.ID_MEMBER=g.champion_member "
. "ORDER BY g.champion_time DESC LIMIT 0,1";
if(!($result = mysql_query($sql,$link)))
{
die("Could not get the newest champ");
}
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
//newest champ details
$playerid = $row['ID_MEMBER'];
$player = $row['realName'];
$game_id = $row['id'];
$game_name = $row['name'];
$score = $row['champion_score'];
//now get the pic for the game
$ext = array('gif','GIF','png','PNG','jpg','JPG',);
$game_pic = ""; // No thumbnail for default
foreach($ext as $ex)
{
if(file_exists($boarddir. "/Games/".$row['game'].".".$ex))
{
$game_pic = $boardurl."/Games/".$row['game'].".".$ex;
}
}
//Get the 10 best players or die
$sql = "SELECT m.ID_MEMBER, m.realName, count(g.id) As cnt"
. " FROM {$db_prefix}games g, {$db_prefix}members m"
. " WHERE m.ID_MEMBER=g.champion_member"
. " GROUP BY realName "
. " ORDER BY cnt DESC LIMIT 0,{$chno}";
if(!($result = db_query($sql,__FILE__,__LINE__)))
{
die("Could not get the best players");
}
$row = mysql_fetch_assoc($result);
$score_poss=0; //players position
//make the block content
$content .= "<table width=\"100%\"><tr>
<td align=\"center\">
<br />
<a href=\"{$scripturl}?action=arcade\"><img src=\"{$settings['images_url']}/arcade_block.gif\" border= \"0\" alt=\"Arcade\" /></a>
<br /><br />
</td>
</tr>";
$content .= "
<tr>
<td>
<marquee behavior='scroll' align='center' direction='up' height='100' scrollamount='1' scrolldelay='50' onmouseover='this.stop()' onmouseout='this.start()'>
<br />
<div align=\"center\"><a href=\"{$scripturl}?action=arcade;sa=play;game={$game_id}\"><img src=\"{$game_pic}\" border= \"0\" /></a>
<br />{$txtlate}<br />
<a href=\"{$scripturl}?action=profile;u=$playerid\">{$player}</a><br />{$txtwit} {$score} {$txton} {$game_name}
<br />------------------<br />{$txtplay}
<br /><br /> ";
do
{
$score_poss++;
$content .= "
$score_poss -
<a href=\"{$scripturl}?action=profile;u=".$row['ID_MEMBER']."\"> ".$row['realName']."</a>
<br /> $txtwin ".$row['cnt']."
<br /><br />";
} while ($row = mysql_fetch_assoc($result));
mysql_free_result($result);
$content .= "</marquee></div></td></tr></table>" ;
echo $content;
?>
thanks eeek ur the champ :D
i would love to use this mod but ive got over 23 pages of games on my site and I dont have the time to wade through their image icon files to change some from jpgs to gifs oh well, maybe when i get another holiday I will have ago. :)
Thanks for the block code. It works great on my wifes site. :up:
Is there any chance that this code can be updated to work with the 2.0.5 arcade as now ive updated it isnt pulling in the data uptodate. :(
Quote from: daftdate on January 18, 2007, 02:04:40 AM
Is there any chance that this code can be updated to work with the 2.0.5 arcade as now ive updated it isnt pulling in the data uptodate. :(
It is updated and can be found over at smfarcade site.
See this thread: http://www.smfarcade.net/index.php/topic,2112.0.html
seems to be a problem with the site cause i just get a games search engine called smfarcade.net and not our old forum. :o will wait till they have sorted it out and my cold has gone. :)
Ok normally I wouldnt post after myself but has anyone got any ideas as to what is going on with smfarcade at the moment cause the site seems to have been down for the last few days????
They have changed themes and made some updates to the site.
If you look here you can follow the link to the site from there
http://www.tinyportal.net/index.php?topic=12569.msg104702;topicseen#new
thanx I was gettin a little worried there. :)
None of these work for me. I am using SMF 1.1.2 and SMF Arcade 2.0.6
I get the following error:
Database Error:
Table '###_###.ollocksgames' doesn't exist
File: /home/###/public_html/Sources/Load.php(1735) : eval()'d code(35) : eval()'d code
Line: 31
for latest TP arcade blocks check down on smfarcade.info site
Thank you. =)
Please code Arkade Games block ver.SMF 1.1.4,Tyniportal 0.983 ?? :'(
Please !!!!
Thank you !!
It should work just fine in SMF 1.1.4 and TP V.098, im using it on my site with no troubble at all.
Already it codes but not !
SMF Arcade 2.0.9 .
That block code will only work on eeeks own version of the arcade, if you have the version from SMF arcade.info you will not be able to use that block code.
Im using the Powered by E-Arcade 2.4.2 based on: SMF Arcade 2.0.9 and as you can see the block code works just fine on my site.
Please download E-Arcade 2.4.2 ???
You can find that version on ericsworld here
http://www.ericsworld.eu/f2/