Warning: preg_replace_callback(): Requires argument 2, '$func['entity_fix']('\2')', to be a valid callback in /nfs/c01/h06/mnt/10927/domains/dragonprime.net/html/Sources/Load.php(225) : runtime-created function on line 3

Warning: preg_replace_callback(): Requires argument 2, '$func['entity_fix']('\2')', to be a valid callback in /nfs/c01/h06/mnt/10927/domains/dragonprime.net/html/Sources/Load.php(225) : runtime-created function on line 3
Print Page - Show Users.

DragonPrime - LoGD Resource Community

Coding Support => Coding Support Desk => Topic started by: Freeze on July 08, 2005, 02:12:41 PM



Title: Show Users.
Post by: Freeze on July 08, 2005, 02:12:41 PM
I have a 'village' that i've created [i've mentioned it elsewhere here].

And i've ran into a few problems, but with the help of others, i've managed to get everything working right.

But now i've another question for the technically advanced people. I would like to know what code to add to an area to make it show who is there. I know its basically the same as whe whoshere module, but as it doesn't work for places that arent listed, it does not cover this place. and i couldn't work out what code to 'copy/paste' from that module and put it in this place.

So plainly, does anyone know the code to show what users are in an area?


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 02:23:53 PM
If your area changes the user's location, it is easy.

Code:
$mycity = get_module_setting("villagename","citymodule");
$sql = "SELECT name FROM ".db_prefix("accounts")." WHERE alive=1 AND location='$mycity'";
Then build it into a table.


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 02:25:36 PM
if the city is a real city (own location) it shouldn't be the Problem
Code:
SELECT name FROM ".db_prefix("accounts")." WHERE location = "$mycity" AND alive = 1)

for performance reasons ( if you are running a server with more than 50 users online at the same time)

-> just forget it

else : have fun


if you only want the users that are logged on you should also ad an

Code:
AND lasthit < time() - 500
(i don't remember the getsetting for that time ...


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 02:43:51 PM
An "Area" (an House or something) is also possible.

If you an user enters it set an modulepref to 1 , if he leaves set it  0 or blank again.

To show the people run :

Code:
SELECT name from accounts where acctid IN (SELECT userid FROM module_userprefs WHERE section = $yourmodulename AND setting = $yourprefname AND value = 1)

if the user could die in the area add an "AND alive=1" and set the pref 0 or blank at newday's.

(with logged on users same as above)

*note that the query is kinda deadly to big servers*


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 02:52:36 PM
Edorian, you are carrying it out kinda far...

As well, if you wanted loggedin players, just:
Code:
AND loggedin=1


Title: Re:Show Users.
Post by: Freeze on July 08, 2005, 02:54:14 PM
It doesn't changed the player's location. Dont even know how to do that.


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 02:55:27 PM
I'm sry...

It's just that we have over 2000 differnt users every day on .. serverall hours the server is full... (200 is limit)

my first thougt always is "performance"


loggedin is not set to zero if the user has a timeout (or am i wrong ? :) )


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 02:56:50 PM
loggedin is not set to zero if the user has a timeout (or am i wrong ? :) )

Yes, it is. :)


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 03:00:12 PM
It doesn't changed the player's location. Dont even know how to do that.

Okay, then you are gonna wanna go with a pref system.

When a user enters the area:
Code:
set_module_pref("here",1);
Then, you can check to see:
Code:
//in the dohook
case "footer-runmodule":
$module = httpget('module');
if ($module != "filename" || $module == NULL) set_module_pref("here",0,"filename");
break;

Then, you would run an SQL query, to build the table:
Code:
$sql = "SELECT name FROM ".db_prefix("accounts")." INNER JOIN ".db_prefix("module_userprefs")." ON acctid=userid WHERE setting='here' AND modulename='filename' AND value=1";


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 03:01:41 PM
 :o

ok.. it's not my job to know .. i'm sry...
somewhat freaky...

that but if you show me where that is done i would thank you.

btw. excuse my bad english


just a note Sichae. As i don't know how big Anakin server is.

That code will consume a lot of runtime and it's an extra hook in the runmodule footer.. so you should at least split the files if you really run it.


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 03:05:18 PM
192, of common.php
Code:
if (!isset($session['user']['loggedin'])) $session['user']['loggedin']=false;

Meaning, if the cookie does not exist, or the session is not open (same thing) the session is ended.


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 03:09:43 PM
Edorian, the server consumption by a single query would not bog a server down the slightest... if only a little .3 seconds slow querying.

As well, I have several modules that do the same thing, even hooks at everyhit, and it still runs smoothly.


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 03:10:13 PM
192, of common.php
Code:
if (!isset($session['user']['loggedin'])) $session['user']['loggedin']=false;

Meaning, if the cookie does not exist, or the session is not open (same thing) the session is ended.
... that's not what i meant.

if the user has a timeout and doesn't hit the one of the pages again

(just closes browser and leaves)

and you don't what to display that users


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 03:11:45 PM
Edorian, the script runs a cleanup of the timedout players. If it didn't, then a user would stay logged in all the time, and would be invinvible to PvP.

As well, we should take this out of the forum, before it heads out any longer.


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 03:20:17 PM
Your right.

To geht back to Topic
Code:
SELECT name FROM accounts INNER JOIN module_userprefs ON acctid=userid WHERE setting='bought' AND modulename='abigail' AND value=0
7653 rows in set (Query took : 1.09 sec)

In my Opinion that is way to much runtime (and it's midnight here)


the footer-runmodule isn't the problem it's self but if the file is large u don't need to parse the whole file

just get the _run() part in an extra file and require it..


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 03:22:52 PM
Heh, that is your opinion.

As well, there are only about... 3 servers in the entire world that a massive amount of querying results would be returned.

For now, that is one of the only ways to do it. And if he really wants it that badly, then that is one of the only options.

If performance is always an issue, then it is going to impede many of your executive decisions.


Title: Re:Show Users.
Post by: edorian on July 08, 2005, 03:28:02 PM
and i am lucky to administrate one of that three..

but i get your point : "It just doesn't care" ..

i got to deal with that every day... but i got the point and keep my mouth shut.


Title: Re:Show Users.
Post by: Sichae on July 08, 2005, 03:29:14 PM
It is not that, it is just the fact that there are so few options that he can take, and all of them would warrant some kind of server runtime slowing.

The one that was provided, warrants the lowest runtime slowing, that is why I suggested it.


Title: Re:Show Users.
Post by: XChrisX on July 10, 2005, 11:16:24 AM
Edorian, the script runs a cleanup of the timedout players. If it didn't, then a user would stay logged in all the time, and would be invinvible to PvP.

As well, we should take this out of the forum, before it heads out any longer.

Where does it do this!? Sichae, pvplist.php has an extra check against the timeout-setting... If you tell me this isn't necessary... Well WHY would JT and eric leave it in the core, if it's obsolete?!


Title: Re:Show Users.
Post by: Sichae on July 10, 2005, 05:33:55 PM
...never said it wasn't necessary... ::)

As well, it doesn't really matter about the other subjects stated in this thread. If you wish to know where loggedin players are booted, then ask JT or Eric. This thread was just to help a fellow person, and that has been done.

Now, I am quite sure that Talisman does not wish for this thread to go on anymore, as the information already provided in it are enough, and any more is extraneous.

© 2019 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines