function kill() { if ($this->connection) { $this->connection->manualFlowControlEnable(false); } $this->running = false; }
function man($login, $commandName, $parametersCount = -2) { $commandName = strtolower($commandName); if ($parametersCount == -2 && isset($this->registeredCommands[$commandName])) { $help = array(); $help[] = 'Available $<$o$FC4' . $commandName . '$> commands:'; foreach ($this->registeredCommands[$commandName] as $command) { if (!count($command->authorizedLogin) || in_array($login, $command->authorizedLogin)) { $help[] = '$<$o$FC4' . $command->name . ' (' . $command->parametersCount . ')$>' . ($command->help ? ':' . $command->help : ''); } } $text = implode("\n", $help); } else { if (isset($this->registeredCommands[$commandName][$parametersCount])) { $command = $this->registeredCommands[$commandName][$parametersCount]; if (!count($command->authorizedLogin) || in_array($login, $command->authorizedLogin)) { $text = '$<$o$FC4' . $command->name . ' (' . $command->parametersCount . ')$>' . ($command->help ? ':' . $command->help : ''); } else { $text = 'This command does not exists use help to see available commands'; } } else { $text = 'This command does not exists use help to see available commands'; } } $this->connection->chatSendServerMessage($text, $login, true); }
function onPlayerAlliesChanged($login) { try { $allies = $this->connection->getDetailedPlayerInfo($login)->allies; $this->getPlayerObject($login)->allies = $allies; } catch (\Exception $e) { } }
public function onEcho($internal, $public) { $call = explode(':', substr($internal, 1), 2); if (isset($call[1]) && $call[1] != $this->identifier) { return; } if (substr($internal, 0, 1) == '?') { switch ($call[0]) { case 'census': $this->connection->dedicatedEcho($this->identifier, '!census:' . $public); break; case 'stop': \ManiaLiveApplication\Application::getInstance()->kill(); break; } } }
final function __construct() { $this->dependencies = array(); $this->methods = array(); $items = explode('\\', get_class($this)); $this->author = $items[1]; $this->name = $items[2]; $this->id = $this->author . '\\' . $this->name; $this->setVersion(1); $config = \ManiaLive\DedicatedApi\Config::getInstance(); $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password); $this->pluginHandler = PluginHandler::getInstance(); $this->storage = Storage::getInstance(); $this->chatCommands = array(); }
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 onTerminate() { if (Storage::getInstance()->serverStatus->code > Status::LAUNCHING) { $this->connection->sendHideManialinkPage(); } }