added log message on player join / leave

This commit is contained in:
kremsy 2013-12-09 19:31:55 +01:00
parent 323cec03ac
commit 16c5a12cff
2 changed files with 13 additions and 9 deletions

View File

@ -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'];
@ -57,6 +56,8 @@ class Player {
$this->ladderScore = $rpcInfos['LadderStats']['PlayerRankings'][0]['Score'];
$this->ladderRank = $rpcInfos['LadderStats']['PlayerRankings'][0]['Ranking'];
$this->ipAddress = $rpcInfos['IPAddress'];
$this->joinTime = time();
}

View File

@ -129,6 +129,8 @@ class PlayerManager implements CallbackListener {
$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));
}
@ -142,11 +144,12 @@ class PlayerManager implements CallbackListener {
$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);
}
}
/**