Thread: Add-On Releases - v3 Arcade - Games Arcade System for 3.6.0
View Single Post
  #3045  
Old 10-15-2008, 05:36 PM
skhms's Avatar
skhms skhms is offline
 
Join Date: Oct 2006
Location: Sweden
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by crkgb View Post
In the v3Arcade settings I have it set up so that only the best result counts. it works for all the cases but when the same user gets the same score. Then there are 2 results for the same user listed.

Is there a way to fix this?
I fixed it this way, see below.
Note that I don't really take any responsibility for this code. It might be some much better way to do it...

In arcade.php
Find this chunk of code:
PHP Code:
    // Time for the scores.
    
$scores $db->query_read("SELECT arcade_sessions.*, user.username, user.arcadeoptions" iif($vbulletin->options['distinctscores'], ", " iif($game['isreverse']==1'MIN''MAX') . "(arcade_sessions.score) AS score") . " FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
    LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
    WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid]
    " 
iif($vbulletin->options['distinctscores'], "GROUP BY arcade_sessions.userid") . "
    ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
    LIMIT " 
$vbulletin->options['scoresperpage']);
    
    if (
$vbulletin->options['distinctscores'])
    {
        
$scorecache = array();
        while (
$score $db->fetch_array($scores))
        {
            
$scorecache[] = "(arcade_sessions.score=$score[score] AND arcade_sessions.userid=$score[userid])";
        }
        
$scorecache implode(' OR '$scorecache);
        
        
$scores $db->query_read("SELECT arcade_sessions.*, user.username, user.arcadeoptions FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
        WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid] AND ($scorecache)
        ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
        LIMIT " 
$vbulletin->options['scoresperpage']);
    } 
Replace it with this:
PHP Code:
    // Time for the scores.
    // Replaced code for finding scores, so it won't show duplicates on players with the same score. /SK
    
$scores $db->query_read"SELECT arcade_sessions.*, user.username, user.arcadeoptions FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
    LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
    WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid]
    ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
    " 
iif( !$vbulletin->options['distinctscores'], "LIMIT " $vbulletin->options['scoresperpage']) );
        
    if (
$vbulletin->options['distinctscores'])
    {
        
$sk_usedusers = array();
        
$scorecache = array();
        while( 
$score $db->fetch_array($scores) )
        {
            if( 
$sk_usedusers$score[userid] ] ) continue; 
            
$sk_usedusers$score[userid] ] = true;
            
            
$scorecache[] = "arcade_sessions.sessionid=$score[sessionid]";
        }
        
$scorecache implode(' OR '$scorecache);
                
        
$scores $db->query_read("SELECT arcade_sessions.*, user.username, user.arcadeoptions FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
        WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid] AND ($scorecache)
        ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
        LIMIT " 
$vbulletin->options['scoresperpage']);
    } 
also find this: (there is some small differences from the code above)
PHP Code:
    // Time for the scores.
    
$scores $db->query_read("SELECT arcade_sessions.*, user.username" iif($vbulletin->options['distinctscores'], ", " iif($game['isreverse']==1'MIN''MAX') . "(arcade_sessions.score) AS score") . " FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
    LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
    WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid]
    " 
iif($vbulletin->options['distinctscores'], "GROUP BY arcade_sessions.userid") . "
    ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
    LIMIT 
$start, " $vbulletin->options['scoresperpage']);
    
    if (
$vbulletin->options['distinctscores'])
    {
        
$scorecache = array();
        while (
$score $db->fetch_array($scores))
        {
            
$scorecache[] = "(arcade_sessions.score='$score[score]' AND arcade_sessions.userid=$score[userid])";
        }
        
$scorecache implode(' OR '$scorecache);
        
        
$scores $db->query_read("SELECT arcade_sessions.*, user.username FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
        WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid] " iif($scorecache"AND ($scorecache)") . "
        ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
        LIMIT " 
$vbulletin->options['scoresperpage']);
    } 
Replace it with:
PHP Code:
    // Time for the scores.
    // Replaced code for finding scores, so it won't show duplicates on players with the same score. /SK
    
$scores $db->query_read("SELECT arcade_sessions.*, user.username FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
    LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
    WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid]
    ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
    " 
iif( !$vbulletin->options['distinctscores'], " LIMIT $start, " $vbulletin->options['scoresperpage']) );

    if (
$vbulletin->options['distinctscores'])
    {
        
$sk_usedusers = array();
        
$scorecache = array();
        while( 
$score $db->fetch_array($scores) )
        {
            if( 
$sk_usedusers$score[userid] ] ) continue; 
            
$sk_usedusers$score[userid] ] = true;
            
            
$scorecache[] = "arcade_sessions.sessionid=$score[sessionid]";
        }
        
$scorecache implode(' OR '$scorecache);
        
        
$scores $db->query_read("SELECT arcade_sessions.userid, arcade_sessions.*, user.username FROM " TABLE_PREFIX "arcade_sessions AS arcade_sessions
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid=arcade_sessions.userid)
        WHERE arcade_sessions.valid=1 AND arcade_sessions.gameid=
$game[gameid] " iif($scorecache"AND ($scorecache)") . "
        ORDER BY score " 
iif($game['isreverse']==1'ASC''DESC') . ", arcade_sessions.finish DESC
        LIMIT 
$start, " $vbulletin->options['scoresperpage']);
    } 
/SK
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01346 seconds
  • Memory Usage 1,891KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete