some changes
This commit is contained in:
parent
f29a83a8bc
commit
176b9eef6d
@ -8,8 +8,10 @@ use FML\Controls\Quad;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\ManiaLink;
|
||||
use FML\Script\Script;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Statistics\StatisticManager;
|
||||
|
||||
/**
|
||||
* Player Detailed Page
|
||||
@ -225,6 +227,10 @@ class PlayerDetailed {
|
||||
$statProperties = $stat[0];
|
||||
$value = $stat[1];
|
||||
|
||||
if($statProperties->type == StatisticManager::STAT_TYPE_TIME){
|
||||
$value = Formatter::formatTimeH($value);
|
||||
}
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition(-$this->width / 2 + 70, $y);
|
||||
|
@ -10,6 +10,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Statistics\StatisticManager;
|
||||
|
||||
/**
|
||||
* Class managing players
|
||||
@ -66,7 +67,7 @@ class PlayerManager implements CallbackListener {
|
||||
|
||||
// Define player stats
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME, StatisticManager::STAT_TYPE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,9 @@ class StatisticCollector implements CallbackListener {
|
||||
const STAT_ON_DEATH = 'Deaths';
|
||||
const STAT_ON_PLAYER_REQUEST_RESPAWN = 'Respawns';
|
||||
const STAT_ON_KILL = 'Kills';
|
||||
|
||||
const SPECIAL_STAT_KILL_DEATH_RATIO = 'Kill / Death';
|
||||
|
||||
/**
|
||||
* Private Properties
|
||||
*/
|
||||
|
@ -21,7 +21,8 @@ class StatisticManager {
|
||||
const TABLE_STATMETADATA = 'mc_statmetadata';
|
||||
const TABLE_STATISTICS = 'mc_statistics';
|
||||
|
||||
const STAT_TYPE_INT = '0';
|
||||
const STAT_TYPE_INT = '0';
|
||||
const STAT_TYPE_TIME = '1';
|
||||
|
||||
/**
|
||||
* Public Properties
|
||||
@ -59,8 +60,8 @@ class StatisticManager {
|
||||
*/
|
||||
public function getStatisticData($statName, $playerId, $serverLogin = false) {
|
||||
$serverId = 0; //Temporary
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$statId = $this->getStatId($statName);
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
if($statId == null) {
|
||||
return -1;
|
||||
@ -146,7 +147,7 @@ class StatisticManager {
|
||||
*/
|
||||
public function insertStat($statName, $player, $serverLogin = '', $value, $statType = self::STAT_TYPE_INT) {
|
||||
$serverId = 0; //Temporary
|
||||
$statId = $this->getStatId($statName);
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
if($player == null) {
|
||||
return false;
|
||||
@ -207,29 +208,32 @@ class StatisticManager {
|
||||
return $this->insertStat($statName, $player, $serverLogin, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines a Stat
|
||||
*
|
||||
* @param string $statName
|
||||
* @param string $statDescription
|
||||
* @param $statName
|
||||
* @param string $type
|
||||
* @param string $statDescription
|
||||
* @return bool
|
||||
*/
|
||||
public function defineStatMetaData($statName, $statDescription = '', $type = self::STAT_TYPE_INT) {
|
||||
public function defineStatMetaData($statName, $type = self::STAT_TYPE_INT, $statDescription = '') {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$query = "INSERT IGNORE INTO `" . self::TABLE_STATMETADATA . "` (
|
||||
$query = "INSERT INTO `" . self::TABLE_STATMETADATA . "` (
|
||||
`name`,
|
||||
`type`,
|
||||
`description`
|
||||
) VALUES (
|
||||
?, ?, ?
|
||||
);";
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
`type` = VALUES(`type`),
|
||||
`description` = VALUES(`description`);";
|
||||
$statement = $mysqli->prepare($query);
|
||||
if($mysqli->error) {
|
||||
trigger_error($mysqli->error);
|
||||
return false;
|
||||
}
|
||||
$statement->bind_param('sss', $statName, $type, $statDescription);
|
||||
$statement->bind_param('sis', $statName, $type, $statDescription);
|
||||
$statement->execute();
|
||||
if($statement->error) {
|
||||
trigger_error($statement->error);
|
||||
@ -253,7 +257,7 @@ class StatisticManager {
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_STATMETADATA . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`type` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`type` int(5) NOT NULL,
|
||||
`description` varchar(150) COLLATE utf8_unicode_ci,
|
||||
PRIMARY KEY (`index`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
|
Loading…
Reference in New Issue
Block a user