Exemplo n.º 1
0
 function onLoad()
 {
     //Check if the plugin is not connected on the lobby server
     if ($this->isPluginLoaded('\\ManiaLivePlugins\\MatchMakingLobby\\Lobby\\Plugin')) {
         throw new Exception('Lobby and match cannot be one the same server.');
     }
     //Set the maxPlayer number to 0 to avoid unwanted connection
     $this->connection->cleanGuestList();
     $this->connection->addGuest('-_-');
     $this->connection->setHideServer(1);
     $this->connection->setMaxPlayers(0);
     $this->connection->setMaxSpectators(0);
     $this->connection->removeGuest('-_-');
     $this->nextTick = new \DateTime();
     $ratios = array(new Structures\VoteRatio('SetModeScriptSettingsAndCommands', -1.0), new Structures\VoteRatio('Kick', 0.7), new Structures\VoteRatio('Ban', -1.0), new Structures\VoteRatio('AutoTeamBalance', -1.0), new Structures\VoteRatio('RestartMap', -1.0));
     $this->connection->setCallVoteRatiosEx(false, $ratios);
     $this->connection->setCallVoteTimeOut(15000);
     $this->state = self::SLEEPING;
     $this->enableTickerEvent();
     //Set needed rules to run the lobny
     $matchSettingsClass = $this->config->getMatchSettingsClassName($this->scriptName);
     /* @var $matchSettings \ManiaLivePlugins\MatchMakingLobby\MatchSettings\MatchSettings */
     if (!class_exists($matchSettingsClass)) {
         throw new \Exception(sprintf("Can't find class %s. You should set up the config : ManiaLivePlugins\\MatchMakingLobby\\Config.matchSettingsClassName", $matchSettingsClass));
     }
     $matchSettings = new $matchSettingsClass();
     $settings = $matchSettings->getMatchScriptSettings();
     $this->connection->setModeScriptSettings($settings);
     $this->lobby = $this->matchMakingService->getLobby($this->config->lobbyLogin);
     if (!$this->lobby) {
         throw new \Exception('The lobby can\'t be found in the database. Are you sure that lobby and match server are sharing the same database?');
     }
     $this->connection->setServerTag('nl.lobbylogin', $this->config->lobbyLogin);
     $this->connection->customizeQuitDialog($this->gui->getCustomizedQuitDialogManiaLink(), '#qjoin=' . $this->lobby->backLink, false, 10000);
     //Check if a match existed before to cancel it
     $match = $this->matchMakingService->getServerCurrentMatch($this->storage->serverLogin, $this->scriptName, $this->titleIdString);
     if ($match) {
         $this->matchMakingService->updateMatchState($match->id, Services\Match::FINISHED);
         $this->matchMakingService->updateServerCurrentMatchId(null, $this->storage->serverLogin, $this->scriptName, $this->titleIdString);
     }
     //Restart map to initialize script
     $this->connection->executeMulticall();
     // Flush calls
     $this->connection->restartMap();
 }