diff --git a/application/core/Players/Player.php b/application/core/Players/Player.php index 4c5c99e7..3b8437bb 100644 --- a/application/core/Players/Player.php +++ b/application/core/Players/Player.php @@ -30,7 +30,7 @@ class Player { public $ladderScore = -1.; public $ladderRank = -1; public $joinTime = -1; - + public $ipAddress = ''; /** * Construct a player from XmlRpc data * @@ -40,7 +40,6 @@ class Player { if (!$rpcInfos) { return; } - $this->pid = $rpcInfos['PlayerId']; $this->login = $rpcInfos['Login']; $this->nickname = $rpcInfos['NickName']; @@ -56,7 +55,9 @@ class Player { $this->isReferee = $rpcInfos['IsReferee']; $this->ladderScore = $rpcInfos['LadderStats']['PlayerRankings'][0]['Score']; $this->ladderRank = $rpcInfos['LadderStats']['PlayerRankings'][0]['Ranking']; - + + $this->ipAddress = $rpcInfos['IPAddress']; + $this->joinTime = time(); } diff --git a/application/core/Players/PlayerManager.php b/application/core/Players/PlayerManager.php index 8ad66de3..9c31b8b3 100644 --- a/application/core/Players/PlayerManager.php +++ b/application/core/Players/PlayerManager.php @@ -128,7 +128,9 @@ class PlayerManager implements CallbackListener { ' $ff0Ladder: $fff' . $player->ladderRank); $this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION,$player->login); } - + + $this->maniaControl->log('Player joined: ' . $player->login . " / " . $player->nickname . " Nation: " . $player->getCountry() . " IP: " .$player->ipAddress); + // Trigger own callback $this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERJOINED, array(self::CB_PLAYERJOINED, $player)); } @@ -141,12 +143,13 @@ class PlayerManager implements CallbackListener { public function playerDisconnect(array $callback) { $login = $callback[1][0]; $player = $this->removePlayer($login); - - if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) { - return; - } + $played = Formatter::formatTimeH(time() - $player->joinTime); - $this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $ff0has left the game. Played:$fff ' . $played); + $this->maniaControl->log("Player left: " . $player->login . " / " . $player->nickname . " Playtime: " . $played); + + if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) { + $this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $ff0has left the game. Played:$fff ' . $played); + } } /**