function onLoad() { $wsConfig = \ManiaLib\WebServices\Config::getInstance(); $this->wsClient = new TrustCircles($wsConfig->username, $wsConfig->password); if ($wsConfig->username && $wsConfig->password) { $admins = AdminGroup::get(); $this->registerChatCommand('+black', 'addToBlackList', 1, true, $admins); $this->registerChatCommand('+white', 'addToWhiteList', 1, true, $admins); $this->registerChatCommand('-black', 'removeFromBlackList', 1, true, $admins); $this->registerChatCommand('-white', 'removeFromWhiteList', 1, true, $admins); $currentBlackList = array_map(function ($player) { return $player->login; }, $this->connection->getBlackList(-1, 0)); $distantBlackList = $this->wsClient->getBlackList(); foreach (array_diff($distantBlackList, $currentBlackList) as $player) { $this->connection->blackList($player); } foreach (array_diff($currentBlackList, $distantBlackList) as $player) { $this->connection->unBlackList($player); } $this->whiteList = $this->wsClient->getWhiteList(); } foreach ((array) Config::getInstance()->rules as $rule) { $this->preparedRules[] = Rule::Prepare($rule); } foreach ($this->storage->players as $player) { $this->onPlayerConnect($player->login, false); } foreach ($this->storage->spectators as $player) { $this->onPlayerConnect($player->login, true); } $this->enableDedicatedEvents(ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT); }
function onLoad() { $admins = AdminGroup::get(); $cmd = $this->registerChatCommand('next', 'chatNext', 0, true, $admins); $cmd->isPublic = false; $cmd->help = 'skips current track.'; $cmd = $this->registerChatCommand('restart', 'chatRestart', 0, true, $admins); $cmd->isPublic = false; $cmd->help = 'restarts the current map.'; $cmd = $this->registerChatCommand('setmode', 'chatChooseMode', 0, true, $admins); $cmd->isPublic = false; $cmd->help = 'sets new gamemode on the fly, will open a window to make choice.'; $cmd = $this->registerChatCommand('setname', 'chatSetName', 1, true, $admins); $cmd->isPublic = false; $cmd->help = 'sets new server name.'; $cmd = $this->registerChatCommand('setbandwidth', 'chatSetBandwidth', 1, true, $admins); $cmd->isPublic = false; $cmd->help = 'set connection upload and download speed in kbps.'; $cmd = $this->registerChatCommand('setpassword', 'chatSetPassword', 1, true, $admins); $cmd->isPublic = false; $cmd->help = 'Sets the password which will be required to connect and play on the server.'; if ($this->isPluginLoaded('Standard\\Menubar')) { $this->buildMenu(); } $this->enablePluginEvents(); }
function onLoad() { $command = $this->registerChatCommand('pay', 'toServer', 1, true); $command->help = 'Give the amount to the server' . "\n" . 'sample of usage: /pay 42 will give 42 planets to the server'; $command = $this->registerChatCommand('pay', 'toPlayer', 2, true); $command->help = 'Give the amount to player' . "\n" . 'sample of usage: /pay playerLogin 42 will give 42 planets to the player playerLogin'; $command = $this->registerChatCommand('give', 'fromServer', 2, true, AdminGroup::get()); $command->help = 'Give the amount to the player' . "\n" . 'sample of usage: /give playerLogin 42 will give 42 planets to the player playerLogin with the planets of the server account'; $command = $this->registerChatCommand('checkBill', 'checkBill', 1, true); $command->help = 'Give the current state of the bill' . "\n" . 'sample of usage: /checkBill 42 where 42 is the id of the bill'; $this->setPublicMethod('payFromServer'); $this->setPublicMethod('payToServer'); }
function onLoad() { $this->isProfiling = false; $this->askingPlayers = array(); $this->enablePluginEvents(); $cmd = $this->registerChatCommand('profile', 'startProfiler', 0, true, AdminGroup::get()); $cmd->isPublic = false; $cmd->help = 'checks the average duration of one application loop.'; $cmd = $this->registerChatCommand('stats', 'showStats', 0, true, AdminGroup::get()); $cmd->isPublic = false; $cmd->help = 'shows statistics on how the application performs.'; if ($this->isPluginLoaded('Standard\\Menubar')) { $this->onPluginLoaded('Standard\\Menubar'); } self::$me = $this; }
function pluginsParsed(Command $command) { if (!$command->isDone()) { PluginHandler::getInstance()->unload('Standard\\PluginManager'); } ThreadHandler::getInstance()->killThread($this->threadId); $this->threadId = null; foreach ($command->getResult() as $pluginId) { Manager::AddPlugin($pluginId, $this); } $this->registerChatCommand('pluginManager', 'openWindow', 0, true, AdminGroup::get()); $this->setPublicMethod('openWindow'); if ($this->isPluginLoaded('Standard\\Menubar', 1)) { $this->buildMenu(); } }
function onTick() { $config = Config::getInstance(); $time = time(); if ($config->playerIdleKick > 0) { foreach (array_diff(array_keys($this->storage->players), AdminGroup::get()) as $login) { if ($time - $this->lastActivityTime[$login] > $config->playerIdleKick) { $this->connection->kick($login); } } } if ($config->spectatorIdleKick > 0) { foreach (array_diff(array_keys($this->storage->spectators), AdminGroup::get()) as $login) { if (!in_array($login, $this->queue) && $time - $this->lastActivityTime[$login] > $config->spectatorIdleKick) { $this->connection->kick($login); } } } }
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')); }