fixed forcetoplay

This commit is contained in:
kremsy 2014-01-14 14:37:31 +01:00 committed by Steffen Schröder
parent 8dfed19991
commit 8df21859a0
2 changed files with 24 additions and 11 deletions

View File

@ -67,9 +67,11 @@ class PlayerActions {
* *
* @param string $adminLogin * @param string $adminLogin
* @param string $targetLogin * @param string $targetLogin
* @param int $type * @param bool $userIsAbleToSelect
* @param bool $displayAnnouncement
* @internal param int $type
*/ */
public function forcePlayerToPlay($adminLogin, $targetLogin, $type = 2) { public function forcePlayerToPlay($adminLogin, $targetLogin, $userIsAbleToSelect = true, $displayAnnouncement = true) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
if(!$this->maniaControl->authenticationManager->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) { if(!$this->maniaControl->authenticationManager->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) {
$this->maniaControl->authenticationManager->sendNotAllowed($admin); $this->maniaControl->authenticationManager->sendNotAllowed($admin);
@ -80,16 +82,26 @@ class PlayerActions {
return; return;
} }
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, ($type != 1 ? 0 : 2)); $success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
if($userIsAbleToSelect) {
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_USER_SELECTABLE);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return;
}
}
// Announce force // Announce force
if($displayAnnouncement) {
$chatMessage = '$<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to Play!'; $chatMessage = '$<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to Play!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
} }
}
/** /**
* Force a Player to a certain Team * Force a Player to a certain Team
@ -110,11 +122,7 @@ class PlayerActions {
} }
if($target->isSpectator) { if($target->isSpectator) {
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER); $this->forcePlayerToPlay($adminLogin, $targetLogin, true, false);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return;
}
} }
$success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId); $success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId);

View File

@ -178,7 +178,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
if(isset($params[2]) && is_numeric($params[2])) { if(isset($params[2]) && is_numeric($params[2])) {
$type = intval($params[2]); $type = intval($params[2]);
} }
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $type); $selectable = false;
if($type == 2) {
$selectable = true;
}
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $selectable);
} }
/** /**