DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • February 20, 2019, 02:36:11 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Simple online userlist...  (Read 4399 times)
0 Members and 1 Guest are viewing this topic.
ozental
Guest
« on: August 29, 2005, 02:08:56 PM »

Hey there. I'm looking to find a way of adding a simple listing of 'current users online' to my main forum's portal page. Obviously the v1.0.3 code has a list.php file which could be linked to, but it's contains far too much information. I'm just looking for the 'Online characters' portion as a list of usernames. Has anyone got some PHP and/or HTML code that will allow this?
Logged
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3598


short, sweet and to the point


View Profile
« Reply #1 on: August 29, 2005, 02:22:12 PM »

ye might take a look at this thread gardens roster by sichae, or this one   who is here by lonnyl.

both are modules used to show who is online in areas.
« Last Edit: August 29, 2005, 06:20:38 PM by Elessa » Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
Dannic
Guest
« Reply #2 on: August 29, 2005, 04:14:34 PM »

I think Ozental is probably looking for the RSS feed.  Or a mod based off of it.
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #3 on: August 29, 2005, 05:42:13 PM »

In that case, Lonny's module may be a better choice.

http://www.pqcomp.com/modules/mydownloads/visit.php?cid=3&lid=78

It is for Xoops specifically, but will carry the code that you will need for a portal.
« Last Edit: August 29, 2005, 05:42:43 PM by Sichae » Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

ozental
Guest
« Reply #4 on: August 30, 2005, 04:28:10 AM »

In that case, Lonny's module may be a better choice.

http://www.pqcomp.com/modules/mydownloads/visit.php?cid=3&lid=78

It is for Xoops specifically, but will carry the code that you will need for a portal.

This is much more what I was looking for ... but when I run the PHP file through my browser, I got:

Quote
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\htdocs\dragon\onlinecountxoop.php on line 24

Any ideas?

Also, I'd like this mod to display the usernames too, not just a count that I presume this php file code does.
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #5 on: August 30, 2005, 05:04:08 AM »

You can't just rename it and then run it... you have to take the code as a source or maybe a draft to do it on your own... Wink
Logged

Running for more than three years now:
ozental
Guest
« Reply #6 on: August 30, 2005, 05:23:50 AM »

Well you should be able to just run the PHP code (I think) but non-the-less, I put the iframe code into an HTML page and ran that, and get the same error. I guess it doesn't like something around line 24:

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Lonny Luberts">
<meta name="ProgId" content="Notepad">
<title>Lotgd Online Count</title>
</head>
<body bgcolor="#D6DFF7">
<?php
   
/*
   online count code by Lonny Luberts - Copyright 2005 - www.pqcomp.com
   download - http://www.pqcomp.com/modules/mydownloads/
   version - 1.0
   Xoops Block Code (editing yoursite to match your URL):
   <iframe marginwidth="0" marginheight="0" frameborder="0"
    scrolling="no" width="100%" height="18"
    src="http://www.yoursite.com/lotgd/onlinecountxoops.php"></iframe><br>
   */
   
include("dbconnect.php");
   
$dblink mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
   
mysql_select_db($DB_NAME,$dblink);
   
$sql="SELECT name FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-900 seconds"))."' ORDER BY level DESC";
   
$result mysql_query($sql);
   
$onlinecount mysql_num_rows($result);
   print(
"<center><font color=\"#0000FF\">".$onlinecount." players online.</font></center>");
?>

</body>
</html>
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #7 on: August 30, 2005, 06:28:16 AM »

Change line 23 to
Code:
$result = mysql_query ("SELECT * WHERE 1=1")
    or die ("Error: " . mysql_error());
Either we bothe cannot see the obvious or there's another error... maybe we can find out that way...
Logged

Running for more than three years now:
ozental
Guest
« Reply #8 on: August 30, 2005, 08:47:12 AM »

Actually I found the 'error'. The SQL statement was looking for the table "accounts" but I have a prefix to my table names "lotgd_accounts". Once changed, it worked fine:

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Lonny Luberts">
<meta name="ProgId" content="Notepad">
<title>Lotgd Online Count</title>
</head>
<body bgcolor="#D6DFF7">
<?php
/*
online count code by Lonny Luberts - Copyright 2005 - www.pqcomp.com
download - http://www.pqcomp.com/modules/mydownloads/
version - 1.0
Xoops Block Code (editing yoursite to match your URL):
<iframe marginwidth="0" marginheight="0" frameborder="0"
 scrolling="no" width="100%" height="18"
 src="http://www.yoursite.com/lotgd/onlinecountxoops.php"></iframe><br>
*/
include("dbconnect.php");
$dblink mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$dblink);
$sql="SELECT name FROM lotgd_accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-900 seconds"))."' ORDER BY level DESC";
$result mysql_query($sql);
$onlinecount mysql_num_rows($result);
print("<center><font color=\"#0000FF\">".$onlinecount." players online.</font></center>");
?>

</body>
</html>
Now what I need to do is to try and get a list of the usernames so the output appears something like:

Quote
5 players online - Tim, George, Simon, Peter, Paul

Any ideas how to do this?
« Last Edit: August 30, 2005, 08:48:19 AM by ozental » Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #9 on: August 30, 2005, 01:17:42 PM »

Change this:
Code:
$onlinecount = mysql_num_rows($result);
   print("<center><font color=\"#0000FF\">".$onlinecount." players online.</font></center>");
To:
Code:
$onlinecount = mysql_num_rows($result);
$names = "";
for ($i=0; $i<mysql_num_rows($result);$i++){
$row = mysql_fetch_assoc($result);
$names = sprintf("%s%s%s", $names, $names==""?"":"," ,$row['name']);
}
print("<center><font color=\"#0000FF\">".$onlinecount." players online: ".$names."</font></center>");

You might have to incorporate the color_sanitize function, to remove the `@ and all, but yeah.
« Last Edit: August 30, 2005, 01:18:15 PM by Sichae » Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

ozental
Guest
« Reply #10 on: August 30, 2005, 02:18:47 PM »

Ah, you're a star. It works!

I think I'll make this into a more formal mod and post the finished code here, for others to use.
Logged
Dannic
Guest
« Reply #11 on: August 30, 2005, 06:03:09 PM »

Its not really a mod per se.  What  you are doing is for your forum  not LoGD.

Don't think it really qualifies as a module.  You might want to get with Talisman before you post it in the module section.
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #12 on: August 30, 2005, 06:04:39 PM »

Lonny had done the same thing, with his Xoops module, which is not exactly for LotGD, but to display LotGD information, such as the RSS module.

I don't think Talisman would have much of a problem with it.
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5483



View Profile WWW
« Reply #13 on: August 30, 2005, 06:13:17 PM »

It's an accessory for the game; I don't really want to start yet another area for the few such accessories there are, so the completed modules section will be fine.
Logged

Play the latest beta version here on DragonPrime
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

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