Need a mod that displays the number of players online in the game

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Need a mod that displays the number of players online in the game

      Need a mod that displays the number of players online in the game :) for version 1.8 git

      or code that will work on version 1.8
    • PHP Source Code

      1. $OnlineUsers = Database::get()->selectSingle("SELECT COUNT(*) as count FROM %%USERS%% WHERE onlinetime >= :time;", array( ':time' => (TIMESTAMP - 3600 * 1)), 'count');
      This is on last hour. You change the :time string as you wish.

      You can also use rowcount.

      PHP Source Code

      1. Database::get()->select("SELECT * FROM %%USERS%% WHERE onlinetime >= :time;", array( ':time' => (TIMESTAMP - 3600 * 1)));
      2. $OnlineUsers = Database::get()->rowCount();
    • Russoll wrote:

      might work...worked for me

      <div id="online_user">
      {$LNG.over_online}: <span>{$online_users}</span>
      Ah yes, I forgot to mention to add on template, but it's very intuitive.. :)

      Just add the var after template array like, on the example you gave, "online_users" => $OnlineUsers,
    • hey i was wondering instead of having this line <div align="left">{$LNG.over_online}: <span>{$online_users}</span> to show how many players.

      is their code to show how many but when you hover the mouse it actually shows the players on line ie. names
    • Russoll wrote:

      hey i was wondering instead of having this line <div align="left">{$LNG.over_online}: <span>{$online_users}</span> to show how many players.

      is their code to show how many but when you hover the mouse it actually shows the players on line ie. names
      create a array foreach with the query above returning username column
    • ok so im putting </span>{$userList.id}">{$userList.username}</span> in the overview.default and i get error

      Undefined index: userList. do i need to specify this somewere else also?
    • Source Code

      1. $PlayersOnline = Database::get()->select("SELECT username FROM %%USERS%% WHERE onlinetime >= :time;", array(
      2. ':time' => (TIMESTAMP - 3600 * 1))
      3. ));
      4. $PlayersName = array();
      5. foreach($PlayersOnline as $Rows)
      6. {
      7. $PlayersName[] = array(
      8. 'name' => $Rows['username'],
      9. );
      10. }
      the simplest foreach for this and untested but should work

      The post was edited 1 time, last by Qwa ().