Exemplo n.º 1
0
 /**
  * Gathers the server information
  *
  * @return $this
  */
 private function serverinfo()
 {
     $info = $this->client->getServerInfo();
     $this->serverinfo = $info;
     $length = count($info);
     if ($this->gameName == 'BF4') {
         switch ($info[4]) {
             case 'SquadDeathMatch0':
             case 'TeamDeathMatch0':
                 $ticketcap = $length < 28 ? null : intval($info[13]);
                 $uptime = $length < 28 ? (int) $info[14] : (int) $info[18];
                 $round = $length < 28 ? (int) $info[15] : (int) $info[19];
                 break;
             case 'CaptureTheFlag0':
             case 'Obliteration':
             case 'Chainlink0':
             case 'RushLarge0':
             case 'Domination0':
             case 'ConquestLarge0':
             case 'ConquestSmall0':
                 if ($info[4] == 'CaptureTheFlag0') {
                     $ticketcap = null;
                 } else {
                     $ticketcap = $length < 26 ? null : intval($info[11]);
                 }
                 $uptime = $length < 26 ? (int) $info[14] : (int) $info[16];
                 $round = $length < 26 ? (int) $info[15] : (int) $info[17];
                 break;
             default:
                 $ticketcap = null;
                 $uptime = -1;
                 $round = -1;
                 break;
         }
     } elseif ($this->gameName == 'BF3') {
         switch ($info[4]) {
             case 'SquadDeathMatch0':
             case 'TeamDeathMatch0':
                 $ticketcap = $length < 25 ? null : intval($info[11]);
                 $uptime = $length < 25 ? (int) $info[12] : (int) $info[16];
                 $round = $length < 25 ? (int) $info[13] : (int) $info[17];
                 break;
             case 'CaptureTheFlag0':
             case 'Obliteration':
             case 'Chainlink0':
             case 'RushLarge0':
             case 'Domination0':
             case 'ConquestLarge0':
             case 'ConquestSmall0':
                 if ($info[4] == 'CaptureTheFlag0') {
                     $ticketcap = null;
                 } else {
                     $ticketcap = $length < 25 ? null : intval($info[11]);
                 }
                 $uptime = $length < 25 ? (int) $info[12] : (int) $info[16];
                 $round = $length < 25 ? (int) $info[13] : (int) $info[17];
                 break;
             default:
                 $ticketcap = null;
                 $uptime = -1;
                 $round = -1;
                 break;
         }
     } elseif ($this->gameName == 'BFHL') {
         switch ($info[4]) {
             case 'TurfWarLarge0':
             case 'TurfWarSmall0':
             case 'Heist0':
             case 'Hotwire0':
             case 'BloodMoney0':
             case 'Hit0':
             case 'Hostage0':
             case 'TeamDeathMatch0':
             case 'CashGrab0':
                 $ticketcap = $length < 25 ? null : intval($info[11]);
                 $uptime = $length < 25 ? (int) $info[14] : (int) $info[16];
                 $round = $length < 25 ? (int) $info[15] : (int) $info[17];
                 break;
             default:
                 $ticketcap = null;
                 $uptime = -1;
                 $round = -1;
                 break;
         }
     }
     if (method_exists($this->client, 'adminVarGetRoundTimeLimit')) {
         $startingTimer = BattlefieldHelper::roundStartingTimer($info[4], $this->client->adminVarGetRoundTimeLimit(), $this->gameName);
     } else {
         $startingTimer = 0;
     }
     if (method_exists($this->client, 'adminVarGetGameModeCounter')) {
         $startingTickets = BattlefieldHelper::startingTickets($info[4], $this->client->adminVarGetGameModeCounter(), $this->gameName);
     } else {
         $startingTickets = 0;
     }
     if ($this->isLoggedIn) {
         $presetMessages = Setting::servers($this->serverID)->settings('Pre-Message List')->first()->setting_value;
     }
     $_playmode = $this->client->getPlaymodeName($info[4]);
     $_map = $this->client->getMapName($info[5]);
     $this->data['server'] = ['name' => $info[1], 'description' => trim($this->client->adminVarGetServerDescription()), 'type' => method_exists($this->client, 'adminVarGetServerType') ? $this->client->adminVarGetServerType() : null, 'isNoobOnly' => method_exists($this->client, 'adminVarGetNoobJoin') ? $this->client->adminVarGetNoobJoin() : null, 'game' => $this->server->game, 'players' => ['online' => (int) $info[2], 'max' => (int) $info[3], 'spectators' => 0, 'commanders' => 0, 'queue' => $this->server->in_queue], 'mode' => ['name' => !is_string($_playmode) ? head($_playmode) : $_playmode, 'uri' => $info[4]], 'map' => ['name' => !is_string($_map) ? head($_map) : $_map, 'uri' => $info[5], 'next' => $this->getNextMap(), 'images' => $this->server->map_image_paths], 'tickets_needed' => $ticketcap, 'tickets_starting' => $startingTickets, 'round_duration' => $startingTimer, 'times' => ['round' => ['humanize' => MainHelper::secToStr($round, true), 'seconds' => (int) $round], 'uptime' => ['humanize' => MainHelper::secToStr($uptime, true), 'seconds' => (int) $uptime], 'remaining' => ['humanize' => $info[2] >= 4 ? MainHelper::secToStr($startingTimer - $round, true) : 'PreMatch', 'seconds' => $info[2] >= 4 ? $startingTimer - $round : $startingTimer]]];
     $this->setFactions();
     $this->data['_presetmessages'] = isset($presetMessages) ? [''] + $presetMessages : [];
     $this->data['_teams'] = [['id' => 1, 'label' => sprintf('%s (%s)', $this->TEAM1['full_name'], 'Team 1')], ['id' => 2, 'label' => sprintf('%s (%s)', $this->TEAM2['full_name'], 'Team 2')], ['id' => 3, 'label' => sprintf('%s (%s)', $this->TEAM3['full_name'], 'Team 3')], ['id' => 4, 'label' => sprintf('%s (%s)', $this->TEAM4['full_name'], 'Team 4')]];
     return $this;
 }