TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,989
  • Total Topics: 21,322
  • Online today: 1,078
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 1102
  • Total: 1103
  • @rjen

Arcade Games Block

Started by eeek, September 09, 2006, 07:51:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eeek

#10
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>';
}

eitbuzz

Thank You eeek , i will surely gonna try it :)

Nokonium

That is super eeek, thanks  :up:

Polymath


Nokonium

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;
?>

akulion


daftdate

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.  :)

Ronlx2

Thanks for the block code. It works great on my wifes site. :up:

daftdate

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.  :(

whoesa

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

This website is proudly hosted on Crocweb Cloud Website Hosting.