LPMuds.net
September 03, 2010, 11:45:34 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: This is the forum page. For the main LPMuds page, visit http://lpmuds.net
 
   Home   SITE FAQ INTERMUD DOWNLOADS LINKS Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: who  (Read 790 times)
yeik
Acquaintance
*
Offline Offline

Posts: 16


View Profile
who
« on: June 05, 2007, 05:58:32 AM »

/* who.c

 Tacitus @ LPUniversity
 06-FEB-07
 Standard command

*/

/* Originally concieved on 08-APR-05; Rewritten 06-FEB-07 */

/* Last edited on Febuary 06th, 2007 by Tacitus@LPUniversity */
/* QA has never occured for this file */

#include <ansi.h>
#define R ""
#define Y ""
#define MUDNAME "WHAT a WHAcky Mud"

string renderTag(string rank);
object array sortRankIndex(object array ranks);

int main(string arg)
{
    int cslen, clen, sdif, uon, don;
    string output, output2, mudname, tstring;
    string ostr;

    if(arg && sscanf(arg, "@%s", mudname) == 1)
    {
        "/adm/daemons/chmodules/chdmod_i3.c"->send_packet(
          ({ "who-req", 5, mud_name(), this_player()->query_name(), mudname, 0 })
        );
        return 1;
    }


    output = "";
    output2 = "";
    sdif=0;
    foreach(string rank in sortRankIndex(RANK_D->getRanks()))
    {
        mixed array gir= sort_array(RANK_D->getInteractives(rank), -1);
        foreach(object user in gir)
        {
            if(user->query_name()!="login") {
                tstring=user->query_title();
                clen=strlen(tstring); tstring= "home/y/yeik/cstrip"->strip_colours(tstring); cslen=strlen(tstring);
sdif=clen-cslen;
                if(rank=="user") uon++;
                if(uon==1) output2 = sprintf("%YELLOW%*%RESET%%35'='s%-43'='s%YELLOW%*%RESET%\n", "", "Players");

                if(rank!="user") don++;
                if(don==1) output = sprintf("%YELLOW%*%RESET%%34'='s%-44'='s%YELLOW%*%RESET%\n", "", "Developers");


                ostr =  sprintf("%YELLOW%*%RESET% %s %-"+(50+sdif)+"s%RESET% %4s %s %5s %YELLOW%*%RESET% \n",
renderTag(rank)+"|",
                  capitalize(user->query_name())+" "+
                  user->query_title(),
                  (user->query_env("away") ? " (A)" :  (in_edit( user ) ? "(*)" : (in_input( user ) ? "(+)" : ""))),
                  "|", (((query_idle( user ) / 60) / 60) >=1 ? query_idle( user ) /60/60/24 >=1 ? query_idle(user)
/60/60/24/7 >=1 ?query_idle(user) /60/60/24/7 +"w" : query_idle( user ) /60/60/24 +"d"  :query_idle( user ) / 60/ 60 +"h"
: query_idle( user ) / 60 + "m"));
                if(rank=="user") output2 += ostr; else output+=ostr;
            }
        }
    }

    write("\n");
    clen=strlen(MUDNAME); cslen=strlen("/home/y/yeik/cstrip"->strip_colours(MUDNAME));
    sdif= clen-cslen;
    /*
        write(Y+"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"+HIR+"W"+NOR+"o"+HIR+"W"+HIG+"
Mud"+NOR+Y"-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"+R+"\n");
    */
    write(sprintf("%YELLOW%%37'*-'s%YELLOW%%-"+(42+sdif)+"'-*'s*%RESET% \n", "", MUDNAME));
    write(sprintf("%YELLOW%*%RESET%%-10s %s %-39s %16s %5s %YELLOW%*%RESET% \n" ,    "   Rank", " | ", "Name", "|",
"Idle"));
    /*
        write(Y+"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"+R+"\n");
    */
    write(output);
    write(output2);
    write(Y+"*"+R+"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"+Y+"*"+R+" \n");
    write(sprintf("%YELLOW%*%RESET% %25s %20s %20s %29s \n", "Total online: "+sizeof(users()), "Players : "+uon,
        "Developers: "+(sizeof(users())-uon), "*"));
    write(Y+"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"+R+" \n\n");
    return 1;
}

string renderTag(string rank)
{
    string tag;
    string tmp;

    tmp = RANK_D->queryRankProperty(rank, "short");

    tag = "[ " + tmp + " ]";
    tag = sprintf("%-11s", tag);
    tag = replace_string(tag, tmp, RANK_D->queryRankProperty(rank, "colour") + capitalize(tmp) + "");
    return tag;
}

object array sortRankIndex(object array ranks)
{
    object array returnValue = ({});
    int i = sizeof(ranks);

    while(i--) returnValue += ({ ranks });

    return returnValue;   
}

string help()
{
    return(HIW + " SYNTAX: " + NOR + "who [@<mud>]\n\n" +
      "This command will display all the users who are currently logged\n" +
      "into " + mud_name() + ". It also lets you know if they are currently\n" +
      "editing, in input, and/or idle. You may also find out who is on a mud\n" +
      "on the I3 network by using the 'who @<mud>' syntax\n");
}

Logged
Atomic
BFF
***
Offline Offline

Posts: 109


To infinity and beyond!


View Profile
« Reply #1 on: June 05, 2007, 10:19:44 AM »

Ok, what are you trying to say?
Logged

Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.
detah
BFF
***
Offline Offline

Posts: 159


Ruler of 2D


View Profile
« Reply #2 on: June 05, 2007, 02:59:04 PM »

Here's a couple of unwritten rules for courteous posting.

1)
This appears to be the work of Tacitus@LPUniversity.
I hope you got permission from him before posting this.
If you did, it is customary to state such before posting.
Moreover, even though it is clear in the header that this is Tacitus' code, you should add your own statement to that effect outside the code brackets to make sure it is clear to everyone that this is not your work.

I am not accusing you of plagarism. It is clear from the headers who wrote that code. But you should be careful that there is never the insinuation that you are claiming someone else's code. Your reputation is very important here.

2)
When posting a bit of code, a snippet or whole file, you should not rely on the code's comments or SetHelp to explain what the code does. It is customary to give a brief explanation of what the code does. And furthermore, the purpose of posting it. Are you asking for help understanding this code? Are you offering this code for public distribution (which you actually can't do because it is Tacitus' code)? And if you were trying to offer it for public use, it has been posted in the wrong forum. Are you commenting on the total leetness of Tacitus' code? In other words, don't just post the code. No one knows what you are trying to do here.

-Detah
Logged
yeik
Acquaintance
*
Offline Offline

Posts: 16


View Profile
« Reply #3 on: June 06, 2007, 02:34:15 PM »

my apologies to all, the code i posted is in fact from the LPUNI lib, but heavily modified by me,
I posted it as i was talking on intermud about reversing the order.
Everybody comes up in reverse alphabetical order, and i have since found an easier way to do it.
Ty all for your time.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!