Daily Lucky Numbers:
5
12
17
25
40
42

Recent posts

#11
SMF Arcade Support + Plugins / Re: Outdo games
Last post by Allach - September 12, 2024, 12:25:49 PM
I mean, if you were outbid.

#12
SMF Arcade Support + Plugins / Re: Outdo games
Last post by Chen Zhen - September 12, 2024, 12:05:49 PM
I believe your translation to English is a bit off.

If you are referring to scoring, there is a hi score link for every game in each game list & under the game window for Flash/HTML5 games.
#13
SMF Arcade Support + Plugins / Outdo games
Last post by Allach - September 12, 2024, 11:51:30 AM
Is there a setting where you find out if you've been outbid in some games?

#14
SMF Arcade Block Codes / Re: High Scores/Stats Block (V...
Last post by Dave - September 11, 2024, 05:03:48 PM
Thanks very much Chen. Nice touch also to only have high scores and to allow changing the type of games showing.
#15
SMF Arcade Block Codes / High Scores/Stats Block (Verti...
Last post by Chen Zhen - September 10, 2024, 03:33:42 AM
High Scores/Stats PHP Block

Arcade version: SMF Arcade 2.7.0.2+



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:
/* High Scores/Stats PHP Block */
/**************************
set $gameTypes
0 = Permission based
1 = Flash/HTML
2 = ROM only
3 = All game types
**************************/
global $settings, $scripturl, $sourcedir, $boardurl, $smcFunc, $arcadeModSettings, $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';
$gameTypes = 0;

switch($gameTypes) {
case 1:
$where = ' WHERE rom_flag = {int:romflag}';
$romflag = 0;
break;
case 2:
$where = ' WHERE rom_flag = {int:romflag}';
$romflag = 1;
break;
case 3:
$where = '';
$romflag = 0;
break;
default:
$romflag = 0;
if (allowedTo('arcade_view_retro_arch')) {
$where = '';
}
else {
$where = ' WHERE rom_flag = {int:romflag}';
}
}

$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;
$display = RandomArcadeDatum($no, $txtplay, $txtwin, $txtlate, $txtwit, $txton, $arcade_icon, $gameTypes, $no_games, $icons_per_row, $mydisplays, $check_game, $where, $romflag);

function RandomArcadeDatum($no, $txtplay, $txtwin, $txtlate, $txtwit, $txton, $arcade_icon, $gameTypes, $no_games, $icons_per_row, $mydisplays, $check_game, $where, $romflag)
{
global $settings, $scripturl, $sourcedir, $boardurl, $smcFunc, $arcadeModSettings, $boarddir;

if (!allowedTo('arcade_view') && $gameTypes == 0) {
return false;
}

$request = $smcFunc['db_query']('', '
SELECT  game.id_game, game.game_name, game.thumbnail, game.game_directory, game.rom_flag,
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)' . (str_replace('rom_flag', 'game.rom_flag', $where)) . '
ORDER BY champion_from DESC
LIMIT 0,1',
array('rname' => '???', 'romflag' => $romflag)
);
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 = !empty($row['real_name']) ? $row['real_name'] : $row['player_name'];
$game_id = $row['id_game'];
$game_name = $row['game_name'];
$score = $row['score'];
$game_pic = (!empty($row['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['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);
$bp = !empty($bp) ? $bp : array();
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, '', $no, $gameTypes, $where, $romflag);
/* END random stats display */
}
if ($check_game == false)
{
echo '
<div class="centertext" style="display: flex;justify-content: center;overflow: hidden;">
<div id="marqueecontainerx" style="position: relative; width: 100%; height:200px; overflow: hidden; border: 0px;" onmouseover="copyspeedx=pausespeedx" onmouseout="copyspeedx=marqueespeedx">
<div id="vmarqueex" style="position: absolute; width: 100%;">
<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>';
return true;
}

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

    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, rom_flag
        FROM {db_prefix}arcade_games' . $where . '
        ORDER BY id_game DESC, game_name DESC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games, 'romflag' => $romflag
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
$path = str_replace('\\', '/', (!empty($game['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']));
$filepath = rtrim($path, '/');
$gamesUrl = !empty($game['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
$action = !empty($game['rom_flag']) ? 'retro_arch' : 'arcade';
        $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=' . $action . ';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, $gameTypes, $where, $romflag)
{
    //show most played games (one score version only)
    global $smcFunc, $scripturl, $arcadeModSettings;

    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, rom_flag, num_plays
        FROM {db_prefix}arcade_games' . $where . '
        ORDER BY num_plays DESC , game_name ASC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games, 'romflag' => $romflag,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
$path = str_replace('\\', '/', (!empty($game['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']));
$filepath = rtrim($path, '/');
$gamesUrl = !empty($game['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
$action = !empty($game['rom_flag']) ? 'retro_arch' : 'arcade';
        $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=' . $action . ';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, $gameTypes, $where, $romflag)
{
  //show least played games (one score version only)
  global $smcFunc, $scripturl, $arcadeModSettings;

  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, rom_flag
        FROM {db_prefix}arcade_games' . $where . '
        ORDER BY num_plays ASC , game_name ASC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games, 'romflag' => $romflag,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
$path = str_replace('\\', '/', (!empty($game['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']));
$filepath = rtrim($path, '/');
$gamesUrl = !empty($game['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
$action = !empty($game['rom_flag']) ? 'retro_arch' : 'arcade';
        $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=' . $action . ';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, $gameTypes, $where, $romflag)
{
    //show best rated games
    global $smcFunc, $scripturl, $arcadeModSettings;

    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, rom_flag
        FROM {db_prefix}arcade_games' . $where . '
        ORDER BY game_rating DESC , game_name ASC
        LIMIT 0,{int:no}',
        array(
            'no' => $no_games, 'romflag' => $romflag,
        )
    );

    while ($game = $smcFunc['db_fetch_assoc']($result))
    {
$path = str_replace('\\', '/', (!empty($game['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']));
$filepath = rtrim($path, '/');
$gamesUrl = !empty($game['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
$action = !empty($game['rom_flag']) ? 'retro_arch' : 'arcade';
        $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=' . $action . ';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>';
}
#16
SMF Arcade Block Codes / Category Block (regular list)
Last post by Chen Zhen - September 10, 2024, 01:54:44 AM
Category Block

Version: SMF Arcade 2.7.0.2+



For EhPortal users, you can have this show in your arcade (only) by selecting Advanced Options and enter the following into Custom Display Options:
~action|arcade


Note:
The categories can also be displayed with small icons. Just name the icon the same as your category name except change any spaces to an underscore (case sensitive) and make sure it's in gif format.
Place the icons in: / Themes / default / images / arc_icons
The icons are set at 20 x 20 but this can be edited within the block.



PHP Block Code:
global $db_prefix, $arcadeModSettings, $context, $sourcedir, $scripturl, $smcFunc, $boardurl, $settings;

// Set table width & column variables  -
// change $NumberOfColumns for the number of columns across
// change $block to "right" to align items on the right side

$NumberOfColumns = 4;
$columns = 0;
$block = 'left';
/**************************
set $gameTypes
0 = Permission based
1 = Flash/HTML
2 = ROM only
3 = All game types
**************************/
$gameTypes = 0;
list($requestit, $rowit, $category, $jam, $gameCats) = array(array(), array(), array(), array(), array());
$jam['arcade_category'] = array();
switch($gameTypes) {
case 1:
$where = ' AND game.rom_flag = {int:romflag}';
$romflag = 0;
break;
case 2:
$where = ' AND game.rom_flag = {int:romflag}';
$romflag = 1;
$included_game_types[] = 'rom';
break;
case 3:
$where = '';
$romflag = 0;
break;
default:
$romflag = 0;
if (allowedTo('arcade_view_retro_arch')) {
$where = '';
}
else {
$where = ' AND game.rom_flag = {int:romflag}';
}
}
$request = $smcFunc['db_query']('', '
    SELECT game.id_game, game.id_cat, game.enabled, game.rom_flag
    FROM {db_prefix}arcade_games as game
WHERE enabled = {int:enabled}' . $where . '
    ORDER BY game.id_game ASC',
    array('enabled' => 1,'romflag' => $romflag)
);
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$idCat = !empty($row['id_cat']) ? intval($row['id_cat']) : 0;
if (empty($gameTypes) && empty($row['rom_flag']) && !allowedTo('arcade_play'))
continue;
elseif (empty($gameTypes) && !empty($row['rom_flag']) && !allowedTo('arcade_view_retro_arch'))
continue;

$gameCats[$idCat][] = $row['id_game'];
}
$smcFunc['db_free_result']($request);
$requestit = $smcFunc['db_query']('', '
SELECT id_cat, cat_name, num_games, cat_order, cat_icon
FROM {db_prefix}arcade_categories
ORDER BY cat_order',
array()
);

while ($rowit = $smcFunc['db_fetch_assoc']($requestit))
{
if (empty($gameCats[$rowit['id_cat']]))
continue;

$jam['arcade_category'][] = array(
'id' => $rowit['id_cat'],
'name' => $rowit['cat_name'],
'href' => $scripturl . '?action=arcade;category=' . $rowit['id_cat'],
'games' => $rowit['num_games'],
'order' => $rowit['cat_order'],
'icon' => $rowit['cat_icon'],
);
}
$smcFunc['db_free_result']($requestit);

echo '
<div style="overflow: hidden;">
<div style="display: table;width: 100%;margin: 0 auto;border: 0px;padding: 5px 5px 1em 5px;text-align: center;overflow: hidden !important;" summary="cats_block2" class="smalltext">
<div style="display: table-row;overflow: hidden;">';

foreach ($jam['arcade_category'] as $category)
{
if ($columns <= $NumberOfColumns) {
$gamepic_name = str_replace (" ", "_", $category['name']);
$gamepic_name = str_replace ("/", "-", $gamepic_name);
$category_pic = '<img src="' .$settings['default_theme_url']. '/images/arc_icons/'.$category['icon'].'" style="border: 0px;width: 25px;height: 25px;padding: 0.1rem 0.3rem 0.3rem 0.3rem;vertical-align: middle;" alt="~"  title="'.$category['name'].'" />';

if ($block == 'right')
echo'
<div style="width: 320px;display: flex;height: 25px;align-items: top;justify-content: right;text-justify: inter-word;border-spacing: 2px;vertical-align: middle;">
<a href="', $category['href'], '"><span style="padding-left: 0.3rem;vertical-align: middle;">',$category['name'], '</span></a><span style="padding-left: 0.3rem;vertical-align: middle;">(', $category['games'] , ' games)</span>', $category_pic, '
</div>';
else
echo'
<div style="padding: 0.15rem 0rem 0.15rem 0rem;width: 320px;display: flex;align-items: top;justify-content: left;text-justify: inter-word;border-spacing: 2px;vertical-align: middle;">', $category_pic, " ", '
<a href="', $category['href'], '"><span style="padding-left: 0.3rem;vertical-align: middle;">',$category['name'], '</span></a><span style="padding-left: 0.3rem;vertical-align: middle;">(', $category['games'] , ' games)</span>
</div>';
$columns++;
}

if ($columns >= $NumberOfColumns)  {
$columns = 0;
echo '
</div>
<div style="display: table-row;overflow: hidden;">';
}
}

echo '
</div>
</div>
</div>';
#17
SMF Arcade Block Codes / Horizontal Favorites Block
Last post by Chen Zhen - September 10, 2024, 01:49:39 AM
Horizontal Favorites Block

Version: SMF Arcade 2.7.0.2+



Use this as a top/bottom/header custom php block:

Mian Code:/**************************
set $gameTypes
0 = Permission based
1 = Flash/HTML
2 = ROM only
3 = All game types
**************************/
/* Display user's favorites for SMF Arcade */

global $user_info, $smcFunc, $settings, $arcadeModSettings, $scripturl, $boardurl, $boarddir, $sourcedir;

/* Adjust these */
$lang = 'Play ';
$none = 'No games selected';
$per_row = 4;
$rows = 1;
$char_length = 35;
$prev = 'Prev';
$next = 'Next';
$gameTypes = 0;

/* Do not edit below this line */
switch($gameTypes) {
case 1:
$where = ' AND game.rom_flag = {int:romflag}';
$romflag = 0;
break;
case 2:
$where = ' AND game.rom_flag = {int:romflag}';
$romflag = 1;
break;
case 3:
$where = '';
$romflag = 0;
break;
default:
$romflag = 0;
if (allowedTo('arcade_view_retro_arch')) {
$where = '';
}
else {
$where = ' AND game.rom_flag = {int:romflag}';
}
}
$query = '(favorite.id_member = ' . $user_info['id'] . ' AND enabled = 1)' . $where;
$datum = array('id_game', 'game_name', 'game_directory', 'thumbnail', 'rom_flag');
list($x, $count, $game) = array(0, 0, array());
$maindir = !empty($arcadeModSettings['gamesUrl']) ? $arcadeModSettings['gamesUrl'] : 'Games';

$pages = '
<script type="text/javascript">
var pager = new Pager("favs", ' . (int)$rows . ');
        pager.init();
        pager.showPageNav("pager", "favPagePosition");
        pager.showPage(1);
    </script>';

/* Some JavaScript to control the pages */
$arcade = '
<script type="text/javascript">
function Pager(tableName, itemsPerPage) {
this.tableName = tableName;
this.itemsPerPage = itemsPerPage;
this.currentPage = 1;
this.pages = 0;
this.inited = false;

this.showRecords = function(from, to) {
var rows = document.getElementById(tableName).children;
for (var i = 1; i < rows.length; i++) {
if (i < from || i > to)
rows[i].style.display = "none";
else
rows[i].style.display = "";
}
}

this.showPage = function(pageNumber) {
if (!this.inited) {
console.log("show page not initialized");
return;
}
var oldPageAnchor = document.getElementById("pg"+this.currentPage);
oldPageAnchor.className = "pg-normal";

this.currentPage = pageNumber;
var newPageAnchor = document.getElementById("pg"+this.currentPage);
newPageAnchor.className = "pg-selected";

var from = (pageNumber - 1) * itemsPerPage + 1;
var to = from + itemsPerPage - 1;
this.showRecords(from, to);
}

this.prev = function() {
if (this.currentPage > 1)
this.showPage(this.currentPage - 1);
}

this.next = function() {
if (this.currentPage < this.pages) {
this.showPage(this.currentPage + 1);
}
}

this.init = function() {
var rows = document.getElementById(tableName).children;
var records = (rows.length - 1);
this.pages = Math.ceil(records / itemsPerPage);
this.inited = true;
}
this.showPageNav = function(pagerName, positionId) {
if (!this.inited) {
console.log("page navigation not initialized");
return;
}
var element = document.getElementById(positionId);
var pagerHtml = \'<span onmouseover="resizePage(this, 125)" onmouseout="resizePage(this, 100)" style="cursor: pointer;" onclick="\' + pagerName + \'.prev();" class="pg-normal"> &larr; ' . $prev . ' </span> | \';

for (var page = 1; page <= this.pages; page++)
pagerHtml += \'<span onmouseover="resizePage(this, 125)" onmouseout="resizePage(this, 100)" style="cursor: pointer;" id="pg\' + page + \'" class="pg-normal" onclick="\' + pagerName + \'.showPage(\' + page + \');">\' + page + \'</span> | \';
pagerHtml += \'<span onmouseover="resizePage(this, 125)" onmouseout="resizePage(this, 100)" style="cursor: pointer;" onclick="\' + pagerName + \'.next();" class="pg-normal"> ' . $next . ' &rarr;</span>\';
element.innerHTML = pagerHtml;
element.style.margin = "0px auto";
}
}
function resizePage(elem, percent)
{
elem.style.fontSize = percent.toString() + "%";
}
function regenerate()
{
window.location.reload();
}

function regenerate3()
{
if (document.layers)
{
appear();
setTimeout("window.onresize=regenerate",450);
}
}

function changetext(whichcontent)
{
if (document.all||document.getElementById)
{
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions;
cross_el.innerHTML = \'<div style="font-family:Arial Narrow Bold;font-size:small;">\'+whichcontent+\'</div>\';
}
else if (document.layers)
{
document.d1.document.d2.document.write(\'<div style="font-family:Arial Narrow Bold;font-size:small;">\'+whichcontent+\'</div>\');
document.d1.document.d2.document.close();
}

}

function appear()
{
document.d1.visibility="show";
}
</script>';
/* end of js controller */

$result = $smcFunc['db_query']('', "
SELECT favorite.id_favorite, favorite.id_member, favorite.id_game, game.game_name, game.game_directory, game.thumbnail, game.rom_flag, game.enabled FROM {db_prefix}arcade_favorite AS favorite
LEFT JOIN {db_prefix}arcade_games AS game ON (game.id_game = favorite.id_game)
WHERE {$query} ORDER BY favorite.id_favorite DESC", array('romflag' => $romflag));
while ($val = $smcFunc['db_fetch_assoc']($result)) {
foreach ($datum as $data) {
if (empty($val[$data]))
$val[$data] = false;
$game[$val['id_favorite']][$data] = $val[$data];
}
$count++;
}
$smcFunc['db_free_result']($result);
$arcade .= '
<script type="text/javascript">
if (window.addEventListener)
window.addEventListener("load", regenerate3, false);
else if (window.attachEvent)
window.attachEvent("onload", regenerate3);
else
window.onload = regenerate3();
</script>';
if ($count == 0)
$arcade .= '
<div style="text-align:center">' . $none . '</div>';
else
{
$arcade .= '
<div style="overflow: hidden;margin: 0 auto;width: 100%;" align="center">
<div id="favs" style="width: 100%;display: table;overflow: hidden;margin: 0 auto;">
<div style="display: table-row;margin: 0 auto;">
<div style="display: table-cell;">&nbsp;</div>
</div>
<div style="display: table-row;margin: 0 auto;">';
foreach ($game as $myfavs)
{
$x++;
$path = str_replace('\\', '/', (!empty($myfavs['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']));
$filepath = rtrim($path, '/');
$gamesUrl = !empty($myfavs['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
$action = !empty($myfavs['rom_flag']) ? 'retro_arch' : 'arcade';
$image = $settings['default_theme_url'] . '/arc_icons/Default.gif';
if (!empty($myfavs['thumbnail'])) {
$imgPath = empty($myfavs['game_directory']) ? $myfavs['thumbnail'] : $myfavs['game_directory'] . '/' . $myfavs['thumbnail'];
$image = file_exists($filepath . '/' . $imgPath) ? $gamesUrl . '/' . $imgPath : $image;
}
$title = strlen($myfavs['game_name']) >= ((int)$char_length) ? $title = substr($myfavs['game_name'], 0, ((int)$char_length - 1)) . '...' : $myfavs['game_name'];

$arcade .= '
<div style="display: table-cell;text-align:center;width:25%;">
<div style="height:80px;overflow:hidden;">
<a href="' . $scripturl . '?action=' . $action. ';sa=play;game=' . $myfavs['id_game'] . '" title="' . $lang . $myfavs['game_name'] . '">
<img src="' . $image . '" style="max-height:50px;max-width:50px;" alt="" />
</a>
<span style="display: block;line-height: 1em;"></span>
<a href="' . $scripturl . '?action=' . $action . ';sa=play;game=' . $myfavs['id_game'] . '" title="' . $lang . $myfavs['game_name'] . '">' . $title . '</a>
</div>
</div>';
if ($x > ((int)$per_row -1)) {
$x=0;
$arcade .= '
</div>
<div style="display: table-row;margin: 0 auto;">';
}
}

$arcade .= '
</div>
</div>
</div>
<span style="display: block;line-height: 1em;"></span>
<div id="favPagePosition" style="text-align:center;margin: 0 auto;overflow: hidden;"> </div>
<div style="text-align:center;margin: 0 auto;overflow: hidden;">' . $pages . '</div>';
}

if (!allowedTo('arcade_view') && $gameTypes == 0) {
$arcade = '';
}

echo $arcade;
#18
SMF Arcade Block Codes / Random Games Block
Last post by Chen Zhen - September 10, 2024, 12:59:49 AM
Random games block (icons only)

Arcade version: SMF Arcade 2.7.0.2 or newer



This one is set up only to appear when the user is not playing a game.
There are 2 limit settings... one for users and one for guests. You can set both as the same if you wish.

Create a new php block...

Enter this for custom display options:
(For viewing on portal - leave this line blank)
~action|arcade

$evenRows = [BOOLEAN] option to trim uneven rows
$guestMax = [INT] to equal the amount preferred
$userMax = [INT] to equal the amount preferred
$icons_per_row = [INT] to equal the amount preferred

Main code:
/**************************
    set $gameTypes
    0 = Permission based
    1 = Flash/HTML
    2 = ROM only
    3 = All game types
**************************/

// adjustable variables
list($evenRows, $guestMax, $userMax, $icons_per_row, $arcade, $gameTypes) = array(true, 60, 28, 4, '', 0);

global $scripturl, $arcadeModSettings, $smcFunc, $user_info, $settings;
$check_game = isset($_REQUEST['game']) ? floatval($_REQUEST['game']) : 0;
$defaultIcon = file_exists($settings['default_theme_dir'] . '/images/arc_icons/game.gif') ? $settings['default_images_url'] . '/arc_icons/game.gif' : '';
list($arcade, $arcadePermissionMode, $count1) = array('', (!isset($arcadeModSettings['arcadePermissionMode']) ? 1 : $arcadeModSettings['arcadePermissionMode']), 0);

switch($gameTypes) {
    case 1:
        $whereRom = ' AND game.rom_flag = {int:romflag}';
        $romflag = 0;
        break;
    case 2:
        $whereRom = ' AND game.rom_flag = {int:romflag}';
        $romflag = 1;
        break;
    case 3:
        $whereRom = '';
        $romflag = 0;
        break;
    default:
        $romflag = 0;
        if (allowedTo('arcade_view_retro_arch')) {
            $whereRom = '';
        }
        else {
            $whereRom = ' AND game.rom_flag = {int:romflag}';
        }
}

// check permissions
if (allowedTo('arcade_admin'))
{
    $see_game = '1=1';
    $see_category = '1=1';
}
else
{
    if ($arcadePermissionMode >= 2)
    {
        if ($user_info['is_guest'])
            $see_game = '(game.id_cat = 0 AND ' . (allowedTo('arcade_view') ? 1 : 0) . ' = 1) OR (game.local_permissions = 0 OR FIND_IN_SET(-1, game.member_groups))';
        else
            $see_game = '(game.local_permissions = 0 OR (FIND_IN_SET(' . implode(', game.member_groups) OR FIND_IN_SET(', $user_info['groups']) . ', game.member_groups)))';
    }

    if ($arcadePermissionMode == 1 || $arcadePermissionMode >= 3)
    {
        if ($user_info['is_guest'])
            $see_category = '(game.id_cat = 0 AND ' . (allowedTo('arcade_view') ? 1 : 0) . ' = 1) OR (FIND_IN_SET(-1, category.member_groups))';
        else
            $see_category = '(FIND_IN_SET(' . implode(', category.member_groups) OR FIND_IN_SET(', $user_info['groups']) . ', category.member_groups) OR ISNULL(category.member_groups))';
    }
}

if (empty($arcadePermissionMode))
    $where = 'enabled = 1';
elseif ($arcadePermissionMode == 1)
    $where = '(enabled = 1 AND ' . $see_category . ')';
elseif ($arcadePermissionMode == 2)
    $where = '(enabled = 1 AND ' . $see_game . ')';
elseif ($arcadePermissionMode == 3)
    $where = '(enabled = 1 AND (' . $see_category . ' AND ' . $see_game . '))';
elseif ($arcadePermissionMode == 4)
    $where = '(enabled = 1 AND (' . $see_category . ' OR ' . $see_game. '))';

$where = !empty($where) ? $where : '1=1';


if (empty($check_game))
{
    $arcade = '
<div style="overflow: hidden;">
    <div style="display: table;width: 100%;margin: 0 auto;padding: 2px;overflow: hidden;">
        <div style="display: table-row;">';
    $id_game = false;
    $result =  $smcFunc['db_query']('', '
        SELECT COUNT(*) as total
        FROM {db_prefix}arcade_games as game
        LEFT JOIN {db_prefix}arcade_categories AS category ON (category.id_cat = game.id_cat)
        WHERE {raw:query_see_game}',
        array(
            'query_see_game' => $where . $whereRom, 'romflag' => $romflag,
        )
    );
    $totalView = $smcFunc['db_fetch_assoc']($result);
    $smcFunc['db_free_result']($result);

    $totalPermitted = !empty($totalView['total']) ? $totalView['total'] : 0;
    $guestMax = $totalPermitted >= $guestMax ? (int)$guestMax : (int)$totalPermitted;
    $userMax = $totalPermitted >= $userMax ? (int)$userMax : (int)$totalPermitted;
    $guestMax = $evenRows ? $guestMax - ($guestMax % $icons_per_row) : $guestMax;
    $userMax = $evenRows ? $userMax - ($userMax % $icons_per_row) : $userMax;

    if (empty($user_info['is_guest']) && !empty($totalPermitted))
    {
        $request = $smcFunc['db_query']('', '
            SELECT game.id_game, game.game_name, game.game_directory, game.thumbnail, game.id_cat, game.rom_flag, category.member_groups
            FROM {db_prefix}arcade_games AS game
            LEFT JOIN {db_prefix}arcade_categories AS category ON (category.id_cat = game.id_cat)
            WHERE {raw:query_see_game}
            ORDER BY RAND()
            LIMIT ' . $userMax,
            array(
                'query_see_game' => $where . $whereRom, 'romflag' => $romflag,
            )
        );

        while ($row = $smcFunc['db_fetch_assoc']($request))
        {
            $path = str_replace('\\', '/', !empty($row['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']);
            $filepath = rtrim($path, '/');
            $gamesUrl = !empty($row['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
            $action = !empty($row['rom_flag']) ? 'retro_arch' : 'arcade';
            if ($count1 % $icons_per_row == 0)
                $arcade .= '
    </div>
    <div style="display: table-row;">';


            $thumbnailFile = '';

            if (!empty($row['thumbnail']))
            {
                $thumbnailFile = $filepath . '/' . (!empty($row['game_directory']) ? $row['game_directory'] . '/' : '') . $row['thumbnail'];
                $thumbnailPath = file_exists($thumbnailFile) ? $gamesUrl . '/' . (!empty($row['game_directory']) ? $row['game_directory'] . '/' : '') . $row['thumbnail'] : '';
            }
            elseif (!empty($defaultIcon))
                $thumbnailPath = $defaultIcon;

            $count1++;

            if (empty($thumbnailFile))
                continue;

            $arcade .= '
            <div class="centertext" style="display: table-cell;borser-spacing: 1px;">
                <a href="' . $scripturl . '?action=' . $action . ';sa=play;game=' . $row['id_game'] . '">
                    <img style="width:42px; height:42px;" src="' . $thumbnailPath . '" alt="'.$row['game_name'].'" title="'.$row['game_name'].'" />
                </a>
            </div>';

        }
        $smcFunc['db_free_result']($request);

        $arcade .= '
        </div>
    </div>
</div>';
    }
    elseif (!empty($totalPermitted))
    {
        $request = $smcFunc['db_query']('', '
            SELECT game.id_game, game.game_name, game.game_directory, game.thumbnail, game.id_cat, game.rom_flag, category.member_groups
            FROM {db_prefix}arcade_games AS game
            LEFT JOIN {db_prefix}arcade_categories AS category ON (category.id_cat = game.id_cat)
            WHERE {raw:query_see_game}
            ORDER BY RAND()
            LIMIT ' . $guestMax,
            array(
                'query_see_game' => $where . $whereRom, 'romflag' => $romflag,
            )
        );

        while ($row = $smcFunc['db_fetch_assoc']($request))
        {
            $path = str_replace('\\', '/', !empty($row['rom_flag']) ? $arcadeModSettings['romGamesDirectory'] : $arcadeModSettings['gamesDirectory']);
            $filepath = rtrim($path, '/');
            $gamesUrl = !empty($row['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
            $action = !empty($row['rom_flag']) ? 'retro_arch' : 'arcade';
            if ($count1 % $icons_per_row == 0)
                $arcade .= '
        </div>
        <div style="display: table-row;">';


            $thumbnailFile = '';

            if (!empty($row['thumbnail']))
            {
                $thumbnailFile = $filepath . '/' . (!empty($row['game_directory']) ? $row['game_directory'] . '/' : '') . $row['thumbnail'];
                $thumbnailPath = file_exists($thumbnailFile) ? $gamesUrl . '/' . (!empty($row['game_directory']) ? $row['game_directory'] . '/' : '') . $row['thumbnail'] : '';
            }
            elseif (!empty($defaultIcon))
                $thumbnailPath = $defaultIcon;

            $count1++;

            if (empty($thumbnailFile))
                continue;

            $arcade .= '
                <div class="centertext" style="display: table-cell;border-spacing: 1px;">
                    <a href="' . $scripturl . '?action=' . $action . ';sa=play;game=' . $row['id_game'] . '">
                        <img style="width:42px; height:42px;" src="' . $thumbnailPath . '" alt="'.$row['game_name'].'" title="'.$row['game_name'].'" />
                    </a>
                </div>';
        }

        $arcade .= '
        </div>
    </div>
</div>';

        $smcFunc['db_free_result']($request);
    }

    if (!allowedTo('arcade_view') && $gameTypes == 0) {
        $arcade = '';
    }
   
    echo $arcade;
}
#19
SMF Arcade Block Codes / Latest Games Block
Last post by Chen Zhen - September 10, 2024, 12:37:47 AM
Latest Games Block
Arcade version: SMF Arcade v2.7.0.2+



Create a new php block...

Enter this for custom display options:
(For viewing on portal - leave this line blank)
~action|arcade

Change '$icons_per_row' to equal the amount preferred
Change '$limit' to equal the amount preferred

Main code:
// Latest games block for SMF Arcade version 2.7.0.2 or newer
/**************************
    set $gameTypes
    0 = Permission based
    1 = Flash/HTML
    2 = ROM only
    3 = All game types
**************************/
global $db_prefix, $scripturl, $arcadeModSettings, $boardurl, $smcFunc;

$icons_per_row = 4;
$limit = 44;
$gameTypes = 0;

switch($gameTypes) {
    case 1:
        $where = ' WHERE game.rom_flag = {int:romflag}';
        $romflag = 0;
        break;
    case 2:
        $where = ' WHERE game.rom_flag = {int:romflag}';
        $romflag = 1;
        break;
    case 3:
        $where = '';
        $romflag = 0;
        break;
    default:
        $romflag = 0;
        if (allowedTo('arcade_view_retro_arch')) {
            $where = '';
        }
        else {
            $where = ' WHERE game.rom_flag = {int:romflag}';
        }
}

$arcade = '
<div style="overflow: hidden;">
    <div style="display: table;margin: 0 auto;padding: 1px;overflow: hidden;">
        <div style="display: table-row;">';
list($count1, $imgFile) = array(0, '');

$request = $smcFunc['db_query']('', '
    SELECT game.id_game, game.game_name, game.game_directory, game.thumbnail, game.rom_flag
    FROM {db_prefix}arcade_games AS game' . $where . '
    ORDER BY game.id_game DESC
    LIMIT {int:mylimit}', array('mylimit' => $limit, 'romflag' => $romflag)
);

while ($row = $smcFunc['db_fetch_assoc']($request)) {
$imgFile = isset($row['game_directory']) && $row['game_directory'] != '' ? $row['game_directory'] . '/' . $row['thumbnail'] : $row['thumbnail'];
$action = !empty($row['rom_flag']) ? 'retro_arch' : 'arcade';
if ($count1 > ($icons_per_row - 1)) {
$count1 = 0;
$arcade .= '
</div>
<div style="display: table-row;">';
}
$count1++;
$arcade .= '
<div style="display: table-cell;text-align: center;margin: 0 auto;border-spacing: 1px;">
<a href="' . $scripturl . '?action=' . $action . ';sa=play;game=' . $row['id_game'] . '">
<img style="width:42px; height:42px;" src="' . (!empty($row['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl']) . '/' . $imgFile . '" alt="' . $row['game_name'] . '" title="' . $row['game_name'] . '" />
</a>
</div>';
}

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

$arcade .= '
        </div>
    </div>
</div>';

if (!allowedTo('arcade_view') && $gameTypes == 0)
    $arcade = '';

echo $arcade;
#20
SMF Arcade Support + Plugins / Re: EmulatorJS Legal Games
Last post by Skhilled - August 25, 2024, 08:12:34 PM
Sounds good!  ;D