Finding info about players

22 views
Skip to first unread message

Zagor

unread,
Feb 14, 2021, 5:14:47 PM2/14/21
to Evennia
Hi these are probably two dumb questions, but I would like to know how many players are connected (and who) in real time. Is it possible somehow?

Moreover, as Admin I would like to find the exact location (room id) in which a player is.
For example if I use the command search I get the player id but not its own location.

Is there a way to get that?

Thx!

Zude Onim

unread,
Feb 14, 2021, 11:44:42 PM2/14/21
to eve...@googlegroups.com
The command 'who' will list who is online (and maybe their location,
can't remember).

Also :

Give yourself (the superuser #1) an alias.
( alias me = fartpants )
The code I am giving you below assumes that I (the superuser) have the
alias "fartpants".
I use MUSHclient 99% of the time, but copy/pasting this into the
webclient should work, too.

What the code is doing is :
- starting a python snippet
- importing the 'search_object' code
- searching for "fartpants"
- searching for "character" objects
- finding the object (character) name, location and strength (you
could replace obj.db.strength with any other db attribute on the
character object. 'strength' is just used here as an example)
- return a message to "fartpants" (the superuser) with the above info
regarding each "character"

I hope that makes sense.
If you need help, just ask.
Try messing around with this code, too, to return different info about
different objects, etc, etc.

Copy / Paste it straight into MUSHclient.
All the lines. Hit ENTER. Win !

@py/edit
from evennia.utils.search import search_object
for fartpants in search_object("fartpants"):
for obj in search_object("character"):
string = ("\n%s |r: |n%s |r: |n%s" % (obj, obj.location,
obj.db.strength))
fartpants.msg(string)
:!
:q!
> --
> You received this message because you are subscribed to the Google Groups
> "Evennia" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to evennia+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/evennia/533cbe73-8136-491f-9c96-8db49a0f0041n%40googlegroups.com.
>

Zude Onim

unread,
Feb 14, 2021, 11:45:28 PM2/14/21
to eve...@googlegroups.com
Due to shitty email formatting the line :

string = ("\n%s |r: |n%s |r: |n%s" % (obj, obj.location,
obj.db.strength))

should be :

string = ("\n%s |r: |n%s |r: |n%s" % (obj, obj.location, obj.db.strength))




Griatch Art

unread,
Feb 15, 2021, 3:28:07 AM2/15/21
to Evennia
As mentioned, the `who` command gives this info. To

As a database query: 

    from evennia import AccountDB
    number_of_connected = AccountDB.objects.filter(is_connected=True).count()

To find out the location of a character, `who` will tell you this if you are a builder or higher. Inside a command you can get this info with e.g.

     def func(self):
        matches = self.caller.search("Foo", global=True)
        if matches:
            location = matches[0].location

As a general search you can use

    from evennia import search_objects
    character_as_list = search_objects(typeclass="typeclasses.characters.Character", key="Foo")
    if character_as_list:
        location = character_as_list[0].location
Reply all
Reply to author
Forward
0 new messages