function __construct($channelData, $permissionsList) { $this->channelId = (int) $channelData['cid']; if (isset(self::$byId[$this->channelId])) { self::Erase($this->channelId); } self::$byId[$this->channelId] = $this; if (isset($channelData['pid'])) { $this->parentId = (int) $channelData['pid']; } else { if (isset($channelData['cpid'])) { $this->parentId = (int) $channelData['cpid']; } } if (isset($channelData['channel_name'])) { $this->name = strval($channelData['channel_name']); } if (isset($permissionsList['i_channel_needed_join_power'])) { $this->joinPower = (int) $permissionsList['i_channel_needed_join_power']['permvalue']; } if (isset($permissionsList['i_client_needed_talk_power'])) { $this->talkPower = (int) $permissionsList['i_client_needed_talk_power']['permvalue']; } $config = \ManiaLivePlugins\Standard\TeamSpeak\Config::getInstance(); $actionHandler = \ManiaLive\Gui\ActionHandler::getInstance(); $tsconnection = \ManiaLivePlugins\Standard\TeamSpeak\Connection::getInstance(); if ($config->serverChannelPath && $this->getPath() == $config->serverChannelPath) { self::$serverIds[self::PATH] = $this->channelId; } else { if ($this->parentId == self::$serverIds[self::PATH] && $this->name == $config->serverChannelName) { self::$serverIds[self::FREE_TALK] = $this->channelId; self::$moveActions[self::FREE_TALK] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId); foreach (array(self::COMMENTS, self::TEAM_1, self::TEAM_2) as $const) { if (self::$serverIds[$const]) { self::$serverIds[$const] = 0; $actionHandler->deleteAction(self::$moveActions[$const]); self::$moveActions[$const] = null; } } } else { if (self::$serverIds[self::FREE_TALK] && $this->parentId == self::$serverIds[self::FREE_TALK]) { if ($this->joinPower == TeamSpeak::BASIC_POWER) { self::$serverIds[self::TEAM_1] = $this->channelId; self::$moveActions[self::TEAM_1] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId); } else { if ($this->joinPower == TeamSpeak::BASIC_POWER + 1) { self::$serverIds[self::TEAM_2] = $this->channelId; self::$moveActions[self::TEAM_2] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId); } else { if ($this->talkPower == TeamSpeak::BASIC_POWER) { self::$serverIds[self::COMMENTS] = $this->channelId; self::$moveActions[self::COMMENTS] = $actionHandler->createAction(array($tsconnection, 'movePlayer'), $this->channelId); } } } } } } }
function setNotConnected() { $this->comments->setVisibility(false); $this->comments->disableLinks(); $this->comments->setBgcolor('8888'); $this->freeTalk->setVisibility(false); $this->freeTalk->disableLinks(); $this->freeTalk->setBgcolor('8888'); $this->logo->setIconImage(TSImages::getInstance()->tsGrey); $this->logo->setUrl(\ManiaLivePlugins\Standard\TeamSpeak\Config::getInstance()->getConnectUrl($this->getRecipient())); $this->status->setText('Connect to the local TeamSpeak server. ManiaPlanet will be minimized.'); }
function onLoad() { $config = Config::getInstance(); if (!$config->serverChannelName) { $config->serverChannelName = substr('ManiaPlanet> ' . Formatting::stripStyles($this->connection->getMainServerPlayerInfo()->nickName), 0, 40); } $this->tsConnection = Connection::getInstance(); $this->tsConnection->open(); if (!$this->tsConnection->isConnected()) { $this->enableTickerEvent(); } Signal::getInstance()->subscribe('notifyEvent', array($this, 'onTeamSpeakEvent')); $this->enableDedicatedEvents(ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT | ServerEvent::ON_PLAYER_INFO_CHANGED); }
function __construct($clientData, $customData) { $this->clientId = (int) $clientData['clid']; $this->databaseId = (int) $clientData['client_database_id']; self::$byId[$this->clientId] = $this; if (isset($clientData['cid'])) { $this->channelId = (int) $clientData['cid']; } else { if (isset($clientData['ctid'])) { $this->channelId = (int) $clientData['ctid']; } } if (isset($clientData['client_talk_power'])) { $this->isCommentator = $clientData['client_talk_power'] == TeamSpeak::BASIC_POWER; } if (isset($customData['maniaplanet_login'])) { $this->login = $customData['maniaplanet_login']; $this->isCommentator = $this->isCommentator || in_array($this->login, Config::getInstance()->commentators); self::$byLogin[$this->login] = $this; } }
function onTick() { if (++$this->tick % 5 == 0) { try { if ($this->tick % 60 == 0) { $this->server->request('whoami'); $this->processHandler->addTask($this->processId, new Tasks\ConnectionKeepAlive(Config::getInstance())); } } catch (\Exception $e) { $this->close(false); } } }