DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • June 16, 2019, 05:43:45 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: users online list  (Read 4783 times)
0 Members and 1 Guest are viewing this topic.
AndyMC
Guest
« on: May 10, 2004, 12:35:59 AM »

I'd like to put the "User's Online" list that you see on the main login page when you're logged out, but underneath the player's stats on every page.  I'm not worried about bandwidth issues or anything like that.  I've been poking around the code but I can't really get anything to work right.
Logged
AndyMC
Guest
« Reply #1 on: May 10, 2004, 04:35:10 PM »

I suppose I could be a little more specific on my request.  The users online list I'm referring to is the one that appears in the top right corner of the page before you log in to the game.  It looks like this:

--- Users Online ---
Farmboy Daystar
Page Telemain
---------------------

Simple as that, and I'd like it to also appear under the stats on each page AFTER you log in, mainly because I have only about 20 people that play my game, and it'd be nice to see when they log in and out while playing instead of going to the "List Users" page.
Logged
MrFixIt
Guest
« Reply #2 on: May 10, 2004, 06:50:37 PM »

I suppose I could be a little more specific on my request.  The users online list I'm referring to is the one that appears in the top right corner of the page before you log in to the game.  It looks like this:

--- Users Online ---
Farmboy Daystar
Page Telemain
---------------------

Simple as that, and I'd like it to also appear under the stats on each page AFTER you log in, mainly because I have only about 20 people that play my game, and it'd be nice to see when they log in and out while playing instead of going to the "List Users" page.


Try this at your own risk.

Find on commons.php
$buffs.=appoencode("`^None`0",true);

After add:(This is from code already found in common.php)

$sql="SELECT name,alive,location,sex,level,laston,loggedin,lastip,uniqueid FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC";
      $ret.=appoencode("`bOnline Characters:`b`n");
      $result = db_query($sql) or die(sql_error($sql));
      for ($i=0;$i<db_num_rows($result);$i++){
         $row = db_fetch_assoc($result);
         //$loggedin=(date("U") - strtotime($row[laston]) < getsetting("LOGINTIMEOUT",900) && $row[loggedin]);
         //if ($loggedin) {
            $ret.=appoencode("`^$row[name]`n");
            $onlinecount++;
         //}
      }
      db_free_result($result);
      if ($onlinecount==0) $ret.=appoencode("`iNone`i");
      return $ret;


It should work, at least it did for me.


Logged
Artte
Guest
« Reply #3 on: May 10, 2004, 07:29:15 PM »

Been fiddling with your question for a good while tonight, not too long though.

in common.php, add this function somewhere in there. I put it right after the function charstats()
Code:
function onlinechars()
{
   global $session;
   
   if ($session[loggedin]){
   
      $sql="SELECT name,alive,location,sex,level,laston,loggedin,lastip,uniqueid FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC";
      $ret=appoencode(templatereplace(statstart).templatereplace("stathead",array("title"=>"Online Characters")),true);
      $result = db_query($sql) or die(sql_error($sql));
      for ($i=0;$i<db_num_rows($result);$i++){
         $row = db_fetch_assoc($result);
         $ret.=appoencode(templatereplace("statrow",array("title"=>"$row[name]","value"=>" ")),true);
         $onlinecount++;
      }
      $ret.=appoencode(templatereplace("statend"),true);
      db_free_result($result);
      if ($onlinecount==0) $ret.=appoencode("`iNone`i");
      return $ret;
   }
}

also in common.php, find this section in the page_footer() function:
Code:
  $footer=str_replace("{stats}",charstats(),$footer);
   $header=str_replace("{stats}",charstats(),$header);
add the following right after
Code:
  $footer=str_replace("{onlinechars}",onlinechars(),$footer);
   $header=str_replace("{onlinechars}",onlinechars(),$header);

In your template file (probably templates/yarbrough.htm), find this line
Code:
       <tr>
          <td> {stats} </td>
        </tr>
add this right after that
Code:
       <tr>
          <td> {onlinechars} </td>
        </tr>

It's a bit of work but it may be more asthetically pleasing for you.

edit: added in check for loggedin so the list wouldn't appear twice on the login page
« Last Edit: May 10, 2004, 07:40:58 PM by Artte » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
40 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search