Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
14240 lines (12205 sloc) 605 KB
<?php
/*
* Plugin: Records Eyepiece
* ~~~~~~~~~~~~~~~~~~~~~~~~
* » A fully configurable HUD for all type of records and gamemodes.
*
* ----------------------------------------------------------------------------------
*
* LICENSE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ----------------------------------------------------------------------------------
*
*/
// Start the plugin
$_PLUGIN = new PluginRecordsEyepiece();
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
class PluginRecordsEyepiece extends Plugin {
public $config = array();
public $scores = array();
public $cache = array();
public $templates = array();
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function __construct () {
global $aseco;
$this->setAuthor('undef.de');
$this->setContributors('.anDy', 'Bueddl');
$this->setVersion('1.1.3');
$this->setBuild('2019-08-27');
$this->setCopyright('2009 - 2019 by undef.de');
$this->setDescription('A fully configurable HUD for all type of records and gamemodes.');
$this->addDependence('PluginModescriptHandler', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginCheckpoints', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginLocalRecords', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginWelcomeCenter', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginManiaExchange', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginRasp', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginRaspJukebox', Dependence::REQUIRED, '1.0.0', null);
$this->addDependence('PluginDedimania', Dependence::WANTED, '1.0.0', null);
$this->addDependence('PluginDonate', Dependence::WANTED, '1.0.0', null);
$this->addDependence('PluginMusicServer', Dependence::WANTED, '1.0.0', null);
$this->addDependence('PluginNouseBetting', Dependence::WANTED, '1.0.0', null);
$this->addDependence('PluginRoundPoints', Dependence::WANTED, '1.0.0', null);
$this->addDependence('PluginManiaKarma', Dependence::WANTED, '1.0.0', null);
$this->registerEvent('onSync', 'onSync');
$this->registerEvent('onPlayerConnect', 'onPlayerConnect');
$this->registerEvent('onPlayerDisconnectPrepare', 'onPlayerDisconnectPrepare');
$this->registerEvent('onPlayerDisconnect', 'onPlayerDisconnect');
$this->registerEvent('onPlayerInfoChanged', 'onPlayerInfoChanged');
$this->registerEvent('onPlayerRankingUpdated', 'onPlayerRankingUpdated');
$this->registerEvent('onPlayerFinishPrefix', 'onPlayerFinishPrefix');
$this->registerEvent('onPlayerWins', 'onPlayerWins');
$this->registerEvent('onPlayerManialinkPageAnswer', 'onPlayerManialinkPageAnswer');
$this->registerEvent('onDedimaniaRecordsLoaded', 'onDedimaniaRecordsLoaded');
$this->registerEvent('onDedimaniaRecord', 'onDedimaniaRecord');
$this->registerEvent('onLocalRecordsLoaded', 'onLocalRecordsLoaded');
$this->registerEvent('onLocalRecord', 'onLocalRecord');
$this->registerEvent('onWarmUpStatusChanged', 'onWarmUpStatusChanged');
$this->registerEvent('onLoadingMap', 'onLoadingMap');
$this->registerEvent('onUnloadingMap', 'onUnloadingMap');
$this->registerEvent('onBeginRound', 'onBeginRound');
$this->registerEvent('onEndRound', 'onEndRound');
$this->registerEvent('onRestartMap', 'onRestartMap');
$this->registerEvent('onEndMapRanking', 'onEndMapRanking');
$this->registerEvent('onEverySecond', 'onEverySecond');
$this->registerEvent('onKarmaChange', 'onKarmaChange');
$this->registerEvent('onDonation', 'onDonation');
$this->registerEvent('onMapListChanged', 'onMapListChanged');
$this->registerEvent('onMapListModified', 'onMapListModified');
$this->registerEvent('onJukeboxChanged', 'onJukeboxChanged');
$this->registerEvent('onMusicboxReloaded', 'onMusicboxReloaded');
$this->registerEvent('onShutdown', 'onShutdown');
$this->registerEvent('onVotingRestartMap', 'onVotingRestartMap'); // from plugin.vote_manager.php
$this->registerChatCommand('eyepiece', 'chat_eyepiece', 'Displays the help for the Records-Eyepiece widgets (see: /eyepiece)', Player::PLAYERS);
// $this->registerChatCommand('list', 'chat_list', 'Lists maps currently on the server (see: /eyepiece)', Player::PLAYERS);
$this->registerChatCommand('elist', 'chat_elist', 'Lists maps currently on the server (see: /eyepiece)', Player::PLAYERS);
$this->registerChatCommand('estat', 'chat_estat', 'Display one of the MoreRankingLists (see: /eyepiece)', Player::PLAYERS);
$this->registerChatCommand('eyeset', 'chat_eyeset', 'Adjust some settings for the Records-Eyepiece plugin (see: /eyepiece)', Player::MASTERADMINS);
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onSync ($aseco, $reload = null) {
// Read Configuration
if (!$this->config = $aseco->parser->xmlToArray('config/records_eyepiece.xml', true, true)) {
trigger_error('[RecordsEyepiece] Could not read/parse config file "config/records_eyepiece.xml"!', E_USER_ERROR);
}
$this->config = $this->config['SETTINGS'];
unset($this->config['SETTINGS']);
// Static settings
$this->config['LineHeight'] = 3.375;
$aseco->console('[RecordsEyepiece] ********************************************************');
$aseco->console('[RecordsEyepiece] Starting version '. $this->getVersion() .' - Maniaplanet');
$aseco->console('[RecordsEyepiece] Parsed "config/records_eyepiece.xml" successfully, starting checks...');
if ( !isset($this->config['MUSIC_WIDGET'][0]['ADVERTISE'][0])) {
$this->config['MUSIC_WIDGET'][0]['ADVERTISE'][0] = 'true';
}
// Transform 'TRUE' or 'FALSE' from string to boolean
$this->config['MAP_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['MAP_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['CLOCK_WIDGET'][0]['RACE'][0]['ENABLED'][0] = ((strtoupper($this->config['CLOCK_WIDGET'][0]['RACE'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['CLOCK_WIDGET'][0]['SCORE'][0]['ENABLED'][0] = ((strtoupper($this->config['CLOCK_WIDGET'][0]['SCORE'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['NEXT_ENVIRONMENT_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['NEXT_ENVIRONMENT_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['NEXT_GAMEMODE_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['NEXT_GAMEMODE_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['WINNING_PAYOUT'][0]['ENABLED'][0] = ((strtoupper($this->config['WINNING_PAYOUT'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['WINNING_PAYOUT'][0]['IGNORE'][0]['OPERATOR'][0] = ((strtoupper($this->config['WINNING_PAYOUT'][0]['IGNORE'][0]['OPERATOR'][0]) === 'TRUE') ? true : false);
$this->config['WINNING_PAYOUT'][0]['IGNORE'][0]['ADMIN'][0] = ((strtoupper($this->config['WINNING_PAYOUT'][0]['IGNORE'][0]['ADMIN'][0]) === 'TRUE') ? true : false);
$this->config['WINNING_PAYOUT'][0]['IGNORE'][0]['MASTERADMIN'][0] = ((strtoupper($this->config['WINNING_PAYOUT'][0]['IGNORE'][0]['MASTERADMIN'][0]) === 'TRUE') ? true : false);
$this->config['DONATION_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['DONATION_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['WARM_UP_INFO_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['WARM_UP_INFO_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['MULTILAP_INFO_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['MULTILAP_INFO_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['SPECTATOR_INFO_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['SPECTATOR_INFO_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['VISITORS_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['VISITORS_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['FAVORITE_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['FAVORITE_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['TOPLIST_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['TOPLIST_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['MANIAEXCHANGE_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['MANIAEXCHANGE_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['MAPCOUNT_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['MAPCOUNT_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['MUSIC_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['MUSIC_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['MUSIC_WIDGET'][0]['ADVERTISE'][0] = ((strtoupper($this->config['MUSIC_WIDGET'][0]['ADVERTISE'][0]) === 'TRUE') ? true : false);
$this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0] = ((strtoupper($this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['NICEMODE'][0]['ENABLED'][0] = ((strtoupper($this->config['NICEMODE'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['NICEMODE'][0]['FORCE'][0] = ((strtoupper($this->config['NICEMODE'][0]['FORCE'][0]) === 'TRUE') ? true : false);
$this->config['STYLE'][0]['WINDOW'][0]['LIGHTBOX'][0]['ENABLED'][0] = ((strtoupper($this->config['STYLE'][0]['WINDOW'][0]['LIGHTBOX'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['SCORETABLE_LISTS'][0]['TOP_BETWINS'][0]['DISPLAY'][0] = ((strtoupper($this->config['SCORETABLE_LISTS'][0]['TOP_BETWINS'][0]['DISPLAY'][0]) === 'AVERAGE') ? true : false);
$this->config['UI_PROPERTIES'][0]['MAP_INFO'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['MAP_INFO'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['ROUND_SCORES'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['ROUND_SCORES'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['WARMUP'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['WARMUP'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['ENDMAP_LADDER_RECAP'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['ENDMAP_LADDER_RECAP'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['MULTILAP_INFO'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['MULTILAP_INFO'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['POSITION'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['POSITION'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['SPEED_AND_DISTANCE'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['SPEED_AND_DISTANCE'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['PERSONAL_BEST_AND_RANK'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['PERSONAL_BEST_AND_RANK'][0]) === 'TRUE') ? true : false);
$this->config['UI_PROPERTIES'][0]['CHECKPOINT_LIST'][0] = ((strtoupper($this->config['UI_PROPERTIES'][0]['CHECKPOINT_LIST'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['MARK_ONLINE_PLAYER_RECORDS'][0] = ((strtoupper($this->config['FEATURES'][0]['MARK_ONLINE_PLAYER_RECORDS'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['ILLUMINATE_NAMES'][0] = ((strtoupper($this->config['FEATURES'][0]['ILLUMINATE_NAMES'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['NUMBER_FORMAT'][0] = strtolower($this->config['FEATURES'][0]['NUMBER_FORMAT'][0]);
$this->config['FEATURES'][0]['SHORTEN_NUMBERS'][0] = ((strtoupper($this->config['FEATURES'][0]['SHORTEN_NUMBERS'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['SONGLIST'][0]['SORTING'][0] = ((strtoupper($this->config['FEATURES'][0]['SONGLIST'][0]['SORTING'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['SONGLIST'][0]['FORCE_SONGLIST'][0] = ((strtoupper($this->config['FEATURES'][0]['SONGLIST'][0]['FORCE_SONGLIST'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['MAPLIST'][0]['SORTING'][0] = strtoupper($this->config['FEATURES'][0]['MAPLIST'][0]['SORTING'][0]);
$this->config['FEATURES'][0]['MAPLIST'][0]['FORCE_MAPLIST'][0] = ((strtoupper($this->config['FEATURES'][0]['MAPLIST'][0]['FORCE_MAPLIST'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['MAPLIST'][0]['MAPIMAGES'][0]['ENABLED'][0] = ((strtoupper($this->config['FEATURES'][0]['MAPLIST'][0]['MAPIMAGES'][0]['ENABLED'][0]) === 'TRUE') ? true : false);
$this->config['FEATURES'][0]['KARMA'][0]['CALCULATION_METHOD'][0] = strtolower($this->config['FEATURES'][0]['KARMA'][0]['CALCULATION_METHOD'][0]);
// Autodisable unsupported Widgets in some Gamemodes
$this->config['DEDIMANIA_RECORDS'][0]['GAMEMODE'][0]['CHASE'][0]['ENABLED'][0] = 'false';
$this->config['LOCAL_RECORDS'][0]['GAMEMODE'][0]['CHASE'][0]['ENABLED'][0] = 'false';
$this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['CHASE'][0]['ENABLED'][0] = 'false';
$this->config['ROUND_SCORE'][0]['GAMEMODE'][0]['TIME_ATTACK'][0]['ENABLED'][0] = 'false';
$this->config['ROUND_SCORE'][0]['GAMEMODE'][0]['KNOCKOUT'][0]['ENABLED'][0] = 'false';
$this->config['ROUND_SCORE'][0]['GAMEMODE'][0]['DOPPLER'][0]['ENABLED'][0] = 'false';
$widgets = array('DEDIMANIA_RECORDS', 'LOCAL_RECORDS', 'LIVE_RANKINGS', 'ROUND_SCORE');
$gamemodes = array(
'ROUNDS' => Gameinfo::ROUNDS,
'TIME_ATTACK' => Gameinfo::TIME_ATTACK,
'TEAM' => Gameinfo::TEAM,
'LAPS' => Gameinfo::LAPS,
'CUP' => Gameinfo::CUP,
'TEAM_ATTACK' => Gameinfo::TEAM_ATTACK,
'CHASE' => Gameinfo::CHASE,
'KNOCKOUT' => Gameinfo::KNOCKOUT,
'DOPPLER' => Gameinfo::DOPPLER,
);
// RecordWidgets like Dedimania...
foreach ($gamemodes as $gamemode => $id) {
foreach ($widgets as $widget) {
if (isset($this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0])) {
$this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] = ((strtoupper($this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0]) === 'TRUE') ? true : false);
// Topcount are required to be lower then entries.
// But not in 'Team', both need to be '2'
if ( (isset($this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['TOPCOUNT'][0])) && (isset($this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENTRIES'][0]))) {
if ( ($widget === 'LIVE_RANKINGS') && ($gamemode === 'TEAM')) {
$this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENTRIES'][0] = 2;
$this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['TOPCOUNT'][0] = 2;
}
else {
if ($this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['TOPCOUNT'][0] >= $this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENTRIES'][0]) {
$this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['TOPCOUNT'][0] = $this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENTRIES'][0] - 1;
}
}
}
// Setup scale factor
if ( (!isset($this->config[$widget][0]['SCALE'][0])) || ($this->config[$widget][0]['SCALE'][0] > 1.0)) {
$this->config[$widget][0]['SCALE'][0] = 1.0;
}
$this->config[$widget][0]['SCALE'][0] = (float)$this->config[$widget][0]['SCALE'][0];
}
else {
// Auto disable this
$this->config[$widget][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] = false;
$this->config[$widget][0]['WIDTH'][0] = 0;
$aseco->console('[RecordsEyepiece] » Auto disable <'. strtolower($widget) .'> in gamemode "'. strtolower($gamemode) .'", missing entry.');
}
}
}
unset($id, $widget);
// Special checks for <rounds>
if ($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['ROUNDS'][0]['ENABLED'][0] === true) {
$this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['ROUNDS'][0]['DISPLAY_TYPE'][0] = ((strtoupper($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['ROUNDS'][0]['DISPLAY_TYPE'][0]) === 'TIME') ? true : false);
$format = ((isset($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['ROUNDS'][0]['FORMAT'][0])) ? $this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['ROUNDS'][0]['FORMAT'][0] : false);
if ( (preg_match('/\{score\}/', $format) === 0) && ((preg_match('/\{remaining\}/', $format) === 0) || (preg_match('/\{pointlimit\}/', $format) === 0))) {
// Setup default
$this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['ROUNDS'][0]['FORMAT'][0] = '{score} ({remaining})';
$aseco->console('[RecordsEyepiece] » LiveRankingsWidget placeholder not (complete) found, setup default format: "{score} ({remaining})"');
}
}
// Special checks for <laps>
if ($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['LAPS'][0]['ENABLED'][0] === true) {
$this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['LAPS'][0]['DISPLAY_TYPE'][0] = ((strtoupper($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0]['LAPS'][0]['DISPLAY_TYPE'][0]) === 'TIME') ? true : false);
}
// Check all Widgets in NiceMode
foreach ($widgets as $widget) {
if (isset($this->config['NICEMODE'][0]['ALLOW'][0][$widget][0])) {
$this->config['NICEMODE'][0]['ALLOW'][0][$widget][0] = ((strtoupper($this->config['NICEMODE'][0]['ALLOW'][0][$widget][0]) === 'TRUE') ? true : false);
}
}
unset($widget);
// All Scoretable-Lists
$scorelists = array('TOP_AVERAGE_TIMES', 'DEDIMANIA_RECORDS', 'LOCAL_RECORDS', 'TOP_RANKINGS', 'TOP_WINNERS', 'MOST_RECORDS', 'MOST_FINISHED', 'TOP_PLAYTIME', 'TOP_DONATORS', 'TOP_NATIONS', 'TOP_CONTINENTS', 'TOP_MAPS', 'TOP_VOTERS', 'TOP_VISITORS', 'TOP_ACTIVE_PLAYERS', 'TOP_WINNING_PAYOUTS', 'TOP_BETWINS', 'TOP_ROUNDSCORE');
foreach ($scorelists as $widget) {
if (isset($this->config['SCORETABLE_LISTS'][0][$widget][0]['ENABLED'][0])) {
$this->config['SCORETABLE_LISTS'][0][$widget][0]['ENABLED'][0] = ((strtoupper($this->config['SCORETABLE_LISTS'][0][$widget][0]['ENABLED'][0]) === 'TRUE') ? true : false);
}
else {
// Auto disable this
$this->config['SCORETABLE_LISTS'][0][$widget][0]['ENABLED'][0] = false;
$aseco->console('[RecordsEyepiece] » Auto disable <'. strtolower($widget) .'> from <scoretable_lists>, missing entry.');
}
// Setup scale factor
if ( (!isset($this->config['SCORETABLE_LISTS'][0][$widget][0]['SCALE'][0])) || ($this->config['SCORETABLE_LISTS'][0][$widget][0]['SCALE'][0] > 1.0)) {
$this->config['SCORETABLE_LISTS'][0][$widget][0]['SCALE'][0] = 1.0;
}
$this->config['SCORETABLE_LISTS'][0][$widget][0]['SCALE'][0] = $aseco->formatFloat($this->config['SCORETABLE_LISTS'][0][$widget][0]['SCALE'][0]);
}
unset($widget);
unset($scorelists);
// Translate e.g. 'rounds' to id '1', 'time_attack' to id '2'...
foreach ($widgets as $widget) {
foreach ($gamemodes as $gamemode => $id) {
if (isset($this->config[$widget][0]['GAMEMODE'][0][$gamemode])) {
$this->config[$widget][0]['GAMEMODE'][0][$id] = $this->config[$widget][0]['GAMEMODE'][0][$gamemode];
unset($this->config[$widget][0]['GAMEMODE'][0][$gamemode]);
}
}
}
unset($widgets, $widget, $id);
// Autodisable unsupported Widgets in some Gamemodes
$this->config['LOCAL_RECORDS'][0]['GAMEMODE'][0][Gameinfo::CHASE][0]['ENABLED'][0] = false;
$this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0][Gameinfo::CHASE][0]['ENABLED'][0] = false;
$this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::TIME_ATTACK][0]['ENABLED'][0] = false;
$this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::KNOCKOUT][0]['ENABLED'][0] = false;
$this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::DOPPLER][0]['ENABLED'][0] = false;
// Register /emusic chat command if the MusicWidget is enabled
if ($this->config['MUSIC_WIDGET'][0]['ENABLED'][0] === true) {
if (!isset($aseco->plugins['PluginMusicServer'])) {
if ($reload !== true) {
$aseco->console('[RecordsEyepiece] » Plugin MusicServer is not available, hide <music_widget>.');
}
$this->config['MUSIC_WIDGET'][0]['ENABLED'][0] = false;
}
else {
if ($reload !== true && $aseco->changing_to_gamemode === false) {
$aseco->console('[RecordsEyepiece] » Registering chat command "/emusic", because <music_widget> is enabled too.');
$aseco->registerChatCommand('emusic', array($this, 'chat_emusic'), 'Lists musics currently on the server (see: /eyepiece)', Player::PLAYERS);
}
}
}
// Check the Widget width's
if ( ($this->config['MUSIC_WIDGET'][0]['WIDTH'][0] < 15.5) || (!$this->config['MUSIC_WIDGET'][0]['WIDTH'][0])) {
$this->config['MUSIC_WIDGET'][0]['WIDTH'][0] = 15.5;
}
if ( ($this->config['DEDIMANIA_RECORDS'][0]['WIDTH'][0] < 15.5) || (!$this->config['DEDIMANIA_RECORDS'][0]['WIDTH'][0])) {
$this->config['DEDIMANIA_RECORDS'][0]['WIDTH'][0] = 15.5;
}
if ( ($this->config['LOCAL_RECORDS'][0]['WIDTH'][0] < 15.5) || (!$this->config['LOCAL_RECORDS'][0]['WIDTH'][0])) {
$this->config['LOCAL_RECORDS'][0]['WIDTH'][0] = 15.5;
}
if ( ($this->config['LIVE_RANKINGS'][0]['WIDTH'][0] < 15.5) || (!$this->config['LIVE_RANKINGS'][0]['WIDTH'][0])) {
$this->config['LIVE_RANKINGS'][0]['WIDTH'][0] = 15.5;
}
if ( ($this->config['ROUND_SCORE'][0]['WIDTH'][0] < 15.5) || (!$this->config['ROUND_SCORE'][0]['WIDTH'][0])) {
$this->config['ROUND_SCORE'][0]['WIDTH'][0] = 15.5;
}
if ( (!isset($this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0])) || ($this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0] === '')) {
$this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0] = 0;
}
if ( (!isset($this->config['FEATURES'][0]['KARMA'][0]['MIN_VOTES'][0])) || ($this->config['FEATURES'][0]['KARMA'][0]['MIN_VOTES'][0] === '')) {
$this->config['FEATURES'][0]['KARMA'][0]['MIN_VOTES'][0] = 0;
}
if ( (!isset($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0])) || ($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0] === '')) {
$this->config['FEATURES'][0]['TOPLIST_LIMIT'][0] = 5000;
}
// Check for additional Features
if ( ($this->config['DEDIMANIA_RECORDS'][0]['DISPLAY_MAX_RECORDS'][0] < 0) || (!$this->config['DEDIMANIA_RECORDS'][0]['DISPLAY_MAX_RECORDS'][0])) {
$this->config['DEDIMANIA_RECORDS'][0]['DISPLAY_MAX_RECORDS'][0] = 0;
}
else {
$this->config['DEDIMANIA_RECORDS'][0]['DISPLAY_MAX_RECORDS'][0] = (int)$this->config['DEDIMANIA_RECORDS'][0]['DISPLAY_MAX_RECORDS'][0];
}
// Check for Background-Colors
if ($this->config['STYLE'][0]['WIDGET_RACE'][0]['BACKGROUND_DEFAULT'][0] === '') {
$this->config['STYLE'][0]['WIDGET_RACE'][0]['BACKGROUND_DEFAULT'][0] = '0000';
}
if ($this->config['STYLE'][0]['WIDGET_RACE'][0]['BACKGROUND_FOCUS'][0] === '') {
$this->config['STYLE'][0]['WIDGET_RACE'][0]['BACKGROUND_FOCUS'][0] = '0000';
}
// Check for additional settings
if ($this->config['FEATURES'][0]['MAPLIST'][0]['MAPIMAGES'][0]['ENABLED'][0] === true) {
if (($this->config['FEATURES'][0]['MAPLIST'][0]['MAPIMAGES'][0]['ACCESS_URL'][0] === '') || (preg_match('/^http.*/', $this->config['FEATURES'][0]['MAPLIST'][0]['MAPIMAGES'][0]['ACCESS_URL'][0]) === 0)) {
// Autodisable
$this->config['FEATURES'][0]['MAPLIST'][0]['MAPIMAGES'][0]['ENABLED'][0] = false;
$aseco->console('[RecordsEyepiece] » Setup for <features><maplist><mapimages><access_url> is not correct in "records_eyepiece.xml"');
}
}
if (!isset($this->config['FEATURES'][0]['MAPLIST'][0]['AUTHOR_DISPLAY'][0]) || empty($this->config['FEATURES'][0]['MAPLIST'][0]['AUTHOR_DISPLAY'][0])) {
$this->config['FEATURES'][0]['MAPLIST'][0]['AUTHOR_DISPLAY'][0] = 'nickname';
}
if ($this->config['MAP_WIDGET'][0]['ENABLED'][0] === true) {
if ( (isset($this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0])) && (strtoupper($this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0]) === 'NEXT')) {
$this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0] = 'next';
}
else if ( (isset($this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0])) && (strtoupper($this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0]) === 'CURRENT')) {
$this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0] = 'current';
}
else {
$this->config['MAP_WIDGET'][0]['SCORE'][0]['DISPLAY'][0] = 'next';
}
if ( (!isset($this->config['MAP_WIDGET'][0]['RACE'][0]['SCALE'][0])) || ($this->config['MAP_WIDGET'][0]['RACE'][0]['SCALE'][0] > 1.0)) {
$this->config['MAP_WIDGET'][0]['RACE'][0]['SCALE'][0] = 1.0;
}
if ( (!isset($this->config['MAP_WIDGET'][0]['SCORE'][0]['SCALE'][0])) || ($this->config['MAP_WIDGET'][0]['SCORE'][0]['SCALE'][0] > 1.0)) {
$this->config['MAP_WIDGET'][0]['SCORE'][0]['SCALE'][0] = 1.0;
}
$this->config['MAP_WIDGET'][0]['RACE'][0]['SCALE'][0] = $aseco->formatFloat($this->config['MAP_WIDGET'][0]['RACE'][0]['SCALE'][0]);
$this->config['MAP_WIDGET'][0]['SCORE'][0]['SCALE'][0] = $aseco->formatFloat($this->config['MAP_WIDGET'][0]['SCORE'][0]['SCALE'][0]);
}
if ( (!isset($this->config['MUSIC_WIDGET'][0]['SCALE'][0])) || ($this->config['MUSIC_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['MUSIC_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['MUSIC_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['MUSIC_WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['WINNING_PAYOUT'][0]['WIDGET'][0]['SCALE'][0])) || ($this->config['WINNING_PAYOUT'][0]['WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['WINNING_PAYOUT'][0]['WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['WINNING_PAYOUT'][0]['WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['WINNING_PAYOUT'][0]['WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['DONATION_WIDGET'][0]['WIDGET'][0]['SCALE'][0])) || ($this->config['DONATION_WIDGET'][0]['WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['DONATION_WIDGET'][0]['WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['DONATION_WIDGET'][0]['WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['DONATION_WIDGET'][0]['WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['MANIAEXCHANGE_WIDGET'][0]['SCALE'][0])) || ($this->config['MANIAEXCHANGE_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['MANIAEXCHANGE_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['MANIAEXCHANGE_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['MANIAEXCHANGE_WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['TOPLIST_WIDGET'][0]['SCALE'][0])) || ($this->config['TOPLIST_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['TOPLIST_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['TOPLIST_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['TOPLIST_WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['MAPCOUNT_WIDGET'][0]['SCALE'][0])) || ($this->config['MAPCOUNT_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['MAPCOUNT_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['MAPCOUNT_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['MAPCOUNT_WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['VISITORS_WIDGET'][0]['SCALE'][0])) || ($this->config['VISITORS_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['VISITORS_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['VISITORS_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['VISITORS_WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['CLOCK_WIDGET'][0]['RACE'][0]['SCALE'][0])) || ($this->config['CLOCK_WIDGET'][0]['RACE'][0]['SCALE'][0] > 1.0)) {
$this->config['CLOCK_WIDGET'][0]['RACE'][0]['SCALE'][0] = 1.0;
}
$this->config['CLOCK_WIDGET'][0]['RACE'][0]['SCALE'][0] = $aseco->formatFloat($this->config['CLOCK_WIDGET'][0]['RACE'][0]['SCALE'][0]);
if ( (!isset($this->config['CLOCK_WIDGET'][0]['SCORE'][0]['SCALE'][0])) || ($this->config['CLOCK_WIDGET'][0]['SCORE'][0]['SCALE'][0] > 1.0)) {
$this->config['CLOCK_WIDGET'][0]['SCORE'][0]['SCALE'][0] = 1.0;
}
$this->config['CLOCK_WIDGET'][0]['SCORE'][0]['SCALE'][0] = $aseco->formatFloat($this->config['CLOCK_WIDGET'][0]['SCORE'][0]['SCALE'][0]);
if ( (!isset($this->config['FAVORITE_WIDGET'][0]['RACE'][0]['SCALE'][0])) || ($this->config['FAVORITE_WIDGET'][0]['RACE'][0]['SCALE'][0] > 1.0)) {
$this->config['FAVORITE_WIDGET'][0]['RACE'][0]['SCALE'][0] = 1.0;
}
$this->config['FAVORITE_WIDGET'][0]['RACE'][0]['SCALE'][0] = $aseco->formatFloat($this->config['FAVORITE_WIDGET'][0]['RACE'][0]['SCALE'][0]);
if ( (!isset($this->config['FAVORITE_WIDGET'][0]['SCORE'][0]['SCALE'][0])) || ($this->config['FAVORITE_WIDGET'][0]['SCORE'][0]['SCALE'][0] > 1.0)) {
$this->config['FAVORITE_WIDGET'][0]['SCORE'][0]['SCALE'][0] = 1.0;
}
$this->config['FAVORITE_WIDGET'][0]['SCORE'][0]['SCALE'][0] = $aseco->formatFloat($this->config['FAVORITE_WIDGET'][0]['SCORE'][0]['SCALE'][0]);
if ( (!isset($this->config['NEXT_ENVIRONMENT_WIDGET'][0]['SCALE'][0])) || ($this->config['NEXT_ENVIRONMENT_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['NEXT_ENVIRONMENT_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['NEXT_ENVIRONMENT_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['NEXT_ENVIRONMENT_WIDGET'][0]['SCALE'][0]);
if ( (!isset($this->config['NEXT_GAMEMODE_WIDGET'][0]['SCALE'][0])) || ($this->config['NEXT_GAMEMODE_WIDGET'][0]['SCALE'][0] > 1.0)) {
$this->config['NEXT_GAMEMODE_WIDGET'][0]['SCALE'][0] = 1.0;
}
$this->config['NEXT_GAMEMODE_WIDGET'][0]['SCALE'][0] = $aseco->formatFloat($this->config['NEXT_GAMEMODE_WIDGET'][0]['SCALE'][0]);
if ($this->config['WINNING_PAYOUT'][0]['ENABLED'][0] === true) {
// Check setup Limits
if ( (!$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['MINIMUM_AMOUNT'][0]) || ($this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['MINIMUM_AMOUNT'][0] < 3)) {
$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['MINIMUM_AMOUNT'][0] = 3;
}
if ( !$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['RANK_LIMIT'][0] ) {
$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['RANK_LIMIT'][0] = 0;
}
if ( !$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['MAXIMUM_PLANETS'][0] ) {
$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['MAXIMUM_PLANETS'][0] = 1000000; // Set to unlimited
}
if ( !$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['RESET_LIMIT'][0] ) {
$this->config['WINNING_PAYOUT'][0]['PLAYERS'][0]['RESET_LIMIT'][0] = 0; // Disable
}
// Check setup Planets
if ( (!$this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['FIRST'][0]) || ($this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['FIRST'][0] < 20)) {
$this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['FIRST'][0] = 20;
}
if ( (!$this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['SECOND'][0]) || ($this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['SECOND'][0] < 15)) {
$this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['SECOND'][0] = 15;
}
if ( (!$this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['THIRD'][0]) || ($this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['THIRD'][0] < 10)) {
$this->config['WINNING_PAYOUT'][0]['PAY_PLANETS'][0]['THIRD'][0] = 10;
}
if ( (!$this->config['WINNING_PAYOUT'][0]['MINIMUM_SERVER_PLANETS'][0]) || ($this->config['WINNING_PAYOUT'][0]['MINIMUM_SERVER_PLANETS'][0] < 50)) {
$this->config['WINNING_PAYOUT'][0]['MINIMUM_SERVER_PLANETS'][0] = 50;
}
// Check for the max. length (256 signs) of <messages><winning_mail_body>
$message = $aseco->formatText($this->config['MESSAGES'][0]['WINNING_MAIL_BODY'][0],
9999,
$aseco->server->login,
$aseco->server->name
);
$message = str_replace('{br}', "%0A", $message); // split long message
$message = $aseco->formatColors($message);
if (strlen($message) >= 256) {
trigger_error('[RecordsEyepiece] » The <messages><winning_mail_body> is '. strlen($message) .' signs long (incl. the replaced placeholder), please remove '. (strlen($message) - 256) .' signs to fit into 256 signs limit!', E_USER_ERROR);
}
}
// Initialise States
$this->config['States']['DedimaniaRecords']['NeedUpdate'] = true; // Interact with onDedimaniaRecord and onDediRecsLoaded
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = true;
$this->config['States']['DedimaniaRecords']['Visibility'] = true; // F9
$this->config['States']['LocalRecords']['NeedUpdate'] = true; // Interact with onLocalRecord
$this->config['States']['LocalRecords']['UpdateDisplay'] = true;
$this->config['States']['LocalRecords']['Visibility'] = true; // F9
$this->config['States']['LocalRecords']['NoRecordsFound'] = false;
$this->config['States']['LocalRecords']['ChkSum'] = false;
$this->config['States']['LiveRankings']['NeedUpdate'] = true; // Interact with onPlayerFinish
$this->config['States']['LiveRankings']['UpdateDisplay'] = true;
$this->config['States']['LiveRankings']['Visibility'] = true; // F9
$this->config['States']['LiveRankings']['NoRecordsFound'] = false;
$this->config['States']['MusicWidget']['Visibility'] = true; // F9
$this->config['States']['RoundScoreWidget']['Visibility'] = true; // F9
$this->config['States']['WarmUpPhase'] = false;
$this->config['States']['TopMaps']['NeedUpdate'] = true; // Interact with onKarmaChange
$this->config['States']['TopVoters']['NeedUpdate'] = true; // Interact with onKarmaChange
$this->config['States']['MusicServerPlaylist']['NeedUpdate'] = false;
$this->config['States']['NiceMode'] = false;
$this->config['States']['RefreshTimestampRecordWidgets'] = -1000; // Update now :D
$this->config['States']['RefreshTimestampPreload'] = time();
$this->config['States']['MaplistRefreshProgressed'] = false;
// Preset the Placeholder which can be used in <placement>, filled later when info loaded by XAseco
$this->config['PlacementPlaceholders']['MAP_MX_PREFIX'] = false;
$this->config['PlacementPlaceholders']['MAP_MX_ID'] = false;
$this->config['PlacementPlaceholders']['MAP_MX_PAGEURL'] = false;
$this->config['PlacementPlaceholders']['MAP_NAME'] = false;
$this->config['PlacementPlaceholders']['MAP_UID'] = false;
// Definitions of Icon- and Title-Positions for the RecordWidgets
$this->config['Positions'] = array(
'left' => array(
'icon' => array(
'x' => 2.8,
'y' => -2.53125
),
'title' => array(
'x' => 5.6,
'y' => -1.3125,
'halign' => 'left'
),
'image_open' => array(
'x' => -0.5,
'image' => $this->config['IMAGES'][0]['WIDGET_OPEN_LEFT'][0]
)
),
'right' => array(
'icon' => array(
'x' => -2.8,
'y' => -2.53125
),
'title' => array(
'x' => -5.6,
'y' => -1.3125,
'halign' => 'right'
),
'image_open' => array(
'x' => -8.25,
'image' => $this->config['IMAGES'][0]['WIDGET_OPEN_RIGHT'][0]
)
)
);
// Define the formats for number_format()
$this->config['NumberFormat'] = array(
'english' => array(
'decimal_sep' => '.',
'thousands_sep' => ',',
),
'german' => array(
'decimal_sep' => ',',
'thousands_sep' => '.',
),
'french' => array(
'decimal_sep' => ',',
'thousands_sep' => ' ',
),
);
// Load the templates
$this->loadTemplates();
// Initialise DataArrays
$this->scores['DedimaniaRecords'] = array();
$this->scores['LocalRecords'] = array();
$this->scores['LiveRankings'] = array();
$this->scores['RoundScore'] = array();
$this->scores['RoundScorePB'] = array();
$this->scores['TopAverageTimes'] = array();
$this->scores['TopRankings'] = array();
$this->scores['TopWinners'] = array();
$this->scores['MostRecords'] = array();
$this->scores['MostFinished'] = array();
$this->scores['TopPlaytime'] = array();
$this->scores['TopDonators'] = array();
$this->scores['TopNations'] = array();
$this->scores['TopMaps'] = array();
$this->scores['TopVoters'] = array();
$this->scores['TopBetwins'] = array();
$this->scores['TopRoundscore'] = array();
$this->scores['TopVisitors'] = array();
$this->scores['TopContinents'] = array();
$this->scores['TopActivePlayers'] = array();
$this->scores['TopWinningPayouts'] = array();
// Init Cache
$this->cache['SpectatorOverview'] = array();
$this->cache['WarmUpInfoWidget'] = false;
$this->cache['MultiLapInfoWidget'] = false;
$this->cache['MusicWidget'] = false;
$this->cache['ToplistWidget'] = false;
$this->cache['VisitorsWidget'] = false;
$this->cache['ManiaExchangeWidget'] = false;
$this->cache['MapcountWidget'] = false;
$this->cache['TopRankings'] = false;
$this->cache['TopWinners'] = false;
$this->cache['TopPlaytime'] = false;
$this->cache['TopNations'] = false;
$this->cache['TopMaps'] = false;
$this->cache['TopVoters'] = false;
$this->cache['TopWinningPayouts'] = false;
$this->cache['TopVisitors'] = false;
$this->cache['TopContinents'] = false;
$this->cache['TopActivePlayers'] = false;
$this->cache['TopBetwins'] = false;
$this->cache['TopRoundscore'] = false;
$this->cache['MapWidget']['Race'] = false;
$this->cache['MapWidget']['Score'] = false;
$this->cache['AddToFavoriteWidget']['Race'] = false;
$this->cache['AddToFavoriteWidget']['Score'] = false;
$this->cache['DonationWidget'] = false;
$this->cache['PlayerStates'] = array();
$this->cache['MusicServerPlaylist'] = array();
$this->cache['MapAuthors'] = array();
$this->cache['CurrentRankings'] = array();
$this->cache['MapAuthorNation'] = $this->loadPlayerNations();
if ( !isset($this->cache['PlayerWinnings'])) {
// Only setup if unset, otherwise it is overridden by "/eyeset reload"!
$this->cache['PlayerWinnings'] = array();
}
// Setup the RecordWidgets and prebuild all enabled Gamemodes
$aseco->console('[RecordsEyepiece] » Build and cache all Widget bodies...');
$this->cache['DedimaniaRecords']['NiceMode'] = false;
$this->cache['LocalRecords']['NiceMode'] = false;
$this->cache['LiveRankings']['NiceMode'] = false;
$widgets = array('DEDIMANIA_RECORDS', 'LOCAL_RECORDS', 'LIVE_RANKINGS', 'ROUND_SCORE');
foreach ($widgets as $widget) {
foreach ($gamemodes as $gamemode => $id) {
if ( ($widget === 'DEDIMANIA_RECORDS') && (($this->config[$widget][0]['GAMEMODE'][0][$id][0]['ENABLED'][0] === true) || (($this->config['NICEMODE'][0]['ALLOW'][0]['DEDIMANIA_RECORDS'][0] === true) && ($this->config['States']['NiceMode'] === true)))) {
$build = $this->buildDedimaniaRecordsWidgetBody($id);
$this->cache['DedimaniaRecords'][$id]['WidgetHeader'] = $build['header'];
$this->cache['DedimaniaRecords'][$id]['WidgetFooter'] = $build['footer'];
}
if ( ($widget === 'LOCAL_RECORDS') && (($this->config[$widget][0]['GAMEMODE'][0][$id][0]['ENABLED'][0] === true) || (($this->config['NICEMODE'][0]['ALLOW'][0]['LOCAL_RECORDS'][0] === true) && ($this->config['States']['NiceMode'] === true)))) {
$build = $this->buildLocalRecordsWidgetBody($id);
$this->cache['LocalRecords'][$id]['WidgetHeader'] = $build['header'];
$this->cache['LocalRecords'][$id]['WidgetFooter'] = $build['footer'];
}
if ( ($widget === 'LIVE_RANKINGS') && (($this->config[$widget][0]['GAMEMODE'][0][$id][0]['ENABLED'][0] === true) || (($this->config['NICEMODE'][0]['ALLOW'][0]['LIVE_RANKINGS'][0] === true) && ($this->config['States']['NiceMode'] === true)))) {
$build = $this->buildLiveRankingsWidgetBody($id);
$this->cache['LiveRankings'][$id]['WidgetHeader'] = $build['header'];
$this->cache['LiveRankings'][$id]['WidgetFooter'] = $build['footer'];
}
if ( ($widget === 'ROUND_SCORE') && ($this->config[$widget][0]['GAMEMODE'][0][$id][0]['ENABLED'][0] === true)) {
$build = $this->buildRoundScoreWidgetBody($id, 'RACE');
$this->cache['RoundScore'][$id]['Race']['WidgetHeader'] = $build['header'];
$this->cache['RoundScore'][$id]['Race']['WidgetFooter'] = $build['footer'];
$build = $this->buildRoundScoreWidgetBody($id, 'WARMUP');
$this->cache['RoundScore'][$id]['WarmUp']['WidgetHeader'] = $build['header'];
$this->cache['RoundScore'][$id]['WarmUp']['WidgetFooter'] = $build['footer'];
}
}
}
unset($widgets, $widget, $gamemode, $id);
// Make sure refresh's are set, otherwise set default
$this->config['FEATURES'][0]['REFRESH_INTERVAL'][0] = ((isset($this->config['FEATURES'][0]['REFRESH_INTERVAL'][0])) ? (int)$this->config['FEATURES'][0]['REFRESH_INTERVAL'][0] : 10);
$this->config['NICEMODE'][0]['REFRESH_INTERVAL'][0] = ((isset($this->config['NICEMODE'][0]['REFRESH_INTERVAL'][0])) ? (int)$this->config['NICEMODE'][0]['REFRESH_INTERVAL'][0] : 10);
// Store the default refresh interval, in NiceMode the $this->config['FEATURES'][0]['REFRESH_INTERVAL'][0] are replaced
$this->config['REFRESH_INTERVAL_DEFAULT'][0] = $this->config['FEATURES'][0]['REFRESH_INTERVAL'][0];
// Stores $this->getCurrentSong() the ListMethod GetForcedMusic()
$this->config['CurrentMusicInfos'] = array(
'Artist' => 'unknown',
'Title' => 'unknown',
);
$this->cache['Map']['Jukebox'] = false;
$this->cache['Map']['NbCheckpoints'] = 0;
$this->cache['Map']['NbLaps'] = 0;
$this->cache['Map']['ForcedLaps'] = 0;
$this->config['Gamemodes'] = array(
Gameinfo::ROUNDS => array('name' => 'ROUNDS', 'icon' => 'RT_Rounds'),
Gameinfo::TIME_ATTACK => array('name' => 'TIME ATTACK', 'icon' => 'RT_TimeAttack'),
Gameinfo::TEAM => array('name' => 'TEAM', 'icon' => 'RT_Team'),
Gameinfo::LAPS => array('name' => 'LAPS', 'icon' => 'RT_Laps'),
Gameinfo::CUP => array('name' => 'CUP', 'icon' => 'RT_Cup'),
Gameinfo::TEAM_ATTACK => array('name' => 'TEAM ATTACK', 'icon' => 'RT_Team'),
Gameinfo::CHASE => array('name' => 'CHASE', 'icon' => 'RT_Team'),
Gameinfo::KNOCKOUT => array('name' => 'KNOCKOUT', 'icon' => 'RT_Rounds'),
Gameinfo::DOPPLER => array('name' => 'DOPPLER', 'icon' => 'RT_TimeAttack'),
);
if ($reload === null) {
$aseco->console('[RecordsEyepiece] » Checking Database for required extensions...');
// Check the Database-Table for required extensions
$fields = array();
$result = $aseco->db->query('SHOW COLUMNS FROM `%prefix%players`;');
if ($result) {
while ($row = $result->fetch_row()) {
$fields[] = $row[0];
}
$result->free_result();
}
// Add `MostFinished` column if not yet done
if ( !in_array('MostFinished', $fields)) {
$aseco->console('[RecordsEyepiece] » Adding column `MostFinished`.');
$aseco->db->query('ALTER TABLE `%prefix%players` ADD `MostFinished` MEDIUMINT(3) UNSIGNED NOT NULL DEFAULT "0" COMMENT "Added by plugin.records_eyepiece.php", ADD INDEX (`MostFinished`);');
}
else {
$aseco->console('[RecordsEyepiece] » Found column `MostFinished`');
}
// Add `MostRecords` column if not yet done
if ( !in_array('MostRecords', $fields)) {
$aseco->console('[RecordsEyepiece] » Adding column `MostRecords`.');
$aseco->db->query('ALTER TABLE `%prefix%players` ADD `MostRecords` MEDIUMINT(3) UNSIGNED NOT NULL DEFAULT "0" COMMENT "Added by plugin.records_eyepiece.php", ADD INDEX (`MostRecords`);');
}
else {
$aseco->console('[RecordsEyepiece] » Found column `MostRecords`.');
}
// Add `RoundPoints` column if not yet done
if ( !in_array('RoundPoints', $fields)) {
$aseco->console('[RecordsEyepiece] » Adding column `RoundPoints`.');
$aseco->db->query('ALTER TABLE `%prefix%players` ADD `RoundPoints` MEDIUMINT(3) UNSIGNED NOT NULL DEFAULT "0" COMMENT "Added by plugin.records_eyepiece.php", ADD INDEX (`RoundPoints`);');
}
else {
$aseco->console('[RecordsEyepiece] » Found column `RoundPoints`.');
}
// Add `TeamPoints` column if not yet done
if ( !in_array('TeamPoints', $fields)) {
$aseco->console('[RecordsEyepiece] » Adding column `TeamPoints`.');
$aseco->db->query('ALTER TABLE `%prefix%players` ADD `TeamPoints` MEDIUMINT(3) UNSIGNED NOT NULL DEFAULT "0" COMMENT "Added by plugin.records_eyepiece.php", ADD INDEX (`TeamPoints`);');
}
else {
$aseco->console('[RecordsEyepiece] » Found column `TeamPoints`.');
}
// Add `WinningPayout` column if not yet done
if ( !in_array('WinningPayout', $fields)) {
$aseco->console('[RecordsEyepiece] » Adding column `WinningPayout`.');
$aseco->db->query('ALTER TABLE `%prefix%players` ADD `WinningPayout` MEDIUMINT(3) UNSIGNED NOT NULL DEFAULT "0" COMMENT "Added by plugin.records_eyepiece.php", ADD INDEX (`WinningPayout`);');
}
else {
$aseco->console('[RecordsEyepiece] » Found column `WinningPayout`.');
}
if ($this->config['SCORETABLE_LISTS'][0]['MOST_FINISHED'][0]['ENABLED'][0] === true) {
// Update own `MostFinished`
$aseco->console('[RecordsEyepiece] Updating `MostFinished` counts for all Players...');
$mostfinished = array();
$query = "
SELECT
`PlayerId`,
COUNT(`Score`) AS `Count`
FROM `%prefix%times`
WHERE `GamemodeId` = ". $aseco->server->gameinfo->mode ."
GROUP BY `PlayerId`;
";
$res = $aseco->db->query($query);
if ($res) {
if ($res->num_rows > 0) {
while ($row = $res->fetch_object()) {
$mostfinished[(int)$row->PlayerId] = (int)$row->Count;
}
$aseco->db->begin_transaction(); // Require PHP >= 5.5.0
foreach ($mostfinished as $id => $count) {
$res1 = $aseco->db->query("
UPDATE `%prefix%players`
SET `MostFinished` = ". $count ."
WHERE `PlayerId` = ". $id ."
LIMIT 1;
");
}
$aseco->db->commit();
unset($mostfinished);
}
$res->free_result();
}
}
else {
$aseco->console('[RecordsEyepiece] Skip updating `MostFinished` counts for all Players, because Widget is disabled.');
}
if ($this->config['SCORETABLE_LISTS'][0]['MOST_RECORDS'][0]['ENABLED'][0] === true) {
// Update own `MostRecords`
$aseco->console('[RecordsEyepiece] Updating `MostRecords` counts for all Players...');
$mostrecords = array();
$query = "
SELECT
`PlayerId`,
COUNT(`Score`) AS `Count`
FROM `%prefix%records`
WHERE `GamemodeId` = ". $aseco->server->gameinfo->mode ."
GROUP BY `PlayerId`;
";
$res = $aseco->db->query($query);
if ($res) {
if ($res->num_rows > 0) {
while ($row = $res->fetch_object()) {
$mostrecords[(int)$row->PlayerId] = (int)$row->Count;
}
$aseco->db->begin_transaction(); // Require PHP >= 5.5.0
foreach ($mostrecords as $id => $count) {
$res1 = $aseco->db->query("
UPDATE `%prefix%players`
SET `MostRecords` = ". $count ."
WHERE `PlayerId` = ". $id ."
LIMIT 1;
");
}
$aseco->db->commit();
unset($mostrecords);
}
$res->free_result();
}
}
else {
$aseco->console('[RecordsEyepiece] Skip updating `MostRecords` counts for all Players, because Widget is disabled.');
}
}
// Check if is NiceMode been forced
if ( ($this->config['NICEMODE'][0]['ENABLED'][0] === true) && ($this->config['NICEMODE'][0]['FORCE'][0] === true)) {
// Turn nicemode on
$this->config['States']['NiceMode'] = true;
// Set new refresh interval
$this->config['FEATURES'][0]['REFRESH_INTERVAL'][0] = $this->config['NICEMODE'][0]['REFRESH_INTERVAL'][0];
$aseco->console('[RecordsEyepiece] Setup and forcing <nicemode>...');
}
if ($this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0] === true && isset($this->config['PLACEMENT_WIDGET'][0]['PLACEMENT'])) {
$aseco->console('[RecordsEyepiece] Checking entries for the <placement_widget>...');
// Remove disabled <placement> (freed mem.) and setup for each <chat_command> entry an own id
$new_placements = array();
$chat_id = 1; // Start ID for <chat_command>'s
foreach ($this->config['PLACEMENT_WIDGET'][0]['PLACEMENT'] as $placement) {
if (isset($placement['ENABLED'][0]) && strtoupper($placement['ENABLED'][0]) === 'TRUE') {
if (isset($placement['INCLUDE'][0])) {
// WITH <include>: Check for min. required entries <display>, <include>,
// skip if one was not found.
if (!isset($placement['DISPLAY'][0])) {
$aseco->console('[RecordsEyepiece] » One of your <placement> did not have all min. required entries, missing <display>!');
continue;
}
if (!is_readable($placement['INCLUDE'][0])) {
$aseco->console('[RecordsEyepiece] » One of your <placement> are unable to display, because the file "'. $placement['INCLUDE'][0] .'" at <include> could not be accessed!');
continue;
}
}
else {
// WITHOUT <include>: Check for min. required entries <pos_x>, <pos_y>, <width> and <height>,
// skip if one was not found.
if (!isset($placement['DISPLAY'][0]) || !isset($placement['POS_X'][0]) || !isset($placement['POS_Y'][0]) || !isset($placement['WIDTH'][0]) || !isset($placement['HEIGHT'][0])) {
$aseco->console('[RecordsEyepiece] » One of your <placement> did not have all min. required entries, missing one of <pos_x>, <pos_y>, <width> or <height>!');
continue;
}
}
$placement['DISPLAY'][0] = strtoupper($placement['DISPLAY'][0]);
// Transform all Gamemode-Names from e.g. 'TIME_ATTACK' to '2'
foreach ($gamemodes as $gamemode => $id) {
if ($placement['DISPLAY'][0] === $gamemode) {
$placement['DISPLAY'][0] = $id;
}
}
unset($id);
// Remove empty and unused tags to free mem. too.
foreach ($placement as $tag => $value) {
if ($value[0] === '') {
unset($placement[$tag]);
}
}
unset($placement['ENABLED'], $placement['DESCRIPTION'], $value);
// Skip this part from <placement> with <include> inside
if (!isset($placement['INCLUDE'][0])) {
// Check for <layer> and adjust the min./max.
if (isset($placement['LAYER'][0])) {
if ($placement['LAYER'][0] < -3) {
$placement['LAYER'][0] = -3; // Set min.
}
else if ($placement['LAYER'][0] > 20) {
$placement['LAYER'][0] = 20; // Set max.
}
}
else {
$placement['LAYER'][0] = 3; // Set default
}
// If this <placement> has a <chat_command>, then setup an ID for this (max. 1 till 25)
if ( (isset($placement['CHAT_COMMAND'][0])) && ($placement['CHAT_COMMAND'][0] !== '') && ($chat_id <= 25)) {
$placement['CHAT_MLID'][0] = $chat_id;
$chat_id ++;
}
}
// Add Placentment
$new_placements[] = $placement;
}
}
$this->config['PLACEMENT_WIDGET'][0]['PLACEMENT'] = $new_placements;
unset($new_placements, $placement);
$aseco->console('[RecordsEyepiece] » Working on all <placement> with <display> "Always"...');
$this->cache['PlacementWidget']['Always'] = $this->buildPlacementWidget('always');
$aseco->console('[RecordsEyepiece] » Working on all <placement> with <display> "Race"...');
$this->cache['PlacementWidget']['Race'] = $this->buildPlacementWidget('race');
// Build all Placements for the Gamemodes
foreach ($this->config['Gamemodes'] as $gamemode => $array) {
$aseco->console('[RecordsEyepiece] » Working on all <placement> with <display> "'. str_replace(' ', '', ucwords(strtolower($array['name']))) .'"...');
$this->cache['PlacementWidget'][$gamemode] = $this->buildPlacementWidget($gamemode);
}
// 'Score' is build at onEndMapRanking, because of the dependence of the placeholder
}
else {
// Autodisable when there is no setup for <placement>
$this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0] = false;
}
// Setup the "no-score" Placeholder depending at the current Gamemode
$this->config['PlaceholderNoScore'] = '-:--.---';
// Setup 'map_info'
if ( ($this->config['UI_PROPERTIES'][0]['MAP_INFO'][0] === false) || ($this->config['MAP_WIDGET'][0]['ENABLED'][0] === true)) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('map_info', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('map_info', true);
}
// Setup 'round_scores' and use own RoundScoreWidget (if enabled)
if ($this->config['UI_PROPERTIES'][0]['ROUND_SCORES'][0] === false || $this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::ROUNDS][0]['ENABLED'][0] === true || $this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::TEAM][0]['ENABLED'][0] === true || $this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::CUP][0]['ENABLED'][0] === true || $this->config['ROUND_SCORE'][0]['GAMEMODE'][0][Gameinfo::CHASE][0]['ENABLED'][0] === true) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('round_scores', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('round_scores', true);
}
// Setup 'warmup'
if ($this->config['UI_PROPERTIES'][0]['WARMUP'][0] === false || $this->config['WARM_UP_INFO_WIDGET'][0]['ENABLED'][0] === true) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('warmup', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('warmup', true);
}
// Setup 'endmap_ladder_recap'
if ($this->config['UI_PROPERTIES'][0]['ENDMAP_LADDER_RECAP'][0] === false) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('endmap_ladder_recap', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('endmap_ladder_recap', true);
}
// Setup 'multilap_info'
if ($this->config['UI_PROPERTIES'][0]['MULTILAP_INFO'][0] === false) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('multilap_info', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('multilap_info', true);
}
// Setup 'position'
if ($this->config['UI_PROPERTIES'][0]['POSITION'][0] === false) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('position', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('position', true);
}
// Setup 'speed_and_distance'
if ($this->config['UI_PROPERTIES'][0]['SPEED_AND_DISTANCE'][0] === false) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('speed_and_distance', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('speed_and_distance', true);
}
// Setup 'personal_best_and_rank'
if ($this->config['UI_PROPERTIES'][0]['PERSONAL_BEST_AND_RANK'][0] === false) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('personal_best_and_rank', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('personal_best_and_rank', true);
}
// Setup 'checkpoint_list'
if ($this->config['UI_PROPERTIES'][0]['CHECKPOINT_LIST'][0] === false) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('checkpoint_list', false);
}
else {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('checkpoint_list', true);
}
// Setup 'countdown'
if (isset($this->config['UI_PROPERTIES'][0]['COUNTDOWN'][0]['POSITION'][0])) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfacePosition('countdown', explode(',', $this->config['UI_PROPERTIES'][0]['COUNTDOWN'][0]['POSITION'][0]));
}
// Setup 'chrono'
if (isset($this->config['UI_PROPERTIES'][0]['CHRONO'][0]['POSITION'][0])) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfacePosition('chrono', explode(',', $this->config['UI_PROPERTIES'][0]['CHRONO'][0]['POSITION'][0]));
}
if ($this->config['SPECTATOR_INFO_WIDGET'][0]['ENABLED'][0] === true) {
$aseco->plugins['PluginModescriptHandler']->setUserInterfaceVisibility('viewers_count', false);
}
// Send the UI settings
$aseco->plugins['PluginModescriptHandler']->setupUserInterface();
// Get the current Maplist
$this->getMaplist(false);
// Get TopRoundscore
$this->getTopRoundscore($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
// Refresh Scoretable lists
$this->refreshScorelists();
// Build the Playlist-Cache
if ($this->config['MUSIC_WIDGET'][0]['ENABLED'][0] === true) {
$this->getMusicServerPlaylist(false, true);
}
// Build the Toplist Widget
if ($this->config['TOPLIST_WIDGET'][0]['ENABLED'][0] === true) {
$this->cache['ToplistWidget'] = $this->buildToplistWidget();
}
// Build the AddToFavorite Widget
if ($this->config['FAVORITE_WIDGET'][0]['ENABLED'][0] === true) {
$this->cache['AddToFavoriteWidget']['Race'] = $this->buildAddToFavoriteWidget('RACE');
$this->cache['AddToFavoriteWidget']['Score'] = $this->buildAddToFavoriteWidget('SCORE');
}
// Build the DonationWidget
if ($this->config['DONATION_WIDGET'][0]['ENABLED'][0] === true) {
$val = explode(',', $this->config['DONATION_WIDGET'][0]['AMOUNTS'][0]);
if (count($val) < 7) {
trigger_error('[RecordsEyepiece] » The amount of <donation_widget><amounts> is lower then the required min. of 7 in records_eyepiece.xml!', E_USER_ERROR);
}
$this->cache['DonationWidget'] = $this->buildDonationWidget();
}
$aseco->console('[RecordsEyepiece] Finished.');
$aseco->console('[RecordsEyepiece] ********************************************************');
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onShutdown ($aseco) {
if (isset($this->config['WINNING_PAYOUT'][0]) && $this->config['WINNING_PAYOUT'][0]['ENABLED'][0] === true) {
foreach ($aseco->server->players->player_list as $player) {
if ($this->cache['PlayerWinnings'][$player->login]['FinishPayment'] > 0) {
$this->winningPayout($player);
}
}
unset($player);
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function chat_eyepiece ($aseco, $login, $chat_command, $chat_parameter) {
// Get Player object
if (!$player = $aseco->server->players->getPlayerByLogin($login)) {
return;
}
if (strtoupper($chat_parameter) === 'PAYOUTS') {
if ($aseco->isAnyAdminByLogin($login)) {
if ($this->config['WINNING_PAYOUT'][0]['ENABLED'][0] === true) {
$message = '{#server}» There are outstanding disbursements in the amount of ';
$outstanding = 0;
foreach ($this->cache['PlayerWinnings'] as $login => $struct) {
$outstanding += $this->cache['PlayerWinnings'][$login]['FinishPayment'];
}
unset($login, $struct);
$message .= $this->formatNumber($outstanding, 0) .' Planets.';
}
else {
$message = '{#server}» WinningPayoutWidget is not enabled, no payouts to do!';
}
// Show message
$aseco->sendChatMessage($message, $login);
}
}
else {
if ($aseco->server->gamestate === Server::RACE) {
// Call the HelpWindow
$params = array(
'Action' => 'showHelpWindow',
);
$this->onPlayerManialinkPageAnswer($aseco, $player->login, $params);
}
else {
// Show message that the display at score is impossible
$aseco->sendChatMessage($this->config['MESSAGES'][0]['DISALLOW_WINDOWS_AT_SCORE'][0], $login);
}
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function chat_estat ($aseco, $login, $chat_command, $chat_parameter) {
if ($aseco->server->gamestate === Server::RACE) {
// Get Player object
if (!$player = $aseco->server->players->getPlayerByLogin($login)) {
return;
}
// Get current Gamemode
$gamemode = $aseco->server->gameinfo->mode;
$id = false;
if ( (strtoupper($chat_parameter) === 'DEDIRECS') && ($this->config['DEDIMANIA_RECORDS'][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] === true)) {
$id = 'showDedimaniaRecordsWindow';
}
else if (strtoupper($chat_parameter) === 'LOCALRECS') {
$id = 'showLocalRecordsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPNATIONS') {
$id = 'showTopNationsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPRANKS') {
$id = 'showTopRankingsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPWINNERS') {
$id = 'showTopWinnersWindow';
}
else if (strtoupper($chat_parameter) === 'MOSTRECORDS') {
$id = 'showMostRecordsWindow';
}
else if (strtoupper($chat_parameter) === 'MOSTFINISHED') {
$id = 'showMostFinishedWindow';
}
else if (strtoupper($chat_parameter) === 'TOPPLAYTIME') {
$id = 'showTopPlaytimeWindow';
}
else if (strtoupper($chat_parameter) === 'TOPDONATORS') {
$id = 'showTopDonatorsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPMAPS') {
$id = 'showTopMapsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPVOTERS') {
$id = 'showTopVotersWindow';
}
else if (strtoupper($chat_parameter) === 'TOPACTIVE') {
$id = 'showTopActivePlayersWindow';
}
else if ( (strtoupper($chat_parameter) === 'TOPPAYOUTS') && ($this->config['WINNING_PAYOUT'][0]['ENABLED'][0] === true)) {
$id = 'showTopWinningPayoutWindow';
}
else if ( (strtoupper($chat_parameter) === 'TOPBETWINS') && ($this->config['SCORETABLE_LISTS'][0]['TOP_BETWINS'][0]['ENABLED'][0] === true)) {
$id = 'showTopBetwinsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPROUNDSCORE') {
$id = 'showTopRoundscoreWindow';
}
else if (strtoupper($chat_parameter) === 'TOPVISITORS') {
$id = 'showTopVisitorsWindow';
}
else if (strtoupper($chat_parameter) === 'TOPCONTINENTS') {
$id = 'showTopContinentsWindow';
}
else {
$id = 'showHelpWindow';
}
if ($id !== false) {
// Simulate a PlayerManialinkPageAnswer and
// wrap "/elist [PARAMETER]" to an onPlayerManialinkPageAnswer
$params = array(
'Action' => $id,
);
$this->onPlayerManialinkPageAnswer($aseco, $player->login, $params);
}
}
else {
// Show message that the display at score is impossible
$aseco->sendChatMessage($this->config['MESSAGES'][0]['DISALLOW_WINDOWS_AT_SCORE'][0], $login);
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function chat_eyeset ($aseco, $login, $chat_command, $chat_parameter) {
// Init
$message = false;
// Check optional parameter
if (strtoupper($chat_parameter) === 'RELOAD') {
if ($aseco->server->gamestate === Server::RACE) {
$aseco->console('[RecordsEyepiece] MasterAdmin '. $login .' reloads the configuration.');
// Close all Widgets at all Players
$xml = $this->closeRaceWidgets(false, true);
$xml .= $this->closeScoretableLists();
$xml .= '<manialink id="PlacementWidgetRace" name="PlacementWidgetRace" version="3"></manialink>';
$xml .= '<manialink id="PlacementWidgetScore" name="PlacementWidgetScore" version="3"></manialink>';
$xml .= '<manialink id="PlacementWidgetAlways" name="PlacementWidgetAlways" version="3"></manialink>';
$this->sendManialink($xml, false, 0);
// Reload the config
$this->onSync($aseco, true);
// Simulate the event 'onLoadingMap'
$this->onLoadingMap($aseco, $aseco->server->maps->current);
// Simulate the event 'onWarmUpStatusChanged'
$this->onWarmUpStatusChanged($aseco, $aseco->warmup_phase);
// Display the PlacementWidgets at state 'always'
if ($this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0] === true) {
$xml = $this->cache['PlacementWidget']['Always'];
$this->sendManialink($xml, false, 0);
}
$message = '{#admin}» Reload of the configuration "config/records_eyepiece.xml" done.';
}
else {
$message = '{#admin}» Can not reload the configuration at Score!';
}
}
else if ( preg_match("/^lfresh \d+$/i", $chat_parameter)) {
$param = preg_split("/^lfresh (\d+)$/", $chat_parameter, 0, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$message = '{#admin}» Set <refresh_interval> (normal mode) to "'. $param[0] .'" sec.';
$this->config['FEATURES'][0]['REFRESH_INTERVAL'][0] = $param[0];
}
else if ( preg_match("/^hfresh \d+$/i", $chat_parameter)) {
$param = preg_split("/^hfresh (\d+)$/", $chat_parameter, 0, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$message = '{#admin}» Set <refresh_interval> (nice mode) to "'. $param[0] .'" sec.';
$this->config['NICEMODE'][0]['REFRESH_INTERVAL'][0] = $param[0];
}
else if ( preg_match("/^llimit \d+$/i", $chat_parameter)) {
$param = preg_split("/^llimit (\d+)$/", $chat_parameter, 0, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$message = '{#admin}» Set <lower_limit> (nice mode) to "'. $param[0] .'" Players.';
$this->config['NICEMODE'][0]['LIMITS'][0]['LOWER_LIMIT'][0] = $param[0];
}
else if ( preg_match("/^ulimit \d+$/i", $chat_parameter)) {
$param = preg_split("/^ulimit (\d+)$/", $chat_parameter, 0, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$message = '{#admin}» Set <upper_limit> (nice mode) to "'. $param[0] .'" Players.';
$this->config['NICEMODE'][0]['LIMITS'][0]['UPPER_LIMIT'][0] = $param[0];
}
else if ( preg_match("/^forcenice (true|false)$/i", $chat_parameter)) {
$param = preg_split("/^forcenice (true|false)$/", $chat_parameter, 0, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$message = '{#admin}» Set <nicemode><force> to "'. $param[0] .'".';
$this->config['NICEMODE'][0]['FORCE'][0] = ((strtoupper($param[0]) === 'TRUE') ? true : false);
$this->config['States']['NiceMode'] = ((strtoupper($param[0]) === 'TRUE') ? true : false);
// Lets refresh the Widgets
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = true;
$this->config['States']['LocalRecords']['UpdateDisplay'] = true;
$this->config['States']['LiveRankings']['UpdateDisplay'] = true;
}
else if ( preg_match("/^playermarker (true|false)$/i", $chat_parameter)) {
$param = preg_split("/^playermarker (true|false)$/", $chat_parameter, 0, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$message = '{#admin}» Set <features><mark_online_player_records> to "'. $param[0] .'".';
$this->config['FEATURES'][0]['MARK_ONLINE_PLAYER_RECORDS'][0] = ((strtoupper($param[0]) === 'TRUE') ? true : false);
// Lets refresh the Widgets
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = true;
$this->config['States']['LocalRecords']['UpdateDisplay'] = true;
}
else {
$message = '{#admin}» Did not found any possible parameter to set!';
}
// Show message
if ($message !== false) {
$aseco->sendChatMessage($message, $login);
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
// Wrapper/Chat command for opening the MaplistWindow
public function chat_elist ($aseco, $login, $chat_command, $chat_parameter) {
// Do not display at score
if ($aseco->server->gamestate === Server::RACE) {
// Get Player object
if (!$player = $aseco->server->players->getPlayerByLogin($login)) {
return;
}
if (count($player->data['PluginRecordsEyepiece']['Maplist']['Records']) === 0) {
if ($aseco->server->maps->count() > $this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0] && $this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0] !== 0) {
$this->sendProgressIndicator($player->login);
}
// Load all local Records from calling Player
$player->data['PluginRecordsEyepiece']['Maplist']['Records'] = $this->getPlayerLocalRecords($player->id);
// Load all Maps that the calling Player did not finished yet
$player->data['PluginRecordsEyepiece']['Maplist']['Unfinished'] = $this->getPlayerUnfinishedMaps($player->id);
}
$id = false;
if (strtoupper($chat_parameter) === 'JUKEBOX') {
// Show the MaplistWindow (but only jukeboxed Maps)
$id = 'showMaplistWindowFilterJukeboxedMaps';
}
else if (strtoupper($chat_parameter) === 'AUTHOR') {
// Show the MapAuthorlistWindow
$id = 'showMapAuthorlistWindow';
}
else if (strtoupper($chat_parameter) === 'NORECENT') {
// Show the MaplistWindow (but no recent Maps)
$id = 'showMaplistWindowFilterNoRecentMaps';
}
else if (strtoupper($chat_parameter) === 'ONLYRECENT') {
// Show the MaplistWindow (but only recent Maps)
$id = 'showMaplistWindowFilterOnlyRecentMaps';
}
else if (strtoupper($chat_parameter) === 'NORANK') {
// Show the MaplistWindow (but only Maps without a rank)
$id = 'showMaplistWindowFilterOnlyMapsWithoutRank';
}
else if (strtoupper($chat_parameter) === 'ONLYRANK') {
// Show the MaplistWindow (but only Maps with a rank)
$id = 'showMaplistWindowFilterOnlyMapsWithRank';
}
else if (strtoupper($chat_parameter) === 'NOMULTI') {
// Show the MaplistWindow (but no Multilap Maps)
$id = 'showMaplistWindowFilterNoMultilapMaps';
}
else if (strtoupper($chat_parameter) === 'ONLYMULTI') {
// Show the MaplistWindow (but only Multilap Maps)
$id = 'showMaplistWindowFilterOnlyMultilapMaps';
}
else if (strtoupper($chat_parameter) === 'NOAUTHOR') {
// Show the MaplistWindow (but only Maps no author time)
$id = 'showMaplistWindowFilterOnlyMapsNoAuthorTime';
}
else if (strtoupper($chat_parameter) === 'NOGOLD') {
// Show the MaplistWindow (but only Maps no gold time)
$id = 'showMaplistWindowFilterOnlyMapsNoGoldTime';
}
else if (strtoupper($chat_parameter) === 'NOSILVER') {
// Show the MaplistWindow (but only Maps no silver time)
$id = 'showMaplistWindowFilterOnlyMapsNoSilverTime';
}
else if (strtoupper($chat_parameter) === 'NOBRONZE') {
// Show the MaplistWindow (but only Maps no bronze time)
$id = 'showMaplistWindowFilterOnlyMapsNoBronzeTime';
}
else if (strtoupper($chat_parameter) === 'NOFINISH') {
// Show the MaplistWindow (but only Maps not finished)
$id = 'showMaplistWindowFilterOnlyMapsNotFinished';
}
else if (strtoupper($chat_parameter) === 'BEST') {
// Show the MaplistWindow (sort Maps 'Best Player Rank')
$id = 'showMaplistWindowSortingBestPlayerRank';
}
else if (strtoupper($chat_parameter) === 'WORST') {
// Show the MaplistWindow (sort Maps 'Worst Player Rank')
$id = 'showMaplistWindowSortingWorstPlayerRank';
}
else if (strtoupper($chat_parameter) === 'SHORTEST') {
// Show the MaplistWindow (sort Maps 'Shortest Author Time')
$id = 'showMaplistWindowSortingShortestAuthorTime';
}
else if (strtoupper($chat_parameter) === 'LONGEST') {
// Show the MaplistWindow (sort Maps 'Longest Author Time')
$id = 'showMaplistWindowSortingLongestAuthorTime';
}
else if (strtoupper($chat_parameter) === 'NEWEST') {
// Show the MaplistWindow (sort Maps 'Newest Maps First')
$id = 'showMaplistWindowSortingNewestMapsFirst';
}
else if (strtoupper($chat_parameter) === 'OLDEST') {
// Show the MaplistWindow (sort Maps 'Oldest Maps First')
$id = 'showMaplistWindowSortingOldestMapsFirst';
}
else if (strtoupper($chat_parameter) === 'MAP') {
// Show the MaplistWindow (sort Maps 'By Mapname')
$id = 'showMaplistWindowSortingByMapname';
}
else if (strtoupper($chat_parameter) === 'AUTHOR') {
// Show the MaplistWindow (sort Maps 'By Authorname')
$id = 'showMaplistWindowSortingByAuthorname';
}
else if (strtoupper($chat_parameter) === 'BESTKARMA') {
// Show the MaplistWindow (sort Maps 'By Karma: Best Maps First')
$id = 'showMaplistWindowSortingByKarmaBestMapsFirst';
}
else if (strtoupper($chat_parameter) === 'WORSTKARMA') {
// Show the MaplistWindow (sort Maps 'By Karma: Worst Maps First')
$id = 'showMaplistWindowSortingByKarmaWorstMapsFirst';
}
else {
if (strlen($chat_parameter) > 0) {
// Show the MaplistWindow (Search for Keyword at Mapname/Author/Filename)
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('key' => $chat_parameter);
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
// Show the MaplistWindow (filtered by given keyword)
$id = 'showMaplistWindowFilterByKeyword';
}
else {
// Show the MaplistWindow (display all Maps)
$id = 'showMaplistWindow';
}
}
if ($id !== false) {
// Simulate a PlayerManialinkPageAnswer and
// wrap "/elist [PARAMETER]" to an onPlayerManialinkPageAnswer
$params = array(
'Action' => $id,
);
$this->onPlayerManialinkPageAnswer($aseco, $player->login, $params);
}
}
else {
// Show message that the display at score is impossible
$aseco->sendChatMessage($this->config['MESSAGES'][0]['DISALLOW_WINDOWS_AT_SCORE'][0], $login);
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
// Wrapper/Chat command for opening the MusiclistWindow
public function chat_emusic ($aseco, $login, $chat_command, $chat_parameter) {
if ($this->config['MUSIC_WIDGET'][0]['ENABLED'][0] === true) {
// Do not display at score
if ($aseco->server->gamestate === Server::RACE) {
// Get Player object
if ($player = $aseco->server->players->getPlayerByLogin($login)) {
$params = array(
'Action' => 'showMusiclistWindow',
);
$this->onPlayerManialinkPageAnswer($aseco, $player->login, $params);
}
}
else {
// Show message that the display at score is impossible
$aseco->sendChatMessage($this->config['MESSAGES'][0]['DISALLOW_WINDOWS_AT_SCORE'][0], $login);
}
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onEverySecond ($aseco) {
// Is it time for refresh the RecordWidgets?
if (time() >= $this->config['States']['RefreshTimestampRecordWidgets']) {
// Get current Gamemode
$gamemode = $aseco->server->gameinfo->mode;
// Set next refresh timestamp
$this->config['States']['RefreshTimestampRecordWidgets'] = (time() + $this->config['FEATURES'][0]['REFRESH_INTERVAL'][0]);
// Check for changed LocalRecords, e.g. on "/admin delrec 1"...
if (isset($this->config['LOCAL_RECORDS'][0]['GAMEMODE'][0][$gamemode]) && $this->config['LOCAL_RECORDS'][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] === true) {
if (count($aseco->plugins['PluginLocalRecords']->records->record_list) >= 1) {
$localDigest = $this->buildRecordDigest('locals', $aseco->plugins['PluginLocalRecords']->records->record_list);
if ($this->config['States']['LocalRecords']['ChkSum'] !== $localDigest && $this->config['States']['LocalRecords']['NoRecordsFound'] === false) {
$this->config['States']['LocalRecords']['NeedUpdate'] = true;
}
}
}
// Load the current Rankings
if (isset($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0][$gamemode]) && $this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] === true) {
$this->cache['CurrentRankings'] = array();
if ($gamemode === Gameinfo::TEAM) {
$this->cache['CurrentRankings'] = $this->getCurrentRanking(2,0);
}
else {
// All other Gamemodes
$this->cache['CurrentRankings'] = $this->getCurrentRanking(300,0);
}
}
// Build the RecordWidgets and ONLY in normal mode send it to each Player (if refresh is required)
$this->buildRecordWidgets(false, false);
$widgets = '';
if ($this->config['States']['NiceMode'] === true) {
// Display the RecordWidgets to all Players (if refresh is required)
$widgets .= $this->showRecordWidgets(false);
}
// Send all widgets to ALL Players
if ($widgets !== '') {
// Send Manialink
$this->sendManialink($widgets, false, 0);
}
// Just refreshed, mark as fresh
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = false;
$this->config['States']['LocalRecords']['UpdateDisplay'] = false;
$this->config['States']['LiveRankings']['UpdateDisplay'] = false;
}
// Required to load the Preloader for external Images
if (time() >= $this->config['States']['RefreshTimestampPreload']) {
$this->config['States']['RefreshTimestampPreload'] = (time() + 5);
foreach ($aseco->server->players->player_list as $player) {
if ( (time() >= $player->data['PluginRecordsEyepiece']['Preload']['Timestamp']) && ($player->data['PluginRecordsEyepiece']['Preload']['LoadedPart'] !== 5)) {
$player->data['PluginRecordsEyepiece']['Preload']['LoadedPart'] += 1;
$widgets = $this->buildImagePreload($player->data['PluginRecordsEyepiece']['Preload']['LoadedPart']);
if ($widgets !== '') {
// Send Manialink
$this->sendManialink($widgets, $player->login, 0);
}
}
}
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function refreshScorelists () {
// Refresh MostRecords Array
$this->getMostRecords($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
// Refresh the MostFinished Array
$this->getMostFinished($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
// Refresh the TopDonators Array
$this->getTopDonators($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
// Refresh the TopContinents Array
$this->getTopContinents($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
// Refresh the TopRankings Array
$this->getTopRankings($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_RANKINGS'][0]['ENABLED'][0] === true) {
$this->cache['TopRankings'] = $this->buildScorelistWidgetEntry('TopRankingsWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_RANKINGS'][0], $this->scores['TopRankings'], array('score', 'nickname'));
}
// Refresh the TopWinners Array
$this->getTopWinners($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_WINNERS'][0]['ENABLED'][0] === true) {
$this->cache['TopWinners'] = $this->buildScorelistWidgetEntry('TopWinnersWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_WINNERS'][0], $this->scores['TopWinners'], array('score', 'nickname'));
}
// Refresh TopMaps Array (if required)
if ($this->config['States']['TopMaps']['NeedUpdate'] === true) {
$this->calculateMapKarma();
$this->getTopMaps($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
}
if ($this->config['SCORETABLE_LISTS'][0]['TOP_MAPS'][0]['ENABLED'][0] === true) {
$this->cache['TopMaps'] = $this->buildScorelistWidgetEntry('TopMapsWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_MAPS'][0], $this->scores['TopMaps'], array('karma', 'map'));
}
// Refresh TopVoters Array (if required)
if ($this->config['States']['TopVoters']['NeedUpdate'] === true) {
$this->getTopVoters($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
}
if ($this->config['SCORETABLE_LISTS'][0]['TOP_VOTERS'][0]['ENABLED'][0] === true) {
$this->cache['TopVoters'] = $this->buildScorelistWidgetEntry('TopVotersWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_VOTERS'][0], $this->scores['TopVoters'], array('score', 'nickname'));
}
// Refresh the TopBetwins Array
$this->getTopBetwins($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_BETWINS'][0]['ENABLED'][0] === true) {
$this->cache['TopBetwins'] = $this->buildScorelistWidgetEntry('TopBetwinsWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_BETWINS'][0], $this->scores['TopBetwins'], array('won', 'nickname'));
}
// Refresh the TopWinningPayout Array
$this->getTopWinningPayout($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_WINNING_PAYOUTS'][0]['ENABLED'][0] === true) {
$this->cache['TopWinningPayouts'] = $this->buildScorelistWidgetEntry('TopWinningPayoutsWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_WINNING_PAYOUTS'][0], $this->scores['TopWinningPayouts'], array('won', 'nickname'));
}
// Refresh the TopVisitors Array
$this->getTopVisitors($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_VISITORS'][0]['ENABLED'][0] === true) {
$this->cache['TopVisitors'] = $this->buildScorelistWidgetEntry('TopVisitorsWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_VISITORS'][0], $this->scores['TopVisitors'], array('score', 'nickname'));
}
// Refresh the TopActivePlayers Array
$this->getTopActivePlayers($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_ACTIVE_PLAYERS'][0]['ENABLED'][0] === true) {
$this->cache['TopActivePlayers'] = $this->buildScorelistWidgetEntry('TopActivePlayersWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_ACTIVE_PLAYERS'][0], $this->scores['TopActivePlayers'], array('score', 'nickname'));
}
// Refresh the TopPlaytime Array
$this->getTopPlaytime($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_PLAYTIME'][0]['ENABLED'][0] === true) {
$this->cache['TopPlaytime'] = $this->buildScorelistWidgetEntry('TopPlaytimeWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_PLAYTIME'][0], $this->scores['TopPlaytime'], array('score', 'nickname'));
}
// Refresh the TopNations Array
$this->getTopNationList($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['SCORETABLE_LISTS'][0]['TOP_NATIONS'][0]['ENABLED'][0] === true) {
$this->cache['TopNations'] = $this->buildTopNationsForScore($this->config['SCORETABLE_LISTS'][0]['TOP_NATIONS'][0]['ENTRIES'][0]);
}
// Refresh the Visitors Array
$this->getVisitors($this->config['FEATURES'][0]['TOPLIST_LIMIT'][0]);
if ($this->config['VISITORS_WIDGET'][0]['ENABLED'][0] === true) {
$this->cache['VisitorsWidget'] = $this->buildVisitorsWidget();
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerConnect ($aseco, $player) {
// Check if it is time to switch from "normal" to NiceMode or back
$this->checkServerLoad();
// Get the detailed Players TeamId (refreshed onPlayerInfoChanged)
$player->data['PluginRecordsEyepiece']['Prefs']['TeamId'] = $player->team_id;
// Init Player-Storages
$player->data['PluginRecordsEyepiece']['Window']['Action'] = false;
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Window']['MaxPage'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = false;
$player->data['PluginRecordsEyepiece']['Maplist']['Records'] = array();
$player->data['PluginRecordsEyepiece']['Maplist']['Unfinished'] = array();
// Get current Gamemode
$gamemode = $aseco->server->gameinfo->mode;
// Init
$widgets = '';
// Preset an empty RecordEntry for the RecordWidgets, required
// for an empty entry for this Player if he/she did not has a Record yet
$item = array();
$item['login'] = $player->login;
$item['nickname'] = $player->nickname;
$item['self'] = 0;
$item['rank'] = '--';
$player->data['PluginRecordsEyepiece']['Prefs']['WidgetEmptyEntry'] = $item;
// Add this Player to the Hash-Compare-Process
$this->cache['PlayerStates'][$player->login]['DedimaniaRecords'] = false;
$this->cache['PlayerStates'][$player->login]['LocalRecords'] = false;
$this->cache['PlayerStates'][$player->login]['LiveRankings'] = false;
$this->cache['PlayerStates'][$player->login]['FinishScore'] = -1;
if ($this->config['WINNING_PAYOUT'][0]['ENABLED'][0] === true) {
// Check for WinningPayment: If this exists, do not override!
if ( !isset($this->cache['PlayerWinnings'][$player->login]['TimeStamp'])) {
$this->cache['PlayerWinnings'][$player->login]['FinishPayment'] = 0;
$this->cache['PlayerWinnings'][$player->login]['FinishPaid'] = 0;
$this->cache['PlayerWinnings'][$player->login]['TimeStamp'] = 0;
}
// Add this Player to the Cache
$this->cache['WinningPayoutPlayers'][$player->login] = array(
'id' => $player->id,
'login' => $player->login,
'nickname' => $player->nickname,
'ladderrank' => $player->ladder_rank
);
}
// Look if Player is in $this->scores['TopActivePlayers'] and if, then update and resort
$found = false;
foreach ($this->scores['TopActivePlayers'] as &$item) {
if ($item['login'] === $player->login) {
$item['score'] = 'Today';
$item['score_plain'] = 0;
$found = true;
break;
}
}
unset($item);
if ($found === true) {
// Resort by 'score'
$data = array();
foreach ($this->scores['TopActivePlayers'] as $key => $row) {
$data[$key] = $row['score_plain'];
}
array_multisort($data, SORT_NUMERIC, SORT_ASC, $this->scores['TopActivePlayers']);
unset($data, $key, $row);
}
$widgets .= $this->buildClockWidget();
if ($this->config['TOPLIST_WIDGET'][0]['ENABLED'][0] === true) {
// Display the TopList Widget to connecting Player
$widgets .= $this->cache['ToplistWidget'];
}
if ($this->config['FAVORITE_WIDGET'][0]['ENABLED'][0] === true) {
// Display the AddToFavorite Widget
$widgets .= $this->cache['AddToFavoriteWidget']['Race'];
}
if ($this->config['VISITORS_WIDGET'][0]['ENABLED'][0] === true) {
// Display the Visitors-Widget to connecting Player
$widgets .= (($this->cache['VisitorsWidget'] !== false) ? $this->cache['VisitorsWidget'] : '');
}
if ($this->config['WARM_UP_INFO_WIDGET'][0]['ENABLED'][0] === true && $this->config['States']['WarmUpPhase'] === true) {
// Display the WarmUpInfoWidget to connecting Player
$widgets .= (($this->cache['WarmUpInfoWidget'] !== false) ? $this->cache['WarmUpInfoWidget'] : '');
}
if ($this->config['MULTILAP_INFO_WIDGET'][0]['ENABLED'][0] === true && ($aseco->server->maps->current->multi_lap === true && ($gamemode !== Gameinfo::TIME_ATTACK && $gamemode !== Gameinfo::DOPPLER))) {
// Display the MultiLapInfoWidget to connecting Player
$widgets .= (($this->cache['MultiLapInfoWidget'] !== false) ? $this->cache['MultiLapInfoWidget'] : '');
}
if ($this->config['SPECTATOR_INFO_WIDGET'][0]['ENABLED'][0] === true) {
// Send the SpectatorInfoGetter to connecting Player
$this->cache['SpectatorOverview'][$player->login] = '';
$widgets .= $this->buildSpectatorInfoGetter();
}
if ($this->config['MANIAEXCHANGE_WIDGET'][0]['ENABLED'][0] === true) {
// Display the ManiaExchangeWidget to connecting Player
$widgets .= (($this->cache['ManiaExchangeWidget'] !== false) ? $this->cache['ManiaExchangeWidget'] : '');
}
if ($this->config['MAPCOUNT_WIDGET'][0]['ENABLED'][0] === true) {
// Display the MapcountWidget to connecting Player
$widgets .= (($this->cache['MapcountWidget'] !== false) ? $this->cache['MapcountWidget'] : '');
}
if ($this->config['MUSIC_WIDGET'][0]['ENABLED'][0] === true) {
// Display the Music Widget to connecting Player
$widgets .= (($this->cache['MusicWidget'] !== false) ? $this->cache['MusicWidget'] : '');
}
if ($this->config['States']['NiceMode'] === true) {
// Display the RecordWidgets to connecting Player
$widgets .= $this->showRecordWidgets(true);
}
else {
// Find any Records for this Player and if found, refresh the concerned Widgets
$result = $this->findPlayerRecords($player->login);
if ( ($result['DedimaniaRecords'] === true) || ($result['LocalRecords'] === true)) {
// New Player has one Record, need to refresh concerned Widgets (without LiveRankings) at ALL Players, but not current Player
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = true;
$this->config['States']['LocalRecords']['UpdateDisplay'] = true;
}
// Now the connected Player need all Widgets to be displayed, not only that where he/she has a record
$this->buildRecordWidgets($player, array('DedimaniaRecords' => true, 'LocalRecords' => true, 'LiveRankings' => true));
}
// Display the PlacementWidgets at state 'always'
if ($this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0] === true) {
$widgets .= $this->cache['PlacementWidget']['Always'];
}
// Display the PlacementWidgets at state 'race'
if ( ($this->config['PLACEMENT_WIDGET'][0]['ENABLED'][0] === true) && ($aseco->server->gamestate === Server::RACE)) {
$widgets .= $this->cache['PlacementWidget']['Race'];
if (isset($this->cache['PlacementWidget'][$gamemode])) {
$widgets .= $this->cache['PlacementWidget'][$gamemode];
}
}
// Display the MapWidget
$widgets .= (($this->cache['MapWidget']['Race'] !== false) ? $this->cache['MapWidget']['Race'] : '');
// Mark this Player for need to preload Images
$player->data['PluginRecordsEyepiece']['Preload']['Timestamp'] = (time() + 15);
$player->data['PluginRecordsEyepiece']['Preload']['LoadedPart'] = 0;
// Display the RoundScoreWidget
if (isset($this->config['ROUND_SCORE'][0]['GAMEMODE'][0][$gamemode]) && $this->config['ROUND_SCORE'][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] === true) {
$widgets .= $this->buildRoundScoreWidget($gamemode, false);
}
// if ($this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] === true) {
// $widgets .= $this->buildLiveRankingsWidgetMS($gamemode, $this->config['LIVE_RANKINGS'][0]['GAMEMODE'][0][$gamemode][0]['ENTRIES'][0]);
// }
// Send all widgets
if (!empty($widgets)) {
// Send Manialink
$this->sendManialink($widgets, $player->login, 0);
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerDisconnectPrepare ($aseco, $player) {
// Remove temporary Player data, do not need to be stored into the database.
$this->removePlayerData($player, 'Maplist');
$this->removePlayerData($player, 'Prefs');
$this->removePlayerData($player, 'Preload');
$this->removePlayerData($player, 'Window');
$params = array(
'Action' => 'spectatorUpdate',
'Spectator' => $player->login,
'Target' => '',
);
$this->onPlayerManialinkPageAnswer($aseco, $player->login, $params);
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerDisconnect ($aseco, $player) {
// Check if it is time to switch from "normal" to NiceMode or back
$this->checkServerLoad();
if ($this->config['WINNING_PAYOUT'][0]['ENABLED'][0] === true) {
$this->winningPayout($player);
}
// Find any Records for this Player and if found, refresh the concerned Widgets
$result = $this->findPlayerRecords($player->login);
if ($result['DedimaniaRecords'] === true) {
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = true;
}
if ($result['LocalRecords'] === true) {
$this->config['States']['LocalRecords']['UpdateDisplay'] = true;
}
// Remove this Player from the Hash-Compare-Process
unset($this->cache['PlayerStates'][$player->login]);
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerRankingUpdated ($aseco) {
// Update LiveRankings only
$this->config['States']['LiveRankings']['NeedUpdate'] = true;
$this->config['States']['LiveRankings']['UpdateDisplay'] = true;
// $this->buildRecordWidgets(false, array('DedimaniaRecords' => false, 'LocalRecords' => false, 'LiveRankings' => true));
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerFinishPrefix ($aseco, $finish_item) {
if ($finish_item->score === 0) {
// No actual finish, bail out immediately
return;
}
// Get the Player object (possible required below)
$player = $aseco->server->players->player_list[$finish_item->player_login];
if ($this->config['ROUND_SCORE'][0]['GAMEMODE'][0][$aseco->server->gameinfo->mode][0]['ENABLED'][0] === true && $this->config['States']['WarmUpPhase'] === false) {
// Add the Score
// $this->scores['RoundScore'][$finish_item->score] = array(
$this->scores['RoundScore'][$player->login] = array(
'team' => $player->data['PluginRecordsEyepiece']['Prefs']['TeamId'],
'checkpointid' => count((isset($aseco->plugins['PluginCheckpoints']->checkpoints[$finish_item->player_login]) ? $aseco->plugins['PluginCheckpoints']->checkpoints[$finish_item->player_login]->current['cps'] : array())) - 1,
'playerid' => $player->pid,
'login' => $player->login,
'nickname' => $player->nickname,
'score' => $aseco->formatTime($finish_item->score),
'score_plain' => $finish_item->score,
);
// Display the Widget
$this->buildRoundScoreWidget($aseco->server->gameinfo->mode, true);
}
// Check if the Player has a better score as before
$refresh = false;
if ($this->cache['PlayerStates'][$player->login]['FinishScore'] === -1) {
// New Score, store them
$this->cache['PlayerStates'][$player->login]['FinishScore'] = $finish_item->score;
// Let the Widget refresh
$refresh = true;
}
else if ($finish_item->score < $this->cache['PlayerStates'][$player->login]['FinishScore']) {
// All Gamemodes: Lower = Better
// Better Score, store them
$this->cache['PlayerStates'][$player->login]['FinishScore'] = $finish_item->score;
// Let the Widget refresh
$refresh = true;
}
// Refresh the LiveRankingsWidget only if there is a better or new Score/Time
if ($refresh === true) {
// Player finished the Map, need to Update the 'LiveRanking',
// but not at Gamemode 'Rounds' - that are only updated at the event 'onEndRound'!
if ($aseco->server->gameinfo->mode !== Gameinfo::ROUNDS) {
$this->config['States']['LiveRankings']['NeedUpdate'] = true;
$this->config['States']['LiveRankings']['NoRecordsFound'] = false;
}
}
// Increase finish count for this Player, required for MostFinished List at Score and in the TopLists
$query = "UPDATE `%prefix%players` SET `MostFinished` = `MostFinished` + 1 WHERE `PlayerId` = '". $player->id ."';";
$result = $aseco->db->query($query);
if (!$result) {
$aseco->console('[RecordsEyepiece] UPDATE `MostFinished` failed. [for statement "'. $query .'"]!');
}
// Store the $finish_item->score to build the average
if ($this->config['SCORETABLE_LISTS'][0]['TOP_AVERAGE_TIMES'][0]['ENABLED'][0] === true) {
$this->scores['TopAverageTimes'][$player->login][] = $finish_item->score;
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerWins ($aseco, $player) {
// Look if Player is in Array
foreach ($this->scores['TopWinners'] as $item) {
if ($item['login'] === $player->login) {
// Lets refresh them now
$this->getTopWinners();
if ($this->config['SCORETABLE_LISTS'][0]['TOP_WINNERS'][0]['ENABLED'][0] === true) {
$this->cache['TopWinners'] = $this->buildScorelistWidgetEntry('TopWinnersWidgetAtScore', $this->config['SCORETABLE_LISTS'][0]['TOP_WINNERS'][0], $this->scores['TopWinners'], array('score', 'nickname'));
}
break;
}
}
unset($item);
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerInfoChanged ($aseco, $login) {
// Skip work at Score
if ($aseco->server->gamestate === Server::RACE) {
// Get current Gamemode
$gamemode = $aseco->server->gameinfo->mode;
// Refresh Player and Team membership
if (isset($this->config['ROUND_SCORE'][0]['GAMEMODE'][0][$gamemode]) && $this->config['ROUND_SCORE'][0]['GAMEMODE'][0][$gamemode][0]['ENABLED'][0] === true) {
// Get Player
if ($player = $aseco->server->players->getPlayerByLogin($login)) {
// Store the (possible changed) TeamId
$player->data['PluginRecordsEyepiece']['Prefs']['TeamId'] = $player->team_id;
}
}
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onPlayerManialinkPageAnswer ($aseco, $login, $params) {
// Get Player
if (!$player = $aseco->server->players->getPlayerByLogin($login)) {
return;
}
// Init
$widgets = '';
$require_action = false;
// F9 handling
if ($params['Action'] === 'switchDedimaniaRecordsWidget') {
$this->config['States']['DedimaniaRecords']['Visibility'] = $aseco->string2bool($params['Visible']);
return;
}
else if ($params['Action'] === 'switchLocalRecordsWidget') {
$this->config['States']['LocalRecords']['Visibility'] = $aseco->string2bool($params['Visible']);
return;
}
else if ($params['Action'] === 'switchMusicWidget') {
$this->config['States']['MusicWidget']['Visibility'] = $aseco->string2bool($params['Visible']);
return;
}
else if ($params['Action'] === 'switchLiveRankingsWidget') {
$this->config['States']['LiveRankings']['Visibility'] = $aseco->string2bool($params['Visible']);
return;
}
else if ($params['Action'] === 'switchRoundScoreWidget') {
$this->config['States']['RoundScoreWidget']['Visibility'] = $aseco->string2bool($params['Visible']);
return;
}
// Setup the answer index
$answer_index = array(
'showDedimaniaRecordsWindow',
'showLocalRecordsWindow',
'showLiveRankingsWindow',
'showMusiclistWindow',
'dropSongFromPlaylist',
'showMaplistWindow',
'showMaplistFilterWindow',
'showMaplistSortingWindow',
'showMapAuthorlistWindow',
'showHelpWindow',
'showToplistWindow',
'showTopRankingsWindow',
'showTopNationsWindow',
'showTopWinnersWindow',
'showMostRecordsWindow',
'showMostFinishedWindow',
'showTopPlaytimeWindow',
'showTopDonatorsWindow',
'showTopMapsWindow',
'showTopVotersWindow',
'showTopActivePlayersWindow',
'showTopWinningPayoutWindow',
'showTopBetwinsWindow',
'showTopRoundscoreWindow',
'showTopVisitorsWindow',
'showTopContinentsWindow',
);
if ($params['Action'] === 'spectatorUpdate' && $this->config['SPECTATOR_INFO_WIDGET'][0]['ENABLED'][0] === true) {
$this->updateSpectatorList($params['Spectator'], $params['Target']);
return;
}
if ($params['Action'] === 'showLastCurrentNextMapWindow') {
$this->buildLastCurrentNextMapWindow($player);
}
else if ($params['Action'] === 'showManiaExchangeMapInfoWindow') {
$this->buildManiaExchangeMapInfoWindow($player);
}
else if ($params['Action'] === 'addMapToPlaylist') {
// Get the selected Map
$map = $aseco->server->maps->getMapByUid($params['uid']);
// Store wished Map in Player object for jukeboxing with plugin.rasp_jukebox.php
$item = array();
$item['name'] = $map->name;
$item['author'] = $map->author;
$item['environment'] = $map->environment;
$item['filename'] = $map->filename;
$item['uid'] = $map->uid;
$player->maplist = array();
$player->maplist[] = $item;
// Juke the selected Map
$aseco->releaseChatCommand('/jukebox 1', $player->login);
// $aseco->server->maps->playlist->addMapToPlaylist($params['uid'], $player->login, 'select');
// Refresh on juke'd map
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$require_action = true;
}
else if ($params['Action'] === 'removeMapFromPlaylist') {
if ($aseco->allowAbility($player, 'dropjukebox')) {
$juked = 0;
$tid = 1;
foreach ($aseco->plugins['PluginRaspJukebox']->jukebox as $item) {
if ($item['uid'] === $params['uid']) {
$juked = $tid;
break;
}
$tid++;
}
// Drop selected map from jukebox by admin
$aseco->releaseChatCommand('/admin dropjukebox '. $juked, $login);
}
else {
// Drop user's jukeboxed map
$aseco->releaseChatCommand('/jukebox drop', $login);
}
if ($this->config['FEATURES'][0]['MAPLIST'][0]['FORCE_MAPLIST'][0] === true) {
// Refresh on drop map from jukebox
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$require_action = true;
}
}
else if ($params['Action'] === 'askDropMapFromPlaylist') {
$widgets .= $this->buildAskDropMapFromPlaylist();
}
else if ($params['Action'] === 'dropMapFromPlaylist') {
// Drop all Maps from the Jukebox
$aseco->releaseChatCommand('/admin clearjukebox', $player->login);
// Close SubWindow
$widgets .= $this->closeAllSubWindows();
// Rebuild the MaplistWindow
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$require_action = true;
}
else if ($params['Action'] === 'askDropSongFromPlaylist') {
$widgets .= $this->buildAskDropSongFromPlaylist();
}
else if ($params['Action'] === 'dropSongFromPlaylist') {
// Drop song
$aseco->releaseChatCommand('/music drop', $player->login);
// Close SubWindow
$widgets .= $this->closeAllSubWindows();
// Rebuild the MusiclistWindow
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMusiclistWindow';
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindow') {
if (count($player->data['PluginRecordsEyepiece']['Maplist']['Records']) === 0) {
if ($aseco->server->maps->count() > $this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0] && $this->config['SHOW_PROGRESS_INDICATOR'][0]['MAPLIST'][0] !== 0) {
$this->sendProgressIndicator($player->login);
}
// Load all local records from calling Player
$player->data['PluginRecordsEyepiece']['Maplist']['Records'] = $this->getPlayerLocalRecords($player->id);
// Load all Maps that the calling Player did not finished yet
$player->data['PluginRecordsEyepiece']['Maplist']['Unfinished'] = $this->getPlayerUnfinishedMaps($player->id);
}
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = false;
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyCanyonMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('environment' => 'CANYON');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyStadiumMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('environment' => 'STADIUM');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyValleyMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('environment' => 'VALLEY');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterJukeboxedMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'JUKEBOX');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterNoRecentMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NORECENT');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyRecentMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'ONLYRECENT');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsWithoutRank') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NORANK');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsWithRank') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'ONLYRANK');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsNoGoldTime') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NOGOLD');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsNoAuthorTime') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NOAUTHOR');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterMapsWithMoodSunrise') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('mood' => 'SUNRISE');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterMapsWithMoodDay') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('mood' => 'DAY');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterMapsWithMoodSunset') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('mood' => 'SUNSET');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterMapsWithMoodNight') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('mood' => 'NIGHT');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMultilapMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'ONLYMULTILAP');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterNoMultilapMaps') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NOMULTILAP');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsNoSilverTime') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NOSILVER');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsNoBronzeTime') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NOBRONZE');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterOnlyMapsNotFinished') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('cmd' => 'NOFINISH');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingBestPlayerRank') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'BEST');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingWorstPlayerRank') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'WORST');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingShortestAuthorTime') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'SHORTEST');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingLongestAuthorTime') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'LONGEST');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingNewestMapsFirst') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'NEWEST');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingOldestMapsFirst') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'OLDEST');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingByMapname') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'MAPNAME');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingByAuthorname') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'AUTHORNAME');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingByKarmaBestMapsFirst') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'BESTMAPS');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingByKarmaWorstMapsFirst') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'WORSTMAPS');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowSortingByAuthorNation') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('sort' => 'AUTHORNATION');
$require_action = true;
}
else if ($params['Action'] === 'showMaplistWindowFilterByKeyword') {
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
// $player->data['PluginRecordsEyepiece']['Window']['Page'] = 0; // already setup in chat_list()!
// $player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('key' => $command['params']); // already setup in chat_list()!
$require_action = true;
}
else if ($params['Action'] === 'handlePlayerDonation') {
// Donate the Donation
$aseco->releaseChatCommand('/donate '. $params['Amount'], $player->login);
}
else if ($params['Action'] === 'releaseChatCommand') {
foreach ($this->config['PLACEMENT_WIDGET'][0]['PLACEMENT'] as $placement) {
if (isset($placement['CHAT_MLID'][0]) && $placement['CHAT_MLID'][0] === (int)$params['id']) {
$aseco->releaseChatCommand($placement['CHAT_COMMAND'][0], $player->login);
break;
}
}
unset($placement);
}
else if ($params['Action'] === 'showMaplistWindowFilterAuthor') {
// Show the MaplistWindow (but only Maps from the selected MapAuthor)
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$player->data['PluginRecordsEyepiece']['Maplist']['Filter'] = array('author' => $params['Author']);
$require_action = true;
}
else if ($params['Action'] === 'addSongToJukebox') {
$aseco->releaseChatCommand('/music '. $params['id'], $login);
// It is required to refresh the SongIds from $aseco->plugins['PluginMusicServer']->songs
$this->config['States']['MusicServerPlaylist']['NeedUpdate'] = true;
if ($this->config['FEATURES'][0]['SONGLIST'][0]['FORCE_SONGLIST'][0] === true) {
// Refresh on juke'd song
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMusiclistWindow';
$require_action = true;
}
}
else if ( ($params['Action'] === 20) && ($this->config['FEATURES'][0]['MAPLIST'][0]['FORCE_MAPLIST'][0] === true)) {
// Refresh on drop complete jukebox (action from plugin.rasp_jukebox.php)
$player->data['PluginRecordsEyepiece']['Window']['Action'] = 'showMaplistWindow';
$require_action = true;
}
else if (in_array($params['Action'], $answer_index)) {
// Set the Window action
if ($player->data['PluginRecordsEyepiece']['Window']['Action'] !== $params['Action']) {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
}
$player->data['PluginRecordsEyepiece']['Window']['Action'] = $params['Action'];
$require_action = true;
}
else if ($params['Action'] === 'WindowPagePrev') {
$player->data['PluginRecordsEyepiece']['Window']['Page'] -= 1;
if ($player->data['PluginRecordsEyepiece']['Window']['Page'] < 0) {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
}
$require_action = true;
}
else if ($params['Action'] === 'WindowPagePrevTwo') {
$player->data['PluginRecordsEyepiece']['Window']['Page'] -= 2;
if ($player->data['PluginRecordsEyepiece']['Window']['Page'] < 0) {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
}
$require_action = true;
}
else if ($params['Action'] === 'WindowPageFirst') {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = 0;
$require_action = true;
}
else if ($params['Action'] === 'WindowPageNext') {
$player->data['PluginRecordsEyepiece']['Window']['Page'] += 1;
if ($player->data['PluginRecordsEyepiece']['Window']['Page'] > $player->data['PluginRecordsEyepiece']['Window']['MaxPage']) {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = $player->data['PluginRecordsEyepiece']['Window']['MaxPage'];
}
$require_action = true;
}
else if ($params['Action'] === 'WindowPageNextTwo') {
$player->data['PluginRecordsEyepiece']['Window']['Page'] += 2;
if ($player->data['PluginRecordsEyepiece']['Window']['Page'] > $player->data['PluginRecordsEyepiece']['Window']['MaxPage']) {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = $player->data['PluginRecordsEyepiece']['Window']['MaxPage'];
}
$require_action = true;
}
else if ($params['Action'] === 'WindowPageLast') {
$player->data['PluginRecordsEyepiece']['Window']['Page'] = $player->data['PluginRecordsEyepiece']['Window']['MaxPage'];
$require_action = true;
}
// Nothing above matched, so the Player want to see the prev/next page in the current open Window
if ($require_action === true) {
if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showDedimaniaRecordsWindow') {
$this->buildDedimaniaRecordsWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showLocalRecordsWindow') {
$this->buildLocalRecordsWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showLiveRankingsWindow') {
$this->buildLiveRankingsWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMusiclistWindow') {
$result = $this->buildMusiclistWindow($player->data['PluginRecordsEyepiece']['Window']['Page'], $player->login);
$player->data['PluginRecordsEyepiece']['Window']['MaxPage'] = $result['maxpage'];
$widgets .= $result['xml'];
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMaplistWindow') {
$result = $this->buildMaplistWindow($player->data['PluginRecordsEyepiece']['Window']['Page'], $player);
$player->data['PluginRecordsEyepiece']['Window']['MaxPage'] = $result['maxpage'];
$widgets .= $result['xml'];
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMapAuthorlistWindow') {
$result = $this->buildMapAuthorlistWindow($player->data['PluginRecordsEyepiece']['Window']['Page'], $player);
$player->data['PluginRecordsEyepiece']['Window']['MaxPage'] = $result['maxpage'];
$widgets .= $result['xml'];
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showHelpWindow') {
$this->buildHelpWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showToplistWindow') {
$this->buildToplistWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopRankingsWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_RANKINGS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopWinnersWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_WINNERS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMostRecordsWindow') {
$this->buildScorelistWindowEntry($player, 'MOST_RECORDS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMostFinishedWindow') {
$this->buildScorelistWindowEntry($player, 'MOST_FINISHED', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopPlaytimeWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_PLAYTIME', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopDonatorsWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_DONATORS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopMapsWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_MAPS', array('karma', 'map'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopVotersWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_VOTERS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopActivePlayersWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_ACTIVE_PLAYERS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopWinningPayoutWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_WINNING_PAYOUTS', array('won', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopBetwinsWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_BETWINS', array('won', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopRoundscoreWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_ROUNDSCORE', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopVisitorsWindow') {
$this->buildScorelistWindowEntry($player, 'TOP_VISITORS', array('score', 'nickname'));
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopNationsWindow') {
$this->buildTopNationsWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showTopContinentsWindow') {
$this->buildTopContinentsWindow($player);
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMaplistFilterWindow') {
$widgets .= $this->buildMaplistFilterWindow();
}
else if ($player->data['PluginRecordsEyepiece']['Window']['Action'] === 'showMaplistSortingWindow') {
$widgets .= $this->buildMaplistSortingWindow();
}
}
// Send all widgets
if (!empty($widgets)) {
// Send Manialink
$this->sendManialink($widgets, $player->login, 0);
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onDedimaniaRecordsLoaded ($aseco, $records) {
if ( (isset($aseco->plugins['PluginDedimania']->db['Map']['Records']) ) && (count($aseco->plugins['PluginDedimania']->db['Map']['Records']) > 0)) {
// Records are loaded, now we can get them into 'DedimaniaRecords' and force reload of the DedimaniaRecordsWidget
$this->config['States']['DedimaniaRecords']['NeedUpdate'] = true;
$this->buildRecordWidgets(false, array('DedimaniaRecords' => true, 'LocalRecords' => false, 'LiveRankings' => false));
}
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
// Event from plugin.dedimania.php
public function onDedimaniaRecord ($aseco, $record) {
// Player reached an new Record at the Map, need to Update the 'DedimaniaRecords'
$this->config['States']['DedimaniaRecords']['NeedUpdate'] = true;
$this->config['States']['DedimaniaRecords']['UpdateDisplay'] = true;
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
public function onLocalRecordsLoaded ($aseco, $records) {
$this->config['States']['LocalRecords']['NeedUpdate'] = true;
$this->config['States']['LocalRecords']['NoRecordsFound'] = false;
$this->config['States']['LocalRecords']['ChkSum'] = false;
}
/*
#///////////////////////////////////////////////////////////////////////#
# #
#///////////////////////////////////////////////////////////////////////#
*/
// Event from plugin.local_records.php
public function onLocalRecord ($aseco, $finish_item) {
// Check if the Player has already a LocalRecord, if not, only then increase MostRecords
// to prevent double countings.
$found = false;
foreach ($this->scores['LocalRecords'] as $item) {