function onClickMode($login, $mode) { try { $config = \ManiaLive\DedicatedApi\Config::getInstance(); Connection::factory($config->host, $config->port)->setGameMode($mode); $dialog = Dialog::Create($login, false); $dialog->setSize(125, 40); $dialog->setTitle('Game Mode Changed!'); $dialog->setText('You have selected ' . self::$modes[$mode][0] . ",\n" . 'New game mode will be set on map change!' . "\n" . 'Do you want to restart now?'); $dialog->setButtons(Dialog::YES | Dialog::NO); $dialog->addCloseCallback(array($this, 'onDialogClosed')); $dialog->centerOnScreen(); $dialog->showModal(); $this->show(); } catch (\Exception $ex) { $win = Info::Create($login, false); $win->setSize(40, 23); $win->setTitle('Error'); $win->setText($ex->getMessage()); $win->centerOnScreen(); $win->showModal(); } }
function onPlayerChangeSide($player, $oldSide) { if ($player->spectator) { if ($player->hasPlayerSlot) { try { $this->connection->spectatorReleasePlayerSlot($player); } catch (\Exception $e) { if (in_array($player->login, $this->lastWorst)) { $this->connection->kick($player->login); return; } $dialog = Dialog::Create($player->login, false); $dialog->setSize(80, 36); $dialog->setTitle('AutoQueue Warning'); $dialog->setText("There are too many spectators already.\nYou'll be kicked so someone else can play."); $dialog->setButtons(Dialog::OK | Dialog::CANCEL); $dialog->addCloseCallback(array($this, 'onKickDialogClosed')); $dialog->showModal(); return; } $this->letQueueFirstPlay(); } $queue = Queue::Create($player->login); switch ($player->forceSpectator) { case 0: $this->connection->forceSpectator($player, 1); unset($this->mapsPlayed[$player->login]); $queue->show(); break; case 1: $this->queue($player->login); $queue->setIsQueued(); $queue->show(); break; } } }