Jump to content
  • 0

Online Players and Peak


Haki

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  96
  • Reputation:   23
  • Joined:  06/14/16
  • Last Seen:  

Hello. I would like some help from someone who knows alot with html/bootstrap.

This is my website : http://asgard.ro-gaming.net/

Please help me insert a Online players/Peak at the top like the ones at

https://talonro.com/

 

Thanks.!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   1
  • Joined:  11/12/14
  • Last Seen:  

At first you need a php file something like: status.php

<?php
include("secure/config.php");

$Status = ServerStatus();
/*
 * HTML Content (Edit what you wont)
 */
// Start HTML ?>

<table border="0">
  <tr>
    <td><?php echo $Str_Loginsrv; ?></td>
    <td><?php echo $Status[0]; ?></td>
  </tr>
  <tr>
    <td><?php echo $Str_Charsrv; ?></td>
    <td><?php echo $Status[1]; ?></td>
  </tr>
  <tr>
    <td><?php echo $Str_Mapsrv; ?></td>
    <td><?php echo $Status[2]; ?></td>
  </tr>
  <tr>
      <td><?php echo $Str_onlinepl; ?></td>
      <td><?php echo PlayerCount(); ?></td>
  </tr>
</table>

<?php // End HTML


/*
 * Functions (Script by EaScriptable.de.vu)
 * Non Licensed (do what you want)
 */

    /*
     * Server Status (Return Array of Login,Char,Map State)
     */
    function ServerStatus() {
        Global $Srv_Host, $Srv_Login, $Srv_Char, $Srv_Map, $Str_Online, $Str_Offline;
        // Disable Error Reporting (for this function)
        error_reporting(0);
        
        $Status = array();
        $LoginServer = fsockopen($Srv_Host, $Srv_Login, $errno, $errstr, 1);
        $CharServer = fsockopen($Srv_Host, $Srv_Char, $errno, $errstr, 1);
        $MapServer = fsockopen($Srv_Host, $Srv_Map, $errno, $errstr, 1);
        if(!$LoginServer){ $Status[0]= $Str_Offline;  } else { $Status[0] = $Str_Online; };
        if(!$CharServer){ $Status[1] = $Str_Offline;  } else { $Status[1] = $Str_Online; };
        if(!$MapServer){ $Status[2] = $Str_Offline;  } else { $Status[2] = $Str_Online; };
        return $Status;
    }
    
    /*
     * Online Player count (Return Array of Player Count as integer)
     */
    function PlayerCount() {
    Global $Srv_Host, $Srv_Username,$Srv_Password,$Srv_Database;           
    $Connection = mysql_connect($Srv_Host, $Srv_Username, $Srv_Password) or die(mysql_error());
    mysql_select_db($Srv_Database, $Connection);
    $query = "SELECT COUNT(*) as total FROM `char` WHERE online = '1'";
    $cresult = mysql_query($query, $Connection);
    mysql_close($Connection);
    $resarray = mysql_fetch_array($cresult);
    $playeronline = $resarray["total"];
    return $playeronline;
    }
?>

after you made this you must made a file like config.php wich should be located at a different location like in this example the folder secure/config.php

in this file you setup the connection to your server and db.

<?php
/*
 * Configurations file (rAthena Status)
 * Writen by Lawliet (EaScriptable.de.vu)
 * Non Licensed (do what you want)
 * 
 */

$Srv_Host = "127.0.0.1";

// Login, Char, Map Server Port
$Srv_Login = 6900;
$Srv_Char = 6121;
$Srv_Map = 5121;

// Database Settings
$Srv_Database = "Ragnarok";
$Srv_Username = "Username";
$Srv_Password = "Password";

// Status Text
$Str_Loginsrv =  "Login Server:";
$Str_Charsrv =  "Char Server:";
$Str_Mapsrv =   "Map Server:";
$Str_onlinepl = "Player Online:";

$Str_Online = '<font color="green">Online</font>';     // (Online) + COLOR
$Str_Offline = '<font color="red">Offline</font>';   // (Offline) + COLOR
?>

 

After that the only thing you need to to is to implement the php files into your html / bootstrap site and design (css) on the right location you want to display the script.

 

Credits for the script goes to Lawliet

Edited by EvilDesign
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  96
  • Reputation:   23
  • Joined:  06/14/16
  • Last Seen:  

hmm i partially get it. I already created the config.php and status.php inside the root/secure but how do i insert this in the body or index.html?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  96
  • Reputation:   23
  • Joined:  06/14/16
  • Last Seen:  

Thanks. That helped me. Solved

Link to comment
Share on other sites

×
×
  • Create New...