this is my code in /finger
static int _handle_finger_command(t_connection * c, char const *text)
{
char dest[MAX_USERNAME_LEN];
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,"Gunakan: /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), "ID: %-16.16s "UID_FORMAT"",
account_get_name(account),
account_get_uid(account));
message_send_text(c,message_type_info,c,msgtemp);
snprintf(msgtemp, sizeof(msgtemp), "Jenis Kelamin: %.14s",
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:
std::strcat(msgtemp," Rank: Chieftain");
break;
case CLAN_SHAMAN:
std::strcat(msgtemp," Rank: Shaman");
break;
case CLAN_GRUNT:
std::strcat(msgtemp," Rank: Grunt");
break;
case CLAN_PEON:
std::strcat(msgtemp," Rank: Peon");
break;
default:;
}
}
message_send_text(c,message_type_info,c,msgtemp);
}
}
snprintf(msgtemp, sizeof(msgtemp), "Lokasi: %-23.23s",
account_get_loc(account));
message_send_text(c,message_type_info,c,msgtemp);
snprintf(msgtemp, sizeof(msgtemp), "Umur: %.14s",
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 Version: %s",
clienttag_get_title(conn_get_clienttag(conn)),
conn_get_clientver(conn));
message_send_text(c,message_type_info,c,msgtemp);
snprintf(msgtemp, sizeof(msgtemp), "Negara: %s",
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";
{
std::time_t then;
struct std::tm * tmthen;
then = account_get_ll_time(account);
tmthen = std::localtime(&then); /* FIXME: determine user's timezone */
if (!(conn))
if (tmthen)
std::strftime(msgtemp,sizeof(msgtemp),"Terakhir login pada %a %b %d %H:%M %Y from ",tmthen);
else
std::strcpy(msgtemp,"Terakhir login ? pada ");
else
if (tmthen)
std::strftime(msgtemp,sizeof(msgtemp),"Terakhir terlihat pada %a %b %d %H:%M %Y dari ",tmthen);
else
std::strcpy(msgtemp,"Terakhir terlihat ? pada ");
}
std::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);
}
std::strncpy(msgtemp,account_get_desc(account),sizeof(msgtemp));
msgtemp[sizeof(msgtemp)-1] = '\0';
for (tok=std::strtok(msgtemp,"\r\n"); tok; tok=std::strtok(NULL,"\r\n"))
message_send_text(c,message_type_info,c,tok);
message_send_text(c,message_type_info,c,"");
return 0;
}
please show me how to add grade class and current password