Jump to content

@accinfo command


KaitoKid

Recommended Posts


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  268
  • Reputation:   27
  • Joined:  12/06/11
  • Last Seen:  

Hey guys, I found this very useful and must have command for GMs created by Ind here

I tried applying from my rAthena and I got errors due to the obsolete codes used to apply the commands and also due to the new code structure for character commands.

Therefore I have adjusted the codes given by Ind from his post and done some minor changes to make it compatible with the latest SVN for rAthena. :)

Go to your socket.c and find this line

#include <sys/types.h>

then add this below:

#include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool]

Still on socket.c, find this line


void set_defaultparse(ParseFunc defaultparse)
{
default_func_parse = defaultparse;
}

Add this below:

/**
* [Dekamaster/Ultimate GM Tool]
**/
const char * geoip_countryname[253] = {"Unknown","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles",
"Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
"Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
"Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
"Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
"Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
"Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
"Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
"Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
"Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
"Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
"Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
"Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
"Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
"Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
"Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
"Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
"Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
"Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
"Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
"Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
"Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
"Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
"Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
"Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
"Saint Barthelemy","Saint Martin"};
unsigned char *geoip_cache;
int geoip_cacheready = 0;
void geoip_readdb(void){
struct stat bufa;
FILE *db=fopen("./db/GeoIP.dat","r");
fstat(fileno(db), &bufa);
geoip_cache = (unsigned char *) malloc(sizeof(unsigned char) * bufa.st_size);
fread(geoip_cache, sizeof(unsigned char), bufa.st_size, db);
fclose(db);
geoip_cacheready=1;
ShowStatus("Finished Reading "CL_GREEN"GeoIP"CL_RESET" Database.n");
}
const char* geoip_getcountry(uint32 ipnum){
int depth;
unsigned int x;
unsigned char stack_buffer[6];
const unsigned char *buf = stack_buffer;
unsigned int offset = 0;

if (!geoip_cacheready) geoip_readdb();

for (depth = 31; depth >= 0; depth--) {
 buf = geoip_cache + (long)6 *offset;
 if (ipnum & (1 << depth)) {
  /* Take the right-hand branch */
  x =   (buf[3*1 + 0] << (0*8))
  + (buf[3*1 + 1] << (1*8))
  + (buf[3*1 + 2] << (2*8));
 } else {
  /* Take the left-hand branch */
  x =   (buf[3*0 + 0] << (0*8))
  + (buf[3*0 + 1] << (1*8))
  + (buf[3*0 + 2] << (2*8));
 }

 if (x >= 16776960) {
  x=x-16776960;
  return geoip_countryname[x];
 }
 offset = x;
}
return geoip_countryname[0];
}

then go to socket.h and find this:

void send_shortlist_do_sends();
#endif

Add the code below:

/**
* [Dekamaster/Ultimate GM Tool]
**/
const char* geoip_getcountry(uint32 ipnum);

Then go to your atcommand.c

Find this line

ACMD_DEF2("newmount", new_mount),

And add the code below:

ACMD_DEF(accinfo),

Still at the atcommand.c, find:

ACMD_FUNC(mapmove)

then add this code before ACMD_FUNC(mapmove)

/**
* [ind/Dekamaster/Zephyrus/Ultimate GM Tool]
**/
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 group_id = -1;
char *data;
int logincount = 0,state = 0;

if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `group_id`, `lastlogin`, `logincount`, `state` FROM `login` WHERE `account_id` = '%d'", account_id) )
 clif_displaymessage(fd, "[Driver Error] : Query Error. (connection seems crappy :/) Show it to 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); group_id = 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 (group_id == -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, group_id, state);
clif_displaymessage(fd, atcmd_output);
if (group_id < pc_get_group_level(sd)) {
 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;
}
ACMD_FUNC(accinfo) {
int account_id = 0;
char *data;

nullpo_retr(-1, sd);

if (!message || !*message || strlen(message) > NAME_LENGTH ) {
 clif_displaymessage(fd, "(usage: @accinfo/@accountinfo <account_id/char name>).");
 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 @accinfo.");
  Sql_FreeResult(mmysql_handle);
  return -1;
 } else if ( Sql_NumRows(mmysql_handle) == 0 ) {
  clif_displaymessage(fd, "Invalid Account ID or Character 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;
}

Don't forget the GeoIP.dat that was provided by Ind to put it inside your db folder. :)

Sorry for the long post. I don't know how to create a diff file :D

I hope this would be helpful :)

Edited by Kaito_Kid
  • Upvote 1
Link to comment
Share on other sites

  • 3 weeks later...

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  90
  • Reputation:   2
  • Joined:  11/14/11
  • Last Seen:  

Posted · Hidden by FrustFenix, April 19, 2012 - please
Hidden by FrustFenix, April 19, 2012 - please

tested and working..

thank you for these code..

:D

Link to comment
  • 3 months later...

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   2
  • Joined:  03/23/12
  • Last Seen:  

"Don't forget the GeoIP.dat that was provided by Ind to put it inside your db folder. "

which db folder ?

cant you upload the GeoIP.dat ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  81
  • Reputation:   14
  • Joined:  08/17/12
  • Last Seen:  

here's some diff patch for you

nice script

accinfo.patch

Edited by Equinox
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

i dont think we need the diff file because rAthena already got it implanted long ago ..... ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  81
  • Reputation:   14
  • Joined:  08/17/12
  • Last Seen:  

i dont think we need the diff file because rAthena already got it implanted long ago ..... ?

i'm just helping ?

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...