DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • October 27, 2016, 09:42:46 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Resource Pages
IRC Channels

Pages: [1]   Go Down
Author Topic: Pulling who's online in LotGD  (Read 3215 times)
0 Members and 1 Guest are viewing this topic.
« on: March 27, 2006, 03:15:17 PM »

I run a forum (no way!) and was wondering is there a way to pull the info for who is online in the game and put it in php?

I use Tiny Portal and they have a blocks function that allows for a variety of code types...so here is what I am picturing and want to know if it is possible:

Block would display - There are x Adventurers Searching for the Green Dragon <---wold be the link to the game
beneath that would list the users online at the moment (scrollable or maybe limit the number it shows)

Maybe the code from the log in page where it shows the users in the realm and the names.  Is this possible?

Thanks in advance for an awesome game! 
« Reply #1 on: March 27, 2006, 08:19:54 PM »

You will need to play around with this and edit it to your liking, but this should work.


$sql = "SELECT name FROM accounts where loggedin=1 ORDER BY name;";
$RS = mysql_query($sql);
$num_rows = mysql_num_rows($RS);
for($x = 0; $x < $num_rows; $x++) {
   echo mysql_result($RS, $x, "name")."\n";

« Reply #2 on: March 27, 2006, 08:29:52 PM »

that's great, but how do i get the reference to LotGD in that code?

here is the link to my forum so you can see what I am talking about


you can use my test account to see everything name/pass=test/test

the small blocks on the right are where I want to put it...the link to the game is at the top labeled LotGD
Global Moderator
Mod God
Offline Offline

Posts: 4647

Be aware of the squirrel!

View Profile WWW
« Reply #3 on: March 27, 2006, 08:43:28 PM »

First: The code above will not give you the correct names of the players online - in two ways.
a) The names may contain color codes, which your forum software surely will ignore.
b) It will also give you the players which timed out and are still offline. (So you might actually have 10 players online, but this code will return 100 players.)

It's best you copy the code from "lib/pageparts.php" (somewhere around line 660 to 680) and adapt it to your forum's code.

Running for more than three years now:
« Reply #4 on: March 30, 2006, 07:40:33 AM »

Okay...here's what I have so far:

// If a module wants to do it's own display of the online chars,
// let it.
$list modulehook("onlinecharlist", array());
if ($list['handled']) {
$onlinecount $list['count'];
$ret $list['list'];
} else {
mysql_connect("localhost""username""password") or die(mysql_error());
mysql_select_db("technodrag_logd") or die(mysql_error());
$sql="SELECT name,alive,location,sex,level,laston,loggedin,lastip,uniqueid FROM logd_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";
$result db_query($sql);
$count db_num_rows($result);
$ret.=appoencode(sprintf(translate_inline("`bOnline Characters (%s players):`b`n"),$count));
for ($i=0;$i<$count;$i++){
$row db_fetch_assoc($result);
if ($onlinecount==0)

But now I get an error:
Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/logd.technodragon.net/lib/dbwrapper.php on line 19

Warning: mysql_query(): A link to the server could not be established in /home/www/logd.technodragon.net/lib/dbwrapper.php on line 19

SELECT * FROM settings

Call Stack:
1: db_query("SELECT * FROM settings") called from /home/www/logd.technodragon.net/lib/dbwrapper.php on line 64
2: db_query_cached("SELECT * FROM settings", "game-settings") called from /home/www/logd.technodragon.net/lib/settings.php on line 38
3: loadsettings() called from /home/www/logd.technodragon.net/lib/settings.php on line 55
4: getsetting("usedatacache", 0) called from /home/www/logd.technodragon.net/lib/datacache.php on line 21
5: datacache("hook-onlinecharlist", 60) called from /home/www/logd.technodragon.net/lib/dbwrapper.php on line 58
6: db_query_cached("SELECT module_hooks....", "hook-onlinecharlist") called from /home/www/logd.technodragon.net/lib/modules.php on line 458
7: modulehook("onlinecharlist", Array()) called from /home/www/logd.technodragon.net/testing.php on line 9

I am not real good with this tuff...any ideas what I am doing wrong?
Global Moderator
Mod God
Offline Offline

Posts: 4647

Be aware of the squirrel!

View Profile WWW
« Reply #5 on: March 30, 2006, 08:25:03 AM »

Your code show this one line:
mysql_connect("localhost", "username", "password") or die(mysql_error());

It should show your correct username and password for your database. If not, the program cannot connect to the server (that's what the error message is saying...)

You also don't need these lines:

   // If a module wants to do it's own display of the online chars,
// let it.
$list = modulehook("onlinecharlist", array());
if ($list['handled']) {
$onlinecount = $list['count'];
$ret = $list['list'];
} else {
and the trailing } at the end of your file...

Running for more than three years now:
« Reply #6 on: March 30, 2006, 08:54:04 AM »

i deliberately left out my info for the post....

Argh!  this is frustrating...cut out that info...still not working.

Look, is there anyway to just show the users online in like a table or something apart from the main page?  Like creating a seperate PHP file that, when run, jsut dislplays the Users Currently online?
« Reply #7 on: March 30, 2006, 10:46:36 AM »

Just a note as to what I use...

Do you have the ability to show RSS feeds on your forum? If so, you can use the online rss feed.  Wink
« Reply #8 on: March 30, 2006, 11:23:17 AM »

Yes I do have RSS available...where is that feed at?

Never mind...did a search...Boy, would have saved me a WHOLE lot of headache had I known that it had an RSS feed all this time!  ROFL
« Last Edit: March 30, 2006, 11:36:57 AM by technodragon73 » Logged
Pages: [1]   Go Up
Jump to:  

DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

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