The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
|
#1
|
||||
|
||||
![]()
I'm currently trying to develop a mod that adds a setting in the Game Settings of the Admin CP which allows you to select whether or not you want to enable "Reverse Scoring" for each game. Some games are built that lower scores are actually BETTER than higher ones, and this mod intends to cater for those games..
In order to do this, a cache needs to be built so that the best scores shown on the main Arcade page are shown, whether they're highest or lowest depending on the game's setting. Originally I'd tried a single query on the arcade.php file, like this (for personal bests): Code:
$getGames = $DB_site->query_first("SELECT * FROM " . TABLE_PREFIX . "games"); // Personal bests - returns PB in form of an array, $personalBest[shortname] $personalBest = array(); if ($gamesettings[$getGames[shortname]][scoredir] == 0) { $result_pb = $DB_site->query(" SELECT gamename, MAX(score) AS score FROM " . TABLE_PREFIX . "gamesessions AS gamesessions WHERE valid=1 AND $sessionclause AND userid=$bbuserinfo[userid] GROUP BY gamename "); } else { $result_pb = $DB_site->query(" SELECT gamename, MIN(score) AS score FROM " . TABLE_PREFIX . "gamesessions AS gamesessions WHERE valid=1 AND $sessionclause AND userid=$bbuserinfo[userid] GROUP BY gamename "); } while ($bestArray = $DB_site->fetch_array($result_pb)) { $personalBest[$bestArray[gamename]] = $bestArray[score]; } $DB_site->free_result($result_pb); This is the cache I tried to build in the functions_arcade.php file: Code:
function fetch_scoredircache() { global $DB_site, $scoredircache; if (!is_array($scoredircache)) { $scoredircache = array(); $allgames = $DB_site->query(" SELECT * FROM " . TABLE_PREFIX . "games "); while($gamearray = $DB_site->fetch_array($allgames)) { $scoredircache["$gamearray[shortname]"] = $gamearray; } $DB_site->free_result($allgames); } } Code:
$getGames = fetch_scoredircache($gameid); // Personal bests - returns PB in form of an array, $personalBest[shortname] $personalBest = array(); if ($gamesettings[$getGames['scoredir']] == 0) { $result_pb = $DB_site->query(" SELECT gamename, MAX(score) AS score FROM " . TABLE_PREFIX . "gamesessions AS gamesessions WHERE valid=1 AND $sessionclause AND userid=$bbuserinfo[userid] GROUP BY gamename "); } else { $result_pb = $DB_site->query(" SELECT gamename, MIN(score) AS score FROM " . TABLE_PREFIX . "gamesessions AS gamesessions WHERE valid=1 AND $sessionclause AND userid=$bbuserinfo[userid] GROUP BY gamename "); } while ($bestArray = $DB_site->fetch_array($result_pb)) { $personalBest[$bestArray[gamename]] = $bestArray[score]; } $DB_site->free_result($result_pb); If anyone could offer any assistance, it'd be a huge help.. I'm still very much learning this stuff (as you can probably tell). :nervous: |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|