Daily Lucky Numbers:
1
3
24
30
31
34

High Scores/Stats Block (Vertical)

Started by Chen Zhen, July 06, 2013, 03:09:31 PM

Previous topic - Next topic

Chen Zhen

PHP Portal Block Code For SMF Arcade 2.7.0.1 or older

Download the attached image
...and using your FTP platform - add the file to:
Themes / default / images / arc_icons


<<<<<<<<<<>>>>>>>>>>

High Scores/Stats PHP Block:

There is an adjustable setting near the start of the block to select if you want to display high scores only:
$mydisplays = true;
PHP Block Code:
global $settings, $scripturl, $sourcedir, $boardurl, $smcFunc, $modSettings, $boarddir;
require_once($boarddir . '/ArcadeSources/ArcadeStats.php');

$no = 10; //number of top players to show
$txtplay = "The Top Players"; // change "The Top Players" to your language
$txtwin = "Number Of Wins :";// change "Number Of Wins :" to your language
$txtlate = "Latest High Score by ";// change "Latest High Score set by" to your language
$txtwit = "with ";// change "with" to your language
$txton = "on ";// change "on" to your language
$arcade_icon = 'arcade.jpg';

$no_games = 8;
$icons_per_row = 4;
$mydisplays = true;
$check_game = !empty($_REQUEST['game']) ? (int) $_REQUEST['game'] : 0;
$no_games = !empty($check_game) ? 28 : 12;

$request = $smcFunc['db_query']('', '
    SELECT  game.id_game, game.game_name, game.thumbnail, game.game_directory,
    IFNULL(mem.id_member, 0) AS id_member, IFNULL(mem.real_name, {string:rname}) AS player_name, score.score
    FROM {db_prefix}arcade_scores AS score
    LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = score.id_member)
    RIGHT JOIN {db_prefix}arcade_games AS game ON (game.id_game = score.id_game)
    ORDER BY champion_from DESC
    LIMIT 0,1',
    array('rname' => '')
);
if(!$request)
  die("Could not get the newest champ");

$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);

if(isset($row['game_directory']))
  $row['game_directory']=$row['game_directory']."/";

//newest champ details
$playerid = $row['id_member'];
$player = $row['player_name'];
$game_id = $row['id_game'];
$game_name = $row['game_name'];
$score = $row['score'];
$game_pic = $modSettings['gamesUrl'] . '/' . $row['game_directory'] . '/' . $row['thumbnail'];
$arcadePic = file_exists($settings['default_theme_dir'] . '/images/arc_icons/' . $arcade_icon) ? '<img style="border: 0px;height: 3em;width: 8em;" src="' . $settings['default_theme_url'] . '/images/arc_icons/' . $arcade_icon . '" alt="" />' : '<img style="border: 0px;height: 5em;width: 5em;" src="' . $settings['default_theme_url'] . '/images/arc_icons/thearcade.png" alt="" />';
$bp=ArcadeStats_BestPlayers($no);
for ($x=1;$x<11;$x++) {
    $imgFile = file_exists($settings['default_theme_dir'] . '/images/arc_icons/' . $x . '.gif') ? $settings['default_theme_url'] . '/images/arc_icons/' . $x . '.gif' : $settings['default_theme_url'] . '/images/arc_icons/trophy.png';
    $trophy[$x] = '<img src="' . $imgFile . '" border= "0" alt="#' . $x . ' Score" />';
}
$score_poss=0; //players position

echo '
    <script type="text/javascript">
        var delayb4scrollx = 2000;
        var marqueespeedx = 1;
        var pauseitx = 1;
        var copyspeedx = marqueespeedx;
        var pausespeedx = pauseitx == 0 ? copyspeedx : 0;
        var actualheightx = "";

        function scrollmarqueex(){
            if (parseInt(cross_marqueex.style.top)>(actualheightx*(-1)+8))
                cross_marqueex.style.top=parseInt(cross_marqueex.style.top)-copyspeedx+"px"
            else
                cross_marqueex.style.top=parseInt(marqueeheightx)+8+"px"
        }

        function initializemarqueex(){
            cross_marqueex = document.getElementById("vmarqueex");
            cross_marqueex.style.top = 0;
            marqueeheightx = document.getElementById("marqueecontainerx").offsetHeight;
            actualheightx = cross_marqueex.offsetHeight;
            if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){
                cross_marqueex.style.height = marqueeheightx+"px";
                cross_marqueex.style.overflow = "scroll";
                return;
            }
            setTimeout('lefttime=setInterval("scrollmarqueex()",30)', delayb4scrollx);
        }

        if (window.addEventListener)
            window.addEventListener("load", initializemarqueex, false);
        else if (window.attachEvent)
            window.attachEvent("onload", initializemarqueex);
        else
            window.onload = initializemarqueex();
    </script>
<div style="overflow: hidden;">
    <div style="display:table;width: 100%;text-align: center;overflow: hidden;">
        <div style="display: table-row;">
            <div style="display: table-cell;text-align: center;">
                <span style="display: block;line-height: 1em;"></span>
                <a href="', $scripturl, '?action=arcade">
                    ', $arcadePic, '
                </a>
                <span style="display: block;line-height: 2em;"></span>
            </div>
        </div>
    </div>
</div>';
if ($mydisplays == true || $check_game == true) {
    /* Start 1 of 4 random stats display above top 10 marquee  */
    $random_games_choice = random_int(1,4);
    $games_choice = 'games'.$random_games_choice;
    $curr_position = 0;
    $games_choice($no_games,$curr_position,$icons_per_row, $modSettings['gamesUrl'], $no);
    /* END random stats display */
}
if ($check_game == false)
{
    echo '
<div class="centertext" style="padding-left: 0.25rem;overflow: hidden;">
    <div id="marqueecontainerx" style="position: relative; width: 99%; height:200px; overflow: hidden; border: 0px;" onmouseover="copyspeedx=pausespeedx" onmouseout="copyspeedx=marqueespeedx">
        <div id="vmarqueex" style="position: absolute; width: 98%;">
            <div class="centertext">
                <a href="', $scripturl, '?action=arcade;sa=play;game=', $game_id, '">
                    <img src="' . $game_pic . '" border="0" alt="' . $game_name . '" style="width: 4em;height: 4em;"/>
                </a>
                <span style="display: block;line-height: 1em;"></span>', $txtlate, '<span style="display: block;line-height: 1em;"></span>
                <a href="', $scripturl, '?action=profile;u=', $playerid, '">', $player, '</a>
                <span style="display: block;line-height: 1em;"></span>
                ', $txtwit, ' ', $score, ' ', $txton, '
                <span style="display: block;line-height: 1em;"></span>', $game_name, '
                <span style="display: block;line-height: 1em;"></span>
                <div style="width: 20%;margin: 0 auto;line-height: 0.2em;"><hr style="border-top: 1px dashed;" /></div>
                <span style="display: block;line-height: 1em;"></span>
                <span style="font: italic small-caps bold 12px/30px Georgia, serif;padding: 1em;">', $txtplay, '</span>
                <span style="display: block;line-height: 2em;"></span>';
    foreach ($bp as $out) {
        $score_poss++;
        if ($score_poss > 10)
            $trophy[$score_poss] = '[' . $score_poss . ']';

        echo $trophy[$score_poss], '
                <span style="display: block;line-height: 1em;"></span>
                ' . $out['link'] . '
                <span style="display: block;line-height: 1em;"></span>
                ' . $txtwin . ' ' . $out['champions'] . '
                <span style="display: block;line-height: 1em;"></span>
                <div style="width: 30%;margin: 0 auto;line-height: 0.2em;"><hr style="border-top: 1px dashed;" /></div>
                <span style="display: block;line-height: 1em;"></span>';
    }
}

echo '
            </div>
        </div>
    </div>
</div>';

/* START - Display Functions */
function games3($no_games,$curr_position,$icons_per_row, $gamesUrl,$no)
{
    //show the latest games
    global $smcFunc, $scripturl;

    echo '
    <div style="width: 100%;margin: 0 auto;text-align: center;overflow: hidden;">Latest Games
        <span style="display: block;line-height: 1em;"></span>
        <div style="display: table;border-spacing: 5px;margin: 0 auto;">
            <div style="display: table-row;">';

    $result = $smcFunc['db_query']('', '
        SELECT id_game, game_name, thumbnail, game_directory
        FROM {db_prefix}arcade_games
        ORDER BY id_game DESC, game_name DESC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
        $game_thumb = $gamesUrl . '/' . $game['game_directory'] . '/' . $game['thumbnail'];
        if($curr_position == $icons_per_row)
        {
            echo '
                </div>
                <div style="display: table-row;">';
            $curr_position=0;
        }
        echo'
                <div style="display: table-cell;padding: 2px;">
                    <a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id_game'].'">
                    <img src="'.$game_thumb.'" alt="'.$game['game_name'].'" style="border: 0px;width: 30px;height: 30px;" title="Play '.$game['game_name'].'" /></a>
                </div>';
      $curr_position++;
  }
  $smcFunc['db_free_result']($result);

  echo '
            </div>
        </div>
    </div>';
}

function games1($no_games,$curr_position,$icons_per_row, $gamesUrl,$no)
{
    //show most played games (one score version only)
    global $smcFunc, $scripturl;

    echo '
    <div style="width: 100%;margin: 0 auto;text-align: center;overflow: hidden;">Most Played
        <span style="display: block;line-height: 1em;"></span>
        <div style="display: table;border-spacing: 5px;margin: 0 auto;">
            <div style="display: table-row;">';

    $result = $smcFunc['db_query']('', '
        SELECT id_game, game_name, thumbnail, game_directory, num_plays
        FROM {db_prefix}arcade_games
        ORDER BY num_plays DESC , game_name ASC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
        $game_thumb = $gamesUrl . '/' . $game['game_directory'] . '/' . $game['thumbnail'];
        if($curr_position == $icons_per_row)
        {
            echo '
                </div>
                <div style="display: table-row;">';
            $curr_position=0;
        }
        echo'
                <div style="display: table-cell;padding: 2px;">
                    <a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id_game'].'">
                    <img src="'.$game_thumb.'" alt="'.$game['game_name'].'" style="border: 0px;width: 30px;height: 30px;" title="Play '.$game['game_name'].'" /></a>
                </div>';
        $curr_position++;
    }

    $smcFunc['db_free_result']($result);

  echo '
            </div>
        </div>
    </div>';
}

function games4($no_games,$curr_position,$icons_per_row, $gamesUrl,$no)
{
  //show least played games (one score version only)
  global $smcFunc, $scripturl;

  echo '
    <div style="width: 100%;margin: 0 auto;text-align: center;overflow: hidden;">Least Played
        <span style="display: block;line-height: 1em;"></span>
        <div style="display: table;border-spacing: 5px;margin: 0 auto;">
            <div style="display: table-row;">';

    $result = $smcFunc['db_query']('', '
        SELECT id_game, game_name, thumbnail, game_directory, num_plays
        FROM {db_prefix}arcade_games
        ORDER BY num_plays ASC , game_name ASC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
        $game_thumb = $gamesUrl . '/' . $game['game_directory'] . '/' . $game['thumbnail'];
        if($curr_position == $icons_per_row)
        {
            echo '
                </div>
                <div style="display: table-row;">';
            $curr_position=0;
        }
        echo '
                <div style="display: table-cell;padding: 2px;">
                    <a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id_game'].'">
                    <img src="'.$game_thumb.'" alt="'.$game['game_name'].'" style="border: 0px;width: 30px;height: 30px;" title="Play '.$game['game_name'].'" /></a>
                </div>';
        $curr_position++;
    }
    $smcFunc['db_free_result']($result);

  echo '
            </div>
        </div>
    </div>';
}

function games2($no_games,$curr_position,$icons_per_row, $gamesUrl,$no)
{
    //show best rated games
    global $smcFunc, $scripturl;

    echo '
    <div style="width: 100%;margin: 0 auto;text-align: center;overflow: hidden;">Top Rated
    <span style="display: block;line-height: 1em;"></span>
        <div style="display: table;border-spacing: 5px;margin: 0 auto;">
            <div style="display: table-row;">';

    $result = $smcFunc['db_query']('', '
        SELECT id_game, game_name, thumbnail, game_directory, game_rating
        FROM {db_prefix}arcade_games
        ORDER BY game_rating DESC , game_name ASC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
        $game_thumb = $gamesUrl . '/' . $game['game_directory'] . '/' . $game['thumbnail'];
        if($curr_position == $icons_per_row)
        {
            echo '</div><div style="display: table-row;">';
            $curr_position=0;
        }
        echo'
                <div style="display: table-cell;padding: 2px;">
                    <a href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id_game'].'">
                    <img src="'.$game_thumb.'" alt="'.$game['game_name'].'" style="border: 0px;width: 30px;height: 30px;" title="Play '.$game['game_name'].'" /></a>
                </div>';
        $curr_position++;
    }

    $smcFunc['db_free_result']($result);

  echo '
            </div>
        </div>
    </div>';
}

I included an extra icon for this block for SMF Arcade 2.65 or prior that can be put into ../Themes/default/images/arc_icons.
This image will already be included in SMF Arcade 2.66 +.

showzamani

I've just started using the arcade plugin but I'm going to solve it

Vincent Titus

and will this block work with the new arcade thats coming out ??

Chen Zhen


I finally got around to updating this block code which will work with the latest version of the Arcade.