2013-11-09 20:18:49 +01:00
|
|
|
<?php
|
|
|
|
|
2013-11-12 15:48:25 +01:00
|
|
|
namespace ManiaControl\Players;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/Player.php';
|
2013-12-05 00:30:10 +01:00
|
|
|
require_once __DIR__ . '/PlayerCommands.php';
|
2014-01-03 16:24:35 +01:00
|
|
|
require_once __DIR__ . '/PlayerDetailed.php';
|
2013-11-12 15:48:25 +01:00
|
|
|
|
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
|
|
|
use ManiaControl\Callbacks\CallbackManager;
|
2013-12-31 20:10:40 +01:00
|
|
|
use ManiaControl\Formatter;
|
|
|
|
use ManiaControl\ManiaControl;
|
2014-01-03 19:14:07 +01:00
|
|
|
use ManiaControl\Statistics\StatisticManager;
|
2013-11-09 20:18:49 +01:00
|
|
|
|
|
|
|
/**
|
2013-11-10 02:55:08 +01:00
|
|
|
* Class managing players
|
|
|
|
*
|
2013-11-10 17:23:00 +01:00
|
|
|
* @author kremsy & steeffeen
|
2013-11-09 20:18:49 +01:00
|
|
|
*/
|
2013-11-12 15:48:25 +01:00
|
|
|
class PlayerManager implements CallbackListener {
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
2014-01-02 13:35:52 +01:00
|
|
|
const CB_PLAYERJOINED = 'PlayerManagerCallback.PlayerJoined';
|
|
|
|
const CB_PLAYERDISCONNECTED = 'PlayerManagerCallback.PlayerDisconnected';
|
|
|
|
const CB_ONINIT = 'PlayerManagerCallback.OnInit';
|
|
|
|
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
|
|
|
const TABLE_PLAYERS = 'mc_players';
|
2013-11-12 19:33:25 +01:00
|
|
|
const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages';
|
2014-01-03 18:37:51 +01:00
|
|
|
const STAT_JOIN_COUNT = 'Joins';
|
|
|
|
const STAT_PLAYTIME = 'Playtime';
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
2014-01-01 18:53:19 +01:00
|
|
|
* Public Properties
|
2013-11-10 02:55:08 +01:00
|
|
|
*/
|
2014-01-01 18:53:19 +01:00
|
|
|
public $playerActions = null;
|
|
|
|
public $playerCommands = null;
|
2014-01-03 16:24:35 +01:00
|
|
|
public $playerDetailed = null;
|
2014-01-01 18:53:19 +01:00
|
|
|
public $playerList = array();
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-12-28 19:48:06 +01:00
|
|
|
/**
|
2014-01-01 18:53:19 +01:00
|
|
|
* Private Properties
|
2013-12-28 19:48:06 +01:00
|
|
|
*/
|
2014-01-01 18:53:19 +01:00
|
|
|
private $maniaControl = null;
|
2013-12-28 19:48:06 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
2014-01-01 18:53:19 +01:00
|
|
|
* Construct a new Player Manager
|
2013-11-10 02:55:08 +01:00
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param \ManiaControl\ManiaControl $maniaControl
|
2013-11-10 02:55:08 +01:00
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
|
|
|
$this->initTables();
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-12-05 00:30:10 +01:00
|
|
|
$this->playerCommands = new PlayerCommands($maniaControl);
|
2014-01-02 13:35:52 +01:00
|
|
|
$this->playerActions = new PlayerActions($maniaControl);
|
2014-01-03 16:24:35 +01:00
|
|
|
$this->playerDetailed = new PlayerDetailed($maniaControl);
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
// Init settings
|
2013-12-08 22:38:20 +01:00
|
|
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
// Register for callbacks
|
2013-11-12 15:48:25 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit');
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
2014-01-02 13:35:52 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
|
|
|
|
2014-01-01 18:53:19 +01:00
|
|
|
// Define player stats
|
2013-12-31 20:10:40 +01:00
|
|
|
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
|
2014-01-03 19:14:07 +01:00
|
|
|
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME, StatisticManager::STAT_TYPE_TIME);
|
2013-11-10 02:55:08 +01:00
|
|
|
}
|
2013-11-09 23:01:54 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
2013-11-10 20:21:12 +01:00
|
|
|
* Initialize necessary database tables
|
2013-11-10 02:55:08 +01:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function initTables() {
|
2014-01-02 13:35:52 +01:00
|
|
|
$mysqli = $this->maniaControl->database->mysqli;
|
|
|
|
$playerTableQuery = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLAYERS . "` (
|
2013-11-10 02:55:08 +01:00
|
|
|
`index` int(11) NOT NULL AUTO_INCREMENT,
|
|
|
|
`login` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
2013-11-10 17:23:00 +01:00
|
|
|
`nickname` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
|
|
|
|
`path` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
2013-11-10 19:30:14 +01:00
|
|
|
`authLevel` int(11) NOT NULL DEFAULT '0',
|
2013-11-10 02:55:08 +01:00
|
|
|
`changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
PRIMARY KEY (`index`),
|
|
|
|
UNIQUE KEY `login` (`login`)
|
2014-01-01 18:53:19 +01:00
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Player Data' AUTO_INCREMENT=1;";
|
2013-11-10 02:55:08 +01:00
|
|
|
$playerTableStatement = $mysqli->prepare($playerTableQuery);
|
2014-01-02 13:35:52 +01:00
|
|
|
if($mysqli->error) {
|
2013-11-10 02:55:08 +01:00
|
|
|
trigger_error($mysqli->error, E_USER_ERROR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$playerTableStatement->execute();
|
2014-01-02 13:35:52 +01:00
|
|
|
if($playerTableStatement->error) {
|
2013-11-10 02:55:08 +01:00
|
|
|
trigger_error($playerTableStatement->error, E_USER_ERROR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$playerTableStatement->close();
|
|
|
|
return true;
|
|
|
|
}
|
2013-11-09 20:18:49 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Handle OnInit callback
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param array $callback
|
2013-11-10 02:55:08 +01:00
|
|
|
*/
|
|
|
|
public function onInit(array $callback) {
|
2013-11-12 19:33:25 +01:00
|
|
|
// Add all players
|
2013-11-10 02:55:08 +01:00
|
|
|
$this->maniaControl->client->query('GetPlayerList', 300, 0, 2);
|
|
|
|
$playerList = $this->maniaControl->client->getResponse();
|
2014-01-02 13:35:52 +01:00
|
|
|
foreach($playerList as $playerItem) {
|
|
|
|
if($playerItem['PlayerId'] <= 0) {
|
2013-11-10 17:23:00 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-11-12 15:48:25 +01:00
|
|
|
$this->maniaControl->client->query('GetDetailedPlayerInfo', $playerItem['Login']);
|
|
|
|
$playerInfo = $this->maniaControl->client->getResponse();
|
2014-01-02 13:35:52 +01:00
|
|
|
$player = new Player($playerInfo);
|
2013-11-12 15:48:25 +01:00
|
|
|
$this->addPlayer($player);
|
2013-11-10 02:55:08 +01:00
|
|
|
}
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-11-28 03:47:08 +01:00
|
|
|
// Trigger own callback
|
|
|
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT, array(self::CB_ONINIT));
|
2013-11-10 02:55:08 +01:00
|
|
|
}
|
2013-11-09 20:18:49 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Handle playerConnect callback
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param array $callback
|
2013-11-10 02:55:08 +01:00
|
|
|
*/
|
|
|
|
public function playerConnect(array $callback) {
|
|
|
|
$login = $callback[1][0];
|
|
|
|
$this->maniaControl->client->query('GetDetailedPlayerInfo', $login);
|
|
|
|
$playerInfo = $this->maniaControl->client->getResponse();
|
2014-01-02 13:35:52 +01:00
|
|
|
$player = new Player($playerInfo);
|
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
$this->addPlayer($player);
|
2014-01-02 13:35:52 +01:00
|
|
|
|
|
|
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
|
|
|
|
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
|
|
|
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!';
|
2013-12-31 15:27:25 +01:00
|
|
|
$this->maniaControl->chat->sendChat($chatMessage);
|
|
|
|
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
2013-11-10 22:08:43 +01:00
|
|
|
}
|
2014-01-02 13:35:52 +01:00
|
|
|
|
|
|
|
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " . $player->getCountry() . " IP: {$player->ipAddress}";
|
2013-12-31 15:27:25 +01:00
|
|
|
$this->maniaControl->log($logMessage);
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-12-31 15:27:25 +01:00
|
|
|
// Trigger own PlayerJoined callback
|
2013-11-28 03:47:08 +01:00
|
|
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERJOINED, array(self::CB_PLAYERJOINED, $player));
|
2013-11-10 02:55:08 +01:00
|
|
|
}
|
2013-11-09 22:08:06 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Handle playerDisconnect callback
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param array $callback
|
2013-11-10 02:55:08 +01:00
|
|
|
*/
|
|
|
|
public function playerDisconnect(array $callback) {
|
2014-01-02 13:35:52 +01:00
|
|
|
$login = $callback[1][0];
|
2013-11-10 02:55:08 +01:00
|
|
|
$player = $this->removePlayer($login);
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-12-29 13:18:27 +01:00
|
|
|
// Trigger own callback
|
|
|
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECTED, array(self::CB_PLAYERDISCONNECTED, $player));
|
2014-01-02 13:35:52 +01:00
|
|
|
|
|
|
|
if($player == null || $player->isFakePlayer()) {
|
2013-12-31 20:10:40 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-02 13:35:52 +01:00
|
|
|
|
|
|
|
$played = Formatter::formatTimeH(time() - $player->joinTime);
|
2014-01-01 18:53:19 +01:00
|
|
|
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
|
|
|
|
$this->maniaControl->log(Formatter::stripCodes($logMessage));
|
2014-01-02 13:35:52 +01:00
|
|
|
|
|
|
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
2013-12-23 16:14:03 +01:00
|
|
|
$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game');
|
2013-12-09 19:31:55 +01:00
|
|
|
}
|
2013-11-10 02:55:08 +01:00
|
|
|
}
|
2013-11-09 22:08:06 +01:00
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
/**
|
|
|
|
* Update PlayerInfo
|
2013-12-31 15:27:25 +01:00
|
|
|
*
|
2013-12-19 21:59:10 +01:00
|
|
|
* @param array $callback
|
|
|
|
*/
|
2013-12-31 15:27:25 +01:00
|
|
|
public function playerInfoChanged(array $callback) {
|
2013-12-19 21:59:10 +01:00
|
|
|
$player = $this->getPlayer($callback[1][0]['Login']);
|
2014-01-02 13:35:52 +01:00
|
|
|
if($player == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$player->teamId = $callback[1][0]["TeamId"];
|
2013-12-19 22:29:21 +01:00
|
|
|
$player->isSpectator = $callback[1][0]["SpectatorStatus"];
|
2014-01-02 13:35:52 +01:00
|
|
|
$player->ladderRank = $callback[1][0]["LadderRanking"];
|
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
// Trigger own callback
|
|
|
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERINFOCHANGED, array(self::CB_PLAYERINFOCHANGED));
|
|
|
|
}
|
|
|
|
|
2013-11-28 01:12:52 +01:00
|
|
|
/**
|
|
|
|
* Get the complete PlayerList
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getPlayers() {
|
|
|
|
return $this->playerList;
|
|
|
|
}
|
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Get a Player from the PlayerList
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param string $login
|
2013-11-10 02:55:08 +01:00
|
|
|
* @return Player
|
|
|
|
*/
|
|
|
|
public function getPlayer($login) {
|
2014-01-02 13:35:52 +01:00
|
|
|
if(!isset($this->playerList[$login])) {
|
2013-11-10 02:55:08 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return $this->playerList[$login];
|
|
|
|
}
|
2013-11-09 22:08:06 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Add a player to the PlayerList
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param Player $player
|
2013-11-10 02:55:08 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function addPlayer(Player $player) {
|
2014-01-02 13:35:52 +01:00
|
|
|
if(!$player) {
|
2013-11-10 02:55:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
2013-11-10 17:23:00 +01:00
|
|
|
$this->savePlayer($player);
|
2013-11-10 02:55:08 +01:00
|
|
|
$this->playerList[$player->login] = $player;
|
|
|
|
return true;
|
|
|
|
}
|
2013-11-09 22:08:06 +01:00
|
|
|
|
2013-11-10 02:55:08 +01:00
|
|
|
/**
|
|
|
|
* Remove a Player from the PlayerList
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param string $login
|
2014-01-02 13:35:52 +01:00
|
|
|
* @param bool $savePlayedTime
|
2013-11-10 02:55:08 +01:00
|
|
|
* @return Player $player
|
|
|
|
*/
|
2013-11-10 17:23:00 +01:00
|
|
|
private function removePlayer($login, $savePlayedTime = true) {
|
2014-01-02 13:35:52 +01:00
|
|
|
if(!isset($this->playerList[$login])) {
|
2013-11-10 02:55:08 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$player = $this->playerList[$login];
|
|
|
|
unset($this->playerList[$login]);
|
2014-01-02 13:35:52 +01:00
|
|
|
if($savePlayedTime) {
|
2013-11-10 17:23:00 +01:00
|
|
|
$this->updatePlayedTime($player);
|
|
|
|
}
|
2013-11-10 02:55:08 +01:00
|
|
|
return $player;
|
|
|
|
}
|
2013-11-10 17:23:00 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save player in database and fill up object properties
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param Player $player
|
2014-01-03 21:06:24 +01:00
|
|
|
* @internal param int $joinCount
|
2013-11-10 17:23:00 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
2014-01-01 18:53:19 +01:00
|
|
|
private function savePlayer(Player &$player) {
|
2013-11-10 17:23:00 +01:00
|
|
|
$mysqli = $this->maniaControl->database->mysqli;
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-11-10 17:23:00 +01:00
|
|
|
// Save player
|
2014-01-02 13:35:52 +01:00
|
|
|
$playerQuery = "INSERT INTO `" . self::TABLE_PLAYERS . "` (
|
2013-11-10 17:23:00 +01:00
|
|
|
`login`,
|
|
|
|
`nickname`,
|
2014-01-01 18:53:19 +01:00
|
|
|
`path`
|
2013-11-10 17:23:00 +01:00
|
|
|
) VALUES (
|
2014-01-01 18:53:19 +01:00
|
|
|
?, ?, ?
|
2013-11-10 17:23:00 +01:00
|
|
|
) ON DUPLICATE KEY UPDATE
|
|
|
|
`index` = LAST_INSERT_ID(`index`),
|
|
|
|
`nickname` = VALUES(`nickname`),
|
2014-01-01 18:53:19 +01:00
|
|
|
`path` = VALUES(`path`);";
|
2013-11-10 17:23:00 +01:00
|
|
|
$playerStatement = $mysqli->prepare($playerQuery);
|
2014-01-02 13:35:52 +01:00
|
|
|
if($mysqli->error) {
|
2013-11-10 17:23:00 +01:00
|
|
|
trigger_error($mysqli->error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-01-01 18:53:19 +01:00
|
|
|
$playerStatement->bind_param('sss', $player->login, $player->nickname, $player->path);
|
2013-11-10 17:23:00 +01:00
|
|
|
$playerStatement->execute();
|
2014-01-02 13:35:52 +01:00
|
|
|
if($playerStatement->error) {
|
2013-11-10 17:23:00 +01:00
|
|
|
trigger_error($playerStatement->error);
|
|
|
|
$playerStatement->close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$player->index = $playerStatement->insert_id;
|
|
|
|
$playerStatement->close();
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2014-01-01 18:53:19 +01:00
|
|
|
// Get Player Auth Level from DB
|
2014-01-02 13:35:52 +01:00
|
|
|
$playerQuery = "SELECT `authLevel` FROM `" . self::TABLE_PLAYERS . "` WHERE `index` = ?;";
|
2013-11-10 17:23:00 +01:00
|
|
|
$playerStatement = $mysqli->prepare($playerQuery);
|
2014-01-02 13:35:52 +01:00
|
|
|
if($mysqli->error) {
|
2013-11-10 17:23:00 +01:00
|
|
|
trigger_error($mysqli->error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$playerStatement->bind_param('i', $player->index);
|
|
|
|
$playerStatement->execute();
|
2014-01-02 13:35:52 +01:00
|
|
|
if($playerStatement->error) {
|
2013-11-10 17:23:00 +01:00
|
|
|
trigger_error($playerStatement->error);
|
|
|
|
$playerStatement->close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$playerStatement->store_result();
|
2014-01-01 18:53:19 +01:00
|
|
|
$playerStatement->bind_result($player->authLevel);
|
2013-11-10 17:23:00 +01:00
|
|
|
$playerStatement->fetch();
|
|
|
|
$playerStatement->free_result();
|
|
|
|
$playerStatement->close();
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2014-01-01 18:53:19 +01:00
|
|
|
// Increment the Player Join Count
|
2014-01-03 21:06:24 +01:00
|
|
|
$this->maniaControl->statisticManager->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->server->getServerId());
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2013-11-10 17:23:00 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update total played time of the player
|
|
|
|
*
|
2013-12-31 15:27:25 +01:00
|
|
|
* @param Player $player
|
2013-11-10 17:23:00 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function updatePlayedTime(Player $player) {
|
2014-01-02 13:35:52 +01:00
|
|
|
if(!$player) {
|
2013-11-10 17:23:00 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$playedTime = time() - $player->joinTime;
|
2014-01-02 13:35:52 +01:00
|
|
|
|
2014-01-03 21:06:24 +01:00
|
|
|
return $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, $this->maniaControl->server->getServerId(), $playedTime);
|
2013-11-10 17:23:00 +01:00
|
|
|
}
|
2013-11-12 15:48:25 +01:00
|
|
|
}
|