Esempio n. 1
0
 function onLoad()
 {
     //Check if Lobby is not running with the match plugin
     if ($this->isPluginLoaded('\\ManiaLivePlugins\\MatchMakingLobby\\Match\\Plugin')) {
         throw new \Exception('Lobby and match cannot be one the same server.');
     }
     $this->enableDedicatedEvents(ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT | ServerEvent::ON_MODE_SCRIPT_CALLBACK | ServerEvent::ON_BEGIN_MAP);
     $this->enableStorageEvents(StorageEvent::ON_PLAYER_CHANGE_SIDE | StorageEvent::ON_PLAYER_JOIN_GAME);
     /** Register to Ally Service Event */
     \ManiaLive\Event\Dispatcher::register(Services\AllyEvent::getClass(), $this);
     $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));
     }
     $this->titleIdString = $this->connection->getSystemInfo()->titleId;
     $this->backLink = $this->storage->serverLogin . ':' . $this->storage->server->password . '@' . $this->titleIdString;
     $this->registerLobby();
     $this->setLobbyInfo();
     $partySize = $this->matchMaker->getNumberOfTeam() ? (int) $this->matchMaker->getPlayersPerMatch() / $this->matchMaker->getNumberOfTeam() : 1;
     $this->gui->createWaitingScreen(\ManiaLive\Gui\ActionHandler::getInstance()->createAction(array($this, 'onPlayerReady')), $this->scriptName, $partySize, $this->config->rulesManialink, $this->config->logoURL, $this->config->logoLink);
     $this->gui->configurePlayerList($partySize > 1 ? true : false);
     foreach (array_merge($this->storage->players, $this->storage->spectators) as $login => $obj) {
         //Simulate player connection
         $this->onPlayerConnect($login, null);
     }
     $this->updatePlayerList = true;
     $matchSettings = new $matchSettingsClass();
     $settings = $matchSettings->getLobbyScriptSettings();
     $this->connection->setModeScriptSettings($settings);
     $this->enableTickerEvent();
     $this->connection->setCallVoteRatiosEx(false, array(new Structures\VoteRatio('SetModeScriptSettingsAndCommands', -1.0), new Structures\VoteRatio('NextMap', -1.0), new Structures\VoteRatio('JumpToMapIndex', -1.0), new Structures\VoteRatio('SetNextMapIndex', -1.0), new Structures\VoteRatio('RestartMap', -1.0)));
     $this->updateLobbyWindow();
     //$this->gui->showHelp($this->scriptName);
     if ($this->config->showMasters) {
         $this->gui->createMasterList();
         $this->updateMasterList();
     }
     $this->connection->disableServiceAnnounces(true);
     $this->registerChatCommand('setAllReady', 'onSetAllReady', 0, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('kickNonReady', 'onKickNotReady', 0, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('resetPenalty', 'onResetPenalty', 1, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('resetAllPenalties', 'onResetAllPenalties', 0, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->registerChatCommand('maintenance', 'onMaintenance', 1, true, \ManiaLive\Features\Admin\AdminGroup::get());
     $this->connection->restartMap();
     $this->setLocalAllyAction = \ManiaLive\Gui\ActionHandler::getInstance()->createAction(array($this, 'onPlayerSetLocalAlly'));
     $this->unsetLocalAllyAction = \ManiaLive\Gui\ActionHandler::getInstance()->createAction(array($this, 'onPlayerUnsetLocalAlly'));
 }
Esempio n. 2
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();
 }