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(); }
public function onPlayerConnect($login, $isSpectator) { $menu = Menu::Create($login); $menu->setPosition(136, 45); $menu->setScale(0.8); $menu->clearItems(); foreach ($this->menu as $section) { switch (count($section['buttons'])) { case 0: break; case 1: if (!$section['buttons'][0]['admin'] || AdminGroup::contains($login)) { $menu->addFinalItem($section['name'], $section['icon'], $section['buttons'][0]['callback']); } break; default: $entry = $menu->addItem($section['name'], $section['icon']); foreach ($section['buttons'] as $button) { if (!$button['admin'] || AdminGroup::contains($login)) { $entry->addSubitem($button['name'], $button['callback']); } } } } $menu->show(); }
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 onEndMap($rankings, $map, $wasWarmUp, $matchContinuesOnNextMap, $restartMap) { if ($wasWarmUp || $restartMap) { return; } $config = Config::getInstance(); $freePlaces = $this->storage->server->nextMaxPlayers - count($this->mapsPlayed); $nbToKick = max(0, min($config->lastToKick, count($this->queue)) - $this->outThisMatch - $freePlaces); while ($nbToKick > 0 && !empty($rankings)) { $ranking = array_pop($rankings); $login = $ranking['Login']; if (isset($this->mapsPlayed[$login]) && $this->mapsPlayed[$login] > 0 && !($config->ignoreAdmins && AdminGroup::contains($login))) { if ($config->queueInsteadOfKick) { $this->connection->forceSpectator($login, 1); $this->lastWorst[] = $login; } else { $this->connection->kick($login); } --$nbToKick; } } }
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')); }
function onPlayerConnect($login, $isSpectator) { if (AdminGroup::contains($login) || in_array($login, $this->whiteList)) { return; } $blacks = $whites = 0; foreach ((array) Config::getInstance()->readFrom as $circle) { $karma = $this->wsClient->getKarma($circle, $login); $blacks += $karma->blacks; $whites += $karma->whites; } foreach ($this->preparedRules as $rule) { switch ($rule->check($blacks, $whites)) { case -2: $this->addToBlackList(null, $login); return; case -1: $this->connection->kick($login, 'You\'re not a trusted player'); case 1: return; case 2: $this->addToWhiteList(null, $login); return; } } }
function onPlayerDisconnect($login, $disconnectionReason) { if (AdminGroup::contains($login)) { unset($this->connectedAdmins[$login]); } }