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
      At the moment I'm working on versions of 2moons 1.8-1.9-2.0-2.1
      --------------------------------------------------------------------------------

      My personal game
      coswars - Open
    • 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();
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate
    • 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,
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate
    • And close div))
      читаем отзыв обо мне тут, вдохновляемся, а после этого не верим в то что я выкладываю)))) предупреждаю сразу, после моих модов слетает БД, портится карма и вообще все плохо становится)))) ставим на свой страх и риск :D
    • 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
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate
    • 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
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate

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