//Child of int atcommand_accountinfo void account_info(const int fd, struct map_session_data *sd, int account_id) { char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30]; short level = -1; char *data; int logincount = 0,state = 0; if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `level`, `lastlogin`, `logincount`, `state` FROM `login` WHERE `account_id` = '%d'", account_id) ) clif_displaymessage(fd, "[Driver Error] : Query Error. (connection seems crappy :/) Tell the admin."); else if ( Sql_NumRows(mmysql_handle) == 0 ) clif_displaymessage(fd, "Account Not Found"); else { Sql_NextRow(mmysql_handle); Sql_GetData(mmysql_handle, 0, &data, NULL); safestrncpy(userid, data, sizeof(userid)); Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(user_pass, data, sizeof(user_pass)); Sql_GetData(mmysql_handle, 2, &data, NULL); safestrncpy(email, data, sizeof(email)); Sql_GetData(mmysql_handle, 3, &data, NULL); safestrncpy(last_ip, data, sizeof(last_ip)); Sql_GetData(mmysql_handle, 4, &data, NULL); level = atoi(data); Sql_GetData(mmysql_handle, 5, &data, NULL); safestrncpy(lastlogin, data, sizeof(lastlogin)); Sql_GetData(mmysql_handle, 6, &data, NULL); logincount = atoi(data); Sql_GetData(mmysql_handle, 7, &data, NULL); state = atoi(data); } Sql_FreeResult(mmysql_handle); if (level == -1) return; sprintf(atcmd_output, "-- Account %d --", account_id); clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, "User: %s | GM Level: %d | State: %d", userid, level, state); clif_displaymessage(fd, atcmd_output); if (pc_isGM(sd) >= 98) { sprintf(atcmd_output, "Password: %s.", user_pass); clif_displaymessage(fd, atcmd_output); } sprintf(atcmd_output, "Account e-mail: %s.", email); clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, "Last IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip))); clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, "This user has logged %d times, the last time were at %s.", logincount, lastlogin); clif_displaymessage(fd, atcmd_output); clif_displaymessage(fd, "-- Character Details --"); if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `char` WHERE `account_id` = '%d' ORDER BY `char_num`", account_id) ) clif_displaymessage(fd, "Character Query Error. Show it to the Admin."); else if ( Sql_NumRows(mmysql_handle) == 0 ) clif_displaymessage(fd, "This account doesnt have characters."); else { while ( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) { int char_id, class_; short char_num, base_level, job_level, online; char name[NAME_LENGTH]; Sql_GetData(mmysql_handle, 0, &data, NULL); char_id = atoi(data); Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name)); Sql_GetData(mmysql_handle, 2, &data, NULL); char_num = atoi(data); Sql_GetData(mmysql_handle, 3, &data, NULL); class_ = atoi(data); Sql_GetData(mmysql_handle, 4, &data, NULL); base_level = atoi(data); Sql_GetData(mmysql_handle, 5, &data, NULL); job_level = atoi(data); Sql_GetData(mmysql_handle, 6, &data, NULL); online = atoi(data); sprintf(atcmd_output, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off"); clif_displaymessage(fd, atcmd_output); } } Sql_FreeResult(mmysql_handle); return; } //Syntax: / //Result: If using account id and id exists return information about user account, if using char name and more than one result found lists all found results. int atcommand_accountinfo(const int fd, struct map_session_data* sd, const char* command, const char* message) { int account_id = 0; char *data; nullpo_retr(-1, sd); if (!message || !*message || strlen(message)>NAME_LENGTH ) { clif_displaymessage(fd, "(usage: @accinfo/@accountinfo )."); return -1; } account_id = atoi(message); if (account_id < START_ACCOUNT_NUM) { if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `char` WHERE `name` like '%s' limit 10", message) ) { clif_displaymessage(fd, "Query Error on accountinfo function."); Sql_FreeResult(mmysql_handle); return -1; } else if ( Sql_NumRows(mmysql_handle) == 0 ) { clif_displaymessage(fd, "Invalid Account ID/Char Name"); Sql_FreeResult(mmysql_handle); return -1; } else { if (Sql_NumRows(mmysql_handle) == 1) { Sql_NextRow(mmysql_handle); Sql_GetData(mmysql_handle, 0, &data, NULL); account_id = atoi(data); Sql_FreeResult(mmysql_handle); } else { sprintf(atcmd_output, "Your Query Returned the following %d results, please be more specific...", (int)Sql_NumRows(mmysql_handle)); clif_displaymessage(fd, atcmd_output); while ( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) { int class_; short base_level, job_level, online; char name[NAME_LENGTH]; Sql_GetData(mmysql_handle, 0, &data, NULL); account_id = atoi(data); Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name)); Sql_GetData(mmysql_handle, 2, &data, NULL); class_ = atoi(data); Sql_GetData(mmysql_handle, 3, &data, NULL); base_level = atoi(data); Sql_GetData(mmysql_handle, 4, &data, NULL); job_level = atoi(data); Sql_GetData(mmysql_handle, 5, &data, NULL); online = atoi(data); sprintf(atcmd_output, "[ACID: %d] %s | %s | Level: %d/%d | %s", account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline"); clif_displaymessage(fd, atcmd_output); } Sql_FreeResult(mmysql_handle); return -1; } } } account_info(fd, sd, account_id); return 0; }