• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

How do i add the "Server Offline" option?

Tyson12302

New Member
Joined
Aug 6, 2014
Messages
264
Reaction score
4
I've changed around my layout.php and now everything works fine but when my server is offline it still says 0 Players Offline instead of saying "Server Offline" I tried adding
PHP:
echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
But i don't know where. Where can i add it without moving any of the codes? Heres my layout.php with the code
PHP:
    Account Maker made by Gesior. Layout by CipSoft GmbH.<br/>Page has been viewed <?PHP echo $page_views; ?> times. Load time: <?PHP echo round($time, 4); ?> seconds, queries: <?PHP echo $SQL->queriesCount; ?>
          </div>
        </div>
        <div id="ThemeboxesColumn">
          <div id="RightArtwork">
            <img id="Monster" src="<?PHP echo $layout_name; ?>/images/hellhound.gif" alt="Monster of the Week" />
            <img id="PedestalAndOnline" src="<?PHP echo $layout_name; ?>/images/header/pedestal-and-online.gif" alt="Monster Pedestal and Players Online Box"/>
                  <?PHP
                  if(count($config['site']['worlds']) > 1)
                          $whoisonlineworld = '?subtopic=whoisonline';
                  else
                          $whoisonlineworld = '?subtopic=whoisonline&world=0';
                  ?>
             <div id="PlayersOnline" onClick="window.location='<?PHP echo $whoisonlineworld; ?>'">

                <?php
        $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
        echo $online[0].'<br />Players Online';
                ?>
</div>
        </div>
Where can i add the "Server Offline"?
 
Edit: Nevermind, I completely misread the topic. I'm not aware if Gesior's AAC has a method for checking if the server is online or not.
 
Ohh cuz i just wanted to know if there was a way to add
PHP:
echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
on the code to make it work. When i do it the page is white so theres something wrong with it. Heres a other script with the code in it.
PHP:
     <?PHP
            if($config['status']['serverStatus_online'] == 1)
                echo $config['status']['serverStatus_players'].'<br />Players Online';
            else
                echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
         ?></div>
        </div>
But i want that
PHP:
echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
to work on my code which is
PHP:
<?php
 $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
 echo $online[0].'<br />Players Online';?></div>
 </div>
without changing anything.
 
I downloaded a version of the AAC because I felt stupid by misreading the topic, lol. From what it looks like, it stores the server information within a cache/serverstatus file. Would you mind trying the following snippet?
PHP:
<?php

$server = parse_ini_file('cache/serverstatus');

if (isset($server['serverStatus_online']) and $server['serverStatus_online'] > 0) {
    $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
    echo $online[0].'<br />Players Online';
} else {
    echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
}
 
Now it shows "Server Offline" but the server is online. Here is how it looks now
PHP:
<?php

$server = parse_ini_file('cache/serverstatus');

if (isset($server['serverStatus_online']) and $server['serverStatus_online'] > 0) {
    $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
    echo $online[0].'<br />Players Online';
} else {
    echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
}
       
                ?>
</div>
        </div>
 
Add a var_dump below the $server line, please, and tell me the result.
PHP:
$server = parse_ini_file('cache/serverstatus');
echo '<pre>', var_dump($server), '</pre>';
 
Still says "Offline" when its on heres a pic
EBhsrpC.png
 
If you'd allow me to connect to you through TeamViewer, we can easily sort this out. Otherwise, please check the contents of the file cache/serverstatus and post whatever it contains.
 
Code:
serverStatus_checkInterval = "303"
    serverStatus_lastCheck = "1435348960"
    serverStatus_online = "1"
    serverStatus_players = "1"
    serverStatus_playersMax = "1000"
    serverStatus_uptime = "1h 1m"
    serverStatus_monsters = "23627"

EDIT: This code works but it updates like every 5mins which is not what i want
PHP:
         <?PHP
            if($config['status']['serverStatus_online'] == 1)
                echo $config['status']['serverStatus_players'].'<br />Players Online';
            else
                echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
         ?></div>
        </div>
 
This should do the trick, works locally for me.
PHP:
<?php


$server = parse_ini_file('cache/serverstatus');
$online = ((boolean) isset($server['serverStatus_online']) and (int) $server['serverStatus_online'] > 0);

if ($online) {
    $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
    echo $online[0].'<br />Players Online';
} else {
    echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
}
 
hmm i think i might be pasting it wrong. Can you paste your layout.php here and see if its the same. If it works for you then i must be pasting it wrong.
This is how my looks like
PHP:
            Account Maker made by Gesior. Layout by CipSoft GmbH.<br/>Page has been viewed <?PHP echo $page_views; ?> times. Load time: <?PHP echo round($time, 4); ?> seconds, queries: <?PHP echo $SQL->queriesCount; ?>
          </div>
        </div>
        <div id="ThemeboxesColumn">
          <div id="RightArtwork">
            <img id="Monster" src="<?PHP echo $layout_name; ?>/images/Gaz'haragoth.gif" alt="Monster of the Week" />
            <img id="PedestalAndOnline" src="<?PHP echo $layout_name; ?>/images/header/pedestal-and-online.gif" alt="Monster Pedestal and Players Online Box"/>
                  <?PHP
                  if(count($config['site']['worlds']) > 1)
                          $whoisonlineworld = '?subtopic=whoisonline';
                  else
                          $whoisonlineworld = '?subtopic=whoisonline&world=0';
                  ?>
             <div id="PlayersOnline" onClick="window.location='<?PHP echo $whoisonlineworld; ?>'">

<?php


$server = parse_ini_file('cache/serverstatus');
$online = ((boolean) isset($server['serverStatus_online']) and (int) $server['serverStatus_online'] > 0);
if ($online) {
    $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
    echo $online[0].'<br />Players Online';
} else {
    echo '<font color="red"><b>Server<br />OFFLINE</b></font>';
}
                ?>
</div>
        </div>

  <div id="Themeboxes">
         
  <div id="NewcomerBox" class="Themebox" style="background-image:url(<?PHP echo $layout_name; ?>/images/themeboxes/newcomer/newcomerbox.gif);">
    <div class="ThemeboxButton" onClick="BigButtonAction('?subtopic=createaccount')" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url(<?PHP echo $layout_name; ?>/images/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url(<?PHP echo $layout_name; ?>/images/buttons/sbutton_over.gif);"></div>
      <div class="ButtonText" style="background-image:url(<?PHP echo $layout_name; ?>/images/buttons/_sbutton_jointibia.gif);"></div>
    </div>
    <div class="Bottom" style="background-image:url(<?PHP echo $layout_name; ?>/images/general/box-bottom.gif);"></div>
  </div>

        </div>
      </div>
     </div>
    </div>
  </div>
</body>
</html>
</html>
 
I'm not using a layout.php file, I'm using a standalone php file, outside of gesior. It is possible that you're getting a notice/warning and it's being surpressed though. Try adding error_reporting(E_ALL); ini_set('display_errors', true); just below <?php.
 
I get this error
Warning: parse_ini_file(cache/serverstatus): failed to open stream: No such file or directory in C:\Users\Tyson\Desktop\UniServer\www\layouts\tibiacom\layout.php on line 406 Server
OFFLINE
 
Ahh ill just use this
PHP:
 Account Maker made by Gesior. Layout by CipSoft GmbH.<br/>Page has been viewed <?PHP echo $page_views; ?> times. Load time: <?PHP echo round($time, 4); ?> seconds, queries: <?PHP echo $SQL->queriesCount; ?>
          </div>
        </div>
        <div id="ThemeboxesColumn">
          <div id="RightArtwork">
            <img id="Monster" src="<?PHP echo $layout_name; ?>/images/hellhound.gif" alt="Monster of the Week" />
            <img id="PedestalAndOnline" src="<?PHP echo $layout_name; ?>/images/header/pedestal-and-online.gif" alt="Monster Pedestal and Players Online Box"/>
                  <?PHP
                  if(count($config['site']['worlds']) > 1)
                          $whoisonlineworld = '?subtopic=whoisonline';
                  else
                          $whoisonlineworld = '?subtopic=whoisonline&world=0';
                  ?>
             <div id="PlayersOnline" onClick="window.location='<?PHP echo $whoisonlineworld; ?>'">

                <?php
        $online = $SQL->query('SELECT COUNT(*) FROM players WHERE online > 0')->fetch();
        echo $online[0].'<br />Players Online';
                ?>
</div>
        </div>
Guess i wont have the "Server Offline" feature.
 
All right, well let me know if you change your mind. Happy to help over TeamViewer as mentioned previously.
 
Back
Top