Server Status

Results 1 to 7 of 7
  1. #1
    Banned Requnael is offline
    BannedRank
    Apr 2009 Join Date
    EstoniaLocation
    378Posts

    Server Status

    Hello guys, who have script like this http://forum.ragezone.com/f245/mopg-...r-rank-565920/ with record players


  2. #2
    Intelligent DoucheBag jur13n is offline
    MemberRank
    Jan 2008 Join Date
    Zwolle,Location
    1,946Posts

    Re: Server Status

    Server status:
    Code:
    $fp = fsockopen($srvip, $srvport, $errno, $errstr, 1);
    if (!$fp) {
        echo "<font style='color:#ab2d2d'>Offline</font></br>";
    } else {
        echo "<font style='color:#96ac19'>Online</font></br>";
        fclose($fp);
    }
    Top 5 players:
    Code:
    $query = mssql_query("SELECT TOP 5 * FROM ServerStatus WHERE DeletFlag='0' ORDER BY XP DESC");
    echo '<table>';
    echo '<tr><td>#</td><td>Name</td><td>Level</td></tr>';
    $i = 1;
    while($f = mssql_fetch_array($query)){
       echo '<tr><td>'.$i.'</td><td>'.$f['Name'].'</td><td>'.$f['Level'].'</td></tr>';
      $i++;
    }
    echo '</table>';
    Top 5 Clan:
    Code:
    $query = mssql_query("SELECT TOP 5 * FROM Clan WHERE DeletFlag='0' ORDER BY Point DESC");
    echo '<table>';
    echo '<tr><td>#</td><td>Name</td><td>Points</td></tr>';
    $i = 1;
    while($f = mssql_fetch_array($query)){
       echo '<tr><td>'.$i.'</td><td>'.$f['Name'].'</td><td>'.$f['Point'].'</td></tr>';
      $i++;
    }
    echo '</table>';
    Amount Accounts:
    Code:
    $query = mssql_query("SELECT * FROM Account");
    echo '.Total Accounts: '.mssql_num_rows($query);
    Amount Characters:
    Code:
    $query = mssql_query("SELECT * FROM Character");
    echo '.Total Characters: '.mssql_num_rows($query);
    Amount Clans:
    Code:
    $query = mssql_query("SELECT * FROM Clan");
    echo '.Total Clans: '.mssql_num_rows($query);
    Amount Online:
    Code:
    $query = mssql_query("SELECT * FROM ServerStatus WHERE Opened='1'");
    while($f = mssql_fetch_array($query)){
    echo 'Online '.$f['ServerName'].': '.$f['CurrPlayer'].'/'.$f['MaxPlayer'];
    You do need a connection to the db

  3. #3
    Pee Aitch Pee Dave is offline
    MemberRank
    Mar 2011 Join Date
    The NetherlandsLocation
    722Posts

    Re: Server Status

    Protip @jur13n:
    Instead of using *, use "SELECT COUNT(primary column) AS number". (Then just use mssql_result() to get the value.)
    Should be much faster.

    Edit: or even "SELECT TOP(1) AID FROM Account ORDER BY AID DESC" if your primary key is not messed up.
    Last edited by Dave; 15-11-12 at 10:29 AM.

  4. #4
    Hi, I'm Omar! Vusion is offline
    MemberRank
    Jan 2011 Join Date
    HereLocation
    1,658Posts

    Re: Server Status

    And you forgot about DeleteFlag.

  5. #5
    Intelligent DoucheBag jur13n is offline
    MemberRank
    Jan 2008 Join Date
    Zwolle,Location
    1,946Posts

    Re: Server Status

    Quote Originally Posted by Vusion View Post
    And you forgot about DeleteFlag.
    Oh did I?
    Re read the code.

    Ranking is with dead flag.

    TOTAL characters and clans without.

    Now you should know what I mean

    Sent from my GT-I9070 using Tapatalk 2

    Quote Originally Posted by SuperWaffle View Post
    Protip @jur13n:
    Instead of using *, use "SELECT COUNT(primary column) AS number". (Then just use mssql_result() to get the value.)
    Should be much faster.

    Edit: or even "SELECT TOP(1) AID FROM Account ORDER BY AID DESC" if your primary key is not messed up.
    Primary column?
    I'll search it up when I get at home.
    Thanks anyway (:

    Oh wait to make it load only 1 column instead of all of them and then only let them load when called in the fetch?

    Sent from my GT-I9070 using Tapatalk 2

  6. #6
    Pee Aitch Pee Dave is offline
    MemberRank
    Mar 2011 Join Date
    The NetherlandsLocation
    722Posts

    Re: Server Status

    Quote Originally Posted by jur13n View Post
    Oh did I?
    Re read the code.

    Ranking is with dead flag.

    TOTAL characters and clans without.

    Now you should know what I mean

    Sent from my GT-I9070 using Tapatalk 2



    Primary column?
    I'll search it up when I get at home.
    Thanks anyway (:

    Oh wait to make it load only 1 column instead of all of them and then only let them load when called in the fetch?

    Sent from my GT-I9070 using Tapatalk 2
    * will select all columns.
    That's not necessary when you only want 1 value.
    And I meant the primary key. (ID/AID/CID, etc. It's what makes the row unique.)

    You made a typo btw, DeletFlag -> DeleteFlag.

  7. #7
    Hi, I'm Omar! Vusion is offline
    MemberRank
    Jan 2011 Join Date
    HereLocation
    1,658Posts

    Re: Server Status

    Quote Originally Posted by jur13n View Post
    Oh did I?
    Re read the code.

    Ranking is with dead flag.

    TOTAL characters and clans without.

    Now you should know what I mean

    Sent from my GT-I9070 using Tapatalk 2



    Primary column?
    I'll search it up when I get at home.
    Thanks anyway (:

    Oh wait to make it load only 1 column instead of all of them and then only let them load when called in the fetch?

    Sent from my GT-I9070 using Tapatalk 2
    I read the code. Why'd you count deleted characters and clans? Sounds stupid enough for me.



Advertisement