Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → modification /finger

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 4

1 (edited by Jimmy_Aquarius 23.12.2012 11:54)

Topic: modification /finger

when i /finger jimmy_aquarius
ID: Jimmy_Aquarius
Location: DotA
Age: Unlimited

how to add "job", like this
ID: Jimmy_Aquarius
Location: DotA
Age: Unlimited
Job: Owner

so, if someone use /finger jimmy_aquarius, it will show like this
ID: Jimmy_Aquarius
Location: DotA
Age: Unlimited
Job: Owner

but, if someone use /finger user, it will show like this
ID: User
Location:
Age:
Job: User


Understand ?

my source code

static int _handle_finger_command(t_connection * c, char const *text)
{
  char           dest[USER_NAME_MAX];
  unsigned int   i,j;
  t_account *    account;
  t_connection * conn;
  char const *   ip;
  char *         tok;
  t_clanmember * clanmemb;

  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */
  for (; text[i]==' '; i++);
  for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get dest */
    if (j<sizeof(dest)-1) dest[j++] = text[i];
  dest[j] = '\0';
  for (; text[i]==' '; i++);

  if (dest[0]=='\0')
  {
    message_send_text(c,message_type_info,c,"usage: /finger <account>");
    return 0;
  }

  if (!(account = accountlist_find_account(dest)))
    {
      message_send_text(c,message_type_error,c,"Invalid user.");
      return 0;
    }
  snprintf(msgtemp, sizeof(msgtemp), "Login: %-16.16s "UID_FORMAT" Sex: %.14s",
      account_get_name(account),
      account_get_uid(account),
      account_get_sex(account));
  message_send_text(c,message_type_info,c,msgtemp);

  if ((clanmemb = account_get_clanmember(account)))
  {
    t_clan *     clan;
    char     status;

    if ((clan = clanmember_get_clan(clanmemb)))
    {
    snprintf(msgtemp, sizeof(msgtemp), "Clan : %-64.64s",clan_get_name(clan));
    if ((status = clanmember_get_status(clanmemb)))
    {
        switch (status)
        {
        case CLAN_CHIEFTAIN:
           strcat(msgtemp,"  Rank: Chieftain");
           break;
        case CLAN_SHAMAN:
           strcat(msgtemp,"  Rank: Shaman");
           break;
        case CLAN_GRUNT:
           strcat(msgtemp,"  Rank: Grunt");
           break;
        case CLAN_PEON:
           strcat(msgtemp,"  Rank: Peon");
           break;
        default:;
        }
    }
    message_send_text(c,message_type_info,c,msgtemp);

    }
  }

  snprintf(msgtemp, sizeof(msgtemp), "Location: %-23.23s Age: %.14s",
      account_get_loc(account),
      account_get_age(account));
  message_send_text(c,message_type_info,c,msgtemp);

  if((conn = connlist_find_connection_by_accountname(dest)))
  {
      snprintf(msgtemp, sizeof(msgtemp), "Client: %s    Ver: %s   Country: %s",
          clienttag_get_title(conn_get_clienttag(conn)),
          conn_get_clientver(conn),
          conn_get_country(conn));
      message_send_text(c,message_type_info,c,msgtemp);
  }

  if (!(ip=account_get_ll_ip(account)) ||
      !(account_get_command_groups(conn_get_account(c)) & command_get_group("/admin-addr"))) /* default to false */
    ip = "unknown";

  {
    time_t      then;
    struct tm * tmthen;

    then = account_get_ll_time(account);
    tmthen = localtime(&then); /* FIXME: determine user's timezone */
    if (!(conn))
      if (tmthen)
    strftime(msgtemp,sizeof(msgtemp),"Last login %a %b %d %H:%M %Y from ",tmthen);
      else
    strcpy(msgtemp,"Last login ? from ");
    else
      if (tmthen)
    strftime(msgtemp,sizeof(msgtemp),"On since %a %b %d %H:%M %Y from ",tmthen);
      else
    strcpy(msgtemp,"On since ? from ");
  }
  strncat(msgtemp,ip,32);
  message_send_text(c,message_type_info,c,msgtemp);

  /* check /admin-addr for admin privileges */
  if ( (account_get_command_groups(conn_get_account(c)) & command_get_group("/admin-addr")))
  {
      /* the player who requested /finger has admin privileges
         give him more info about the one he querys;
         is_admin, is_operator, is_locked, email */
         snprintf(msgtemp, sizeof(msgtemp), "email:%.128s , is_operator: %d , is_admin: %d , is_acc_locked: %d",
         account_get_email(account),
         account_get_auth_operator(account,NULL),
         account_get_auth_admin(account,NULL),
         account_get_auth_lock(account));
         message_send_text(c,message_type_info,c,msgtemp);
  }


  if (conn)
    {
      snprintf(msgtemp, sizeof(msgtemp), "Idle %.128s",seconds_to_timestr(conn_get_idletime(conn)));
      message_send_text(c,message_type_info,c,msgtemp);
    }

  strncpy(msgtemp,account_get_desc(account),sizeof(msgtemp));
  msgtemp[sizeof(msgtemp)-1] = '\0';
  for (tok=strtok(msgtemp,"\r\n"); tok; tok=strtok(NULL,"\r\n"))
    message_send_text(c,message_type_info,c,tok);
  message_send_text(c,message_type_info,c,"");

  return 0;
}

thanks~

2

Re: modification /finger

// compare account lower name with "jimmy_aquarius"
if ( strcmp(tolower(account_get_name(account)), "jimmy_aquarius" ) == 0)
    strcat(msgtemp, "Job: Owner" );

Do not ask for support in PM.

3

Re: modification /finger

HarpyWar wrote:

// compare account lower name with "jimmy_aquarius"
if ( strcmp(tolower(account_get_name(account)), "jimmy_aquarius" ) == 0)
    strcat(msgtemp, "Job: Owner" );

how to add to another person ?
if i want add harpywar to Developer
how to set from battle net ?

but

// compare account lower name with "jimmy_aquarius"
if ( [url=http://www.cplusplus.com/reference/cstring/strcmp/]strcmp[/url](tolower(account_get_name(account)), "jimmy_aquarius" ) == 0) 
    strcat(msgtemp, "Job: Owner" );[

where to put ?
below /finger ?

4

Re: modification /finger

yes

Posts: 4

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 0 guests, 0 registered users

forums.pvpgn.pro → [EN] The Source Code → modification /finger