charcommand.c 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <math.h>
  7. #include "../common/cbasetypes.h"
  8. #include "../common/socket.h"
  9. #include "../common/timer.h"
  10. #include "../common/nullpo.h"
  11. #include "../common/showmsg.h"
  12. #include "log.h"
  13. #include "clif.h"
  14. #include "chrif.h"
  15. #include "intif.h"
  16. #include "itemdb.h"
  17. #include "map.h"
  18. #include "pc.h"
  19. #include "status.h"
  20. #include "skill.h"
  21. #include "mob.h"
  22. #include "pet.h"
  23. #include "battle.h"
  24. #include "charcommand.h"
  25. #include "atcommand.h"
  26. char charcommand_symbol = '#';
  27. extern char *msg_table[1000]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  28. #define CCMD_FUNC(x) int charcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  29. CCMD_FUNC(jobchange);
  30. CCMD_FUNC(petrename);
  31. CCMD_FUNC(petfriendly);
  32. CCMD_FUNC(stats);
  33. CCMD_FUNC(option);
  34. CCMD_FUNC(save);
  35. CCMD_FUNC(stats_all);
  36. CCMD_FUNC(reset);
  37. CCMD_FUNC(spiritball);
  38. CCMD_FUNC(itemlist);
  39. CCMD_FUNC(effect);
  40. CCMD_FUNC(storagelist);
  41. CCMD_FUNC(item);
  42. CCMD_FUNC(warp);
  43. CCMD_FUNC(zeny);
  44. CCMD_FUNC(fakename);
  45. CCMD_FUNC(baselevel);
  46. CCMD_FUNC(joblevel);
  47. CCMD_FUNC(questskill);
  48. CCMD_FUNC(lostskill);
  49. CCMD_FUNC(skreset);
  50. CCMD_FUNC(streset);
  51. CCMD_FUNC(model);
  52. CCMD_FUNC(stpoint);
  53. CCMD_FUNC(skpoint);
  54. CCMD_FUNC(changesex);
  55. CCMD_FUNC(feelreset);
  56. CCMD_FUNC(help);
  57. /*==========================================
  58. *CharCommandInfo charcommand_info[]構造体の定義
  59. *------------------------------------------
  60. */
  61. // First char of commands is configured in charcommand_athena.conf. Leave # in this list for default value.
  62. // to set default level, read charcommand_athena.conf first please.
  63. static CharCommandInfo charcommand_info[] = {
  64. { CharCommandJobChange, "#job", 60, charcommand_jobchange },
  65. { CharCommandJobChange, "#jobchange", 60, charcommand_jobchange },
  66. { CharCommandPetRename, "#petrename", 50, charcommand_petrename },
  67. { CharCommandPetFriendly, "#petfriendly", 50, charcommand_petfriendly },
  68. { CharCommandStats, "#stats", 40, charcommand_stats },
  69. { CharCommandOption, "#option", 60, charcommand_option },
  70. { CharCommandReset, "#reset", 60, charcommand_reset },
  71. { CharCommandSave, "#save", 60, charcommand_save },
  72. { CharCommandStatsAll, "#statsall", 40, charcommand_stats_all },
  73. { CharCommandSpiritball, "#spiritball", 40, charcommand_spiritball },
  74. { CharCommandItemList, "#itemlist", 40, charcommand_itemlist },
  75. { CharCommandEffect, "#effect", 40, charcommand_effect },
  76. { CharCommandStorageList, "#storagelist", 40, charcommand_storagelist },
  77. { CharCommandItem, "#item", 60, charcommand_item },
  78. { CharCommandWarp, "#warp", 60, charcommand_warp },
  79. { CharCommandWarp, "#rura", 60, charcommand_warp },
  80. { CharCommandWarp, "#rura+", 60, charcommand_warp },
  81. { CharCommandZeny, "#zeny", 60, charcommand_zeny },
  82. { CharCommandFakeName, "#fakename", 20, charcommand_fakename},
  83. //*********************************Recently added commands*********************************************
  84. { CharCommandBaseLevel, "#baselvl", 20, charcommand_baselevel},
  85. { CharCommandBaseLevel, "#blvl", 60, charcommand_baselevel},
  86. { CharCommandBaseLevel, "#baselvlup", 60, charcommand_baselevel},
  87. { CharCommandJobLevel, "#joblvl", 60, charcommand_joblevel},
  88. { CharCommandJobLevel, "#jlvl", 60, charcommand_joblevel},
  89. { CharCommandJobLevel, "#joblvlup", 60, charcommand_joblevel},
  90. { CharCommandQuestSkill, "#questskill", 60, charcommand_questskill },
  91. { CharCommandLostSkill, "#lostskill", 60, charcommand_lostskill },
  92. { CharCommandSkReset, "#skreset", 60, charcommand_skreset },
  93. { CharCommandStReset, "#streset", 60, charcommand_streset },
  94. { CharCommandModel, "#model", 50, charcommand_model },
  95. { CharCommandSKPoint, "#skpoint", 60, charcommand_skpoint },
  96. { CharCommandSTPoint, "#stpoint", 60, charcommand_stpoint },
  97. { CharCommandChangeSex, "#changesex", 60, charcommand_changesex },
  98. { CharCommandFeelReset, "#feelreset", 60, charcommand_feelreset },
  99. { CharCommandHelp, "#help", 20, charcommand_help },
  100. // add new commands before this line
  101. { CharCommand_Unknown, NULL, 1, NULL }
  102. };
  103. int get_charcommand_level(const CharCommandType type) {
  104. int i;
  105. for (i = 0; charcommand_info[i].type != CharCommand_None; i++)
  106. if (charcommand_info[i].type == type)
  107. return charcommand_info[i].level;
  108. return 100; // 100: command can not be used
  109. }
  110. CharCommandType
  111. is_charcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
  112. CharCommandInfo info;
  113. CharCommandType type;
  114. memset(&info, 0, sizeof(info));
  115. type = charcommand(sd, gmlvl, str, &info);
  116. if (type != CharCommand_None) {
  117. char command[100];
  118. char output[200];
  119. const char* p = str;
  120. if (map[sd->bl.m].nocommand &&
  121. gmlvl < map[sd->bl.m].nocommand)
  122. { //Command not allowed on this map.
  123. sprintf(output, msg_txt(143));
  124. clif_displaymessage(fd, output);
  125. return AtCommand_None;
  126. }
  127. memset(command, '\0', sizeof(command));
  128. memset(output, '\0', sizeof(output));
  129. while (*p && !ISSPACE(*p))
  130. p++;
  131. if (p - str >= sizeof(command)) // too long
  132. return CharCommand_Unknown;
  133. strncpy(command, str, p - str);
  134. while (ISSPACE(*p))
  135. p++;
  136. if (type == CharCommand_Unknown || info.proc == NULL) {
  137. snprintf(output, sizeof(output),msg_txt(153), command); // %s is Unknown Command.
  138. clif_displaymessage(fd, output);
  139. } else {
  140. if (info.proc(fd, sd, command, p) != 0) {
  141. // Command can not be executed
  142. snprintf(output, sizeof(output), msg_txt(154), command); // %s failed.
  143. clif_displaymessage(fd, output);
  144. }
  145. }
  146. return info.type;
  147. }
  148. return CharCommand_None;
  149. }
  150. /*==========================================
  151. *is_charcommand @コマンドに存在するかどうか確認する
  152. *------------------------------------------
  153. */
  154. CharCommandType
  155. is_charcommand(const int fd, struct map_session_data* sd, const char* message) {
  156. const char* str = message;
  157. int s_flag = 0;
  158. nullpo_retr(CharCommand_None, sd);
  159. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND)
  160. return CharCommand_None;
  161. if (!message || !*message)
  162. return CharCommand_None;
  163. str += strlen(sd->status.name);
  164. while (*str && (ISSPACE(*str) || (s_flag == 0 && *str == ':'))) {
  165. if (*str == ':')
  166. s_flag = 1;
  167. str++;
  168. }
  169. if (!*str)
  170. return CharCommand_None;
  171. if(str[0] == '|' && strlen(str) >= 4 && str[3] == charcommand_symbol)
  172. str += 3; // skip 10/11-langtype's codepage indicator, if detected
  173. return is_charcommand_sub(fd,sd,str,pc_isGM(sd));
  174. }
  175. /*==========================================
  176. *
  177. *------------------------------------------
  178. */
  179. CharCommandType charcommand(struct map_session_data* sd, const int level, const char* message, CharCommandInfo* info) {
  180. char* p = (char *)message;
  181. if (!info)
  182. return CharCommand_None;
  183. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  184. return CharCommand_None;
  185. if (!p || !*p) {
  186. ShowError("char command message is empty\n");
  187. return CharCommand_None;
  188. }
  189. if (*p == charcommand_symbol) { // check first char
  190. char command[101];
  191. int i = 0;
  192. memset(info, 0, sizeof(CharCommandInfo));
  193. sscanf(p, "%100s", command);
  194. command[100] = '\0';
  195. while (charcommand_info[i].type != CharCommand_Unknown) {
  196. if (strcmpi(command+1, charcommand_info[i].command+1) == 0 && level >= charcommand_info[i].level) {
  197. p[0] = charcommand_info[i].command[0]; // set correct first symbol for after.
  198. break;
  199. }
  200. i++;
  201. }
  202. if (charcommand_info[i].type == CharCommand_Unknown) {
  203. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  204. if (level == 0)
  205. return CharCommand_None;
  206. else
  207. return CharCommand_Unknown;
  208. } else if((log_config.gm) && (charcommand_info[i].level >= log_config.gm)) {
  209. log_atcommand(sd, message);
  210. }
  211. memcpy(info, &charcommand_info[i], sizeof charcommand_info[i]);
  212. } else {
  213. return CharCommand_None;
  214. }
  215. return info->type;
  216. }
  217. /*==========================================
  218. *
  219. *------------------------------------------
  220. */
  221. static CharCommandInfo* get_charcommandinfo_byname(const char* name) {
  222. int i;
  223. for (i = 0; charcommand_info[i].type != CharCommand_Unknown; i++)
  224. if (strcmpi(charcommand_info[i].command + 1, name) == 0)
  225. return &charcommand_info[i];
  226. return NULL;
  227. }
  228. /*==========================================
  229. *
  230. *------------------------------------------
  231. */
  232. int charcommand_config_read(const char *cfgName) {
  233. char line[1024], w1[1024], w2[1024];
  234. CharCommandInfo* p;
  235. FILE* fp;
  236. if ((fp = fopen(cfgName, "r")) == NULL) {
  237. ShowError("CharCommands configuration file not found: %s\n", cfgName);
  238. return 1;
  239. }
  240. while (fgets(line, sizeof(line)-1, fp)) {
  241. if (line[0] == '/' && line[1] == '/')
  242. continue;
  243. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  244. continue;
  245. p = get_charcommandinfo_byname(w1);
  246. if (p != NULL) {
  247. p->level = atoi(w2);
  248. if (p->level > 100)
  249. p->level = 100;
  250. else if (p->level < 0)
  251. p->level = 0;
  252. }
  253. if (strcmpi(w1, "import") == 0)
  254. charcommand_config_read(w2);
  255. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  256. w2[0] != '/' && // symbol of standard ragnarok GM commands
  257. w2[0] != '%' && // symbol of party chat speaking
  258. w2[0] != '$' && // symbol of guild chat speaking
  259. w2[0] != '@') // symbol of atcommand
  260. charcommand_symbol = w2[0];
  261. }
  262. fclose(fp);
  263. return 0;
  264. }
  265. /*==========================================
  266. * 対象キャラクターを転職させる upper指定で転生や養子も可能
  267. *------------------------------------------
  268. */
  269. int charcommand_jobchange(
  270. const int fd, struct map_session_data* sd,
  271. const char* command, const char* message)
  272. {
  273. char character[100];
  274. struct map_session_data* pl_sd;
  275. int job = 0, upper = -1;
  276. memset(character, '\0', sizeof(character));
  277. if (!message || !*message) {
  278. clif_displaymessage(fd, "Please, enter a job and a player name (usage: #job/#jobchange <job ID> <char name>).");
  279. return -1;
  280. }
  281. if (sscanf(message, "%d %d %99[^\n]", &job, &upper, character) < 3) { //upper指定してある
  282. upper = -1;
  283. if (sscanf(message, "%d %99[^\n]", &job, character) < 2) { //upper指定してない上に何か足りない
  284. clif_displaymessage(fd, "Please, enter a job and a player name (usage: #job/#jobchange <job ID> <char name>).");
  285. return -1;
  286. }
  287. }
  288. if ((pl_sd = map_nick2sd(character)) != NULL) {
  289. int j;
  290. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job only to lower or same level
  291. if ((job >= 0 && job < MAX_PC_CLASS)) {
  292. for (j=0; j < MAX_INVENTORY; j++) {
  293. if(pl_sd->status.inventory[j].nameid>0 && pl_sd->status.inventory[j].equip!=0)
  294. pc_unequipitem(pl_sd, j, 3);
  295. }
  296. if (pc_jobchange(pl_sd, job, upper) == 0)
  297. clif_displaymessage(fd, msg_table[48]); // Character's job changed.
  298. else {
  299. clif_displaymessage(fd, msg_table[192]); // Impossible to change the character's job.
  300. return -1;
  301. }
  302. } else {
  303. clif_displaymessage(fd, msg_table[49]); // Invalid job ID.
  304. return -1;
  305. }
  306. } else {
  307. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  308. return -1;
  309. }
  310. } else {
  311. clif_displaymessage(fd, msg_table[3]); // Character not found.
  312. return -1;
  313. }
  314. return 0;
  315. }
  316. /*==========================================
  317. *
  318. *------------------------------------------
  319. */
  320. int charcommand_petrename(
  321. const int fd, struct map_session_data* sd,
  322. const char* command, const char* message)
  323. {
  324. char character[NAME_LENGTH];
  325. struct map_session_data *pl_sd;
  326. struct pet_data *pd;
  327. memset(character, '\0', sizeof(character));
  328. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  329. clif_displaymessage(fd, "Please, enter a player name (usage: #petrename <char name>).");
  330. return -1;
  331. }
  332. if ((pl_sd = map_nick2sd(character)) == NULL) {
  333. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  334. return -1;
  335. }
  336. if (!pl_sd->status.pet_id || !pl_sd->pd) {
  337. clif_displaymessage(fd, msg_table[191]); // Sorry, but this player has no pet.
  338. return -1;
  339. }
  340. pd = pl_sd->pd;
  341. if (pd->pet.rename_flag) {
  342. clif_displaymessage(fd, msg_table[190]); // This player can already rename his/her pet.
  343. return -1;
  344. }
  345. pd->pet.rename_flag = 0;
  346. intif_save_petdata(pl_sd->status.account_id, &pd->pet);
  347. clif_send_petstatus(pl_sd);
  348. clif_displaymessage(fd, msg_table[189]); // This player can now rename his/her pet.
  349. return 0;
  350. }
  351. /*==========================================
  352. *
  353. *------------------------------------------
  354. */
  355. int charcommand_petfriendly(
  356. const int fd, struct map_session_data* sd,
  357. const char* command, const char* message)
  358. {
  359. int friendly = 0;
  360. char character[NAME_LENGTH];
  361. struct map_session_data *pl_sd;
  362. struct pet_data *pd;
  363. memset(character, '\0', sizeof(character));
  364. if (!message || !*message || sscanf(message,"%d %23s",&friendly,character) < 2) {
  365. clif_displaymessage(fd, "Please, enter a valid value (usage: "
  366. "#petfriendly <0-1000> <player>).");
  367. return -1;
  368. }
  369. if (((pl_sd = map_nick2sd(character)) == NULL) ||
  370. pc_isGM(sd)<pc_isGM(pl_sd)) {
  371. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  372. return -1;
  373. }
  374. if (!pl_sd->status.pet_id || !pl_sd->pd) {
  375. clif_displaymessage(fd, msg_table[191]); // Sorry, but this player has no pet.
  376. return -1;
  377. }
  378. if (friendly < 0 || friendly > 1000) {
  379. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  380. return -1;
  381. }
  382. pd = pl_sd->pd;
  383. if (friendly == pd->pet.intimate) {
  384. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  385. return -1;
  386. }
  387. pd->pet.intimate = friendly;
  388. clif_send_petstatus(pl_sd);
  389. clif_pet_emotion(pd,0);
  390. clif_displaymessage(pl_sd->fd, msg_table[182]); // Pet friendly value changed!
  391. clif_displaymessage(sd->fd, msg_table[182]); // Pet friendly value changed!
  392. return 0;
  393. }
  394. /*==========================================
  395. *
  396. *------------------------------------------
  397. */
  398. int charcommand_stats(
  399. const int fd, struct map_session_data* sd,
  400. const char* command, const char* message)
  401. {
  402. char character[NAME_LENGTH];
  403. char job_jobname[100];
  404. char output[200];
  405. struct map_session_data *pl_sd;
  406. int i;
  407. memset(character, '\0', sizeof(character));
  408. memset(job_jobname, '\0', sizeof(job_jobname));
  409. memset(output, '\0', sizeof(output));
  410. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  411. clif_displaymessage(fd, "Please, enter a player name (usage: #stats <char name>).");
  412. return -1;
  413. }
  414. if ((pl_sd = map_nick2sd(character)) != NULL) {
  415. struct {
  416. const char* format;
  417. int value;
  418. } output_table[] = {
  419. { "Base Level - %d", 0 },
  420. { NULL, 0 },
  421. { "Hp - %d", 0 },
  422. { "MaxHp - %d", 0 },
  423. { "Sp - %d", 0 },
  424. { "MaxSp - %d", 0 },
  425. { "Str - %3d", 0 },
  426. { "Agi - %3d", 0 },
  427. { "Vit - %3d", 0 },
  428. { "Int - %3d", 0 },
  429. { "Dex - %3d", 0 },
  430. { "Luk - %3d", 0 },
  431. { "Zeny - %d", 0 },
  432. { NULL, 0 }
  433. };
  434. //direct array initialization with variables is not standard C compliant.
  435. output_table[0].value = pl_sd->status.base_level;
  436. output_table[1].format = job_jobname;
  437. output_table[1].value = pl_sd->status.job_level;
  438. output_table[2].value = pl_sd->status.hp;
  439. output_table[3].value = pl_sd->status.max_hp;
  440. output_table[4].value = pl_sd->status.sp;
  441. output_table[5].value = pl_sd->status.max_sp;
  442. output_table[6].value = pl_sd->status.str;
  443. output_table[7].value = pl_sd->status.agi;
  444. output_table[8].value = pl_sd->status.vit;
  445. output_table[9].value = pl_sd->status.int_;
  446. output_table[10].value = pl_sd->status.dex;
  447. output_table[11].value = pl_sd->status.luk;
  448. output_table[12].value = pl_sd->status.zeny;
  449. sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class_), "(level %d)");
  450. sprintf(output, msg_table[53], pl_sd->status.name); // '%s' stats:
  451. clif_displaymessage(fd, output);
  452. for (i = 0; output_table[i].format != NULL; i++) {
  453. sprintf(output, output_table[i].format, output_table[i].value);
  454. clif_displaymessage(fd, output);
  455. }
  456. } else {
  457. clif_displaymessage(fd, msg_table[3]); // Character not found.
  458. return -1;
  459. }
  460. return 0;
  461. }
  462. /*==========================================
  463. * Character Reset
  464. *------------------------------------------
  465. */
  466. int charcommand_reset(
  467. const int fd, struct map_session_data* sd,
  468. const char* command, const char* message)
  469. {
  470. char character[NAME_LENGTH];
  471. char output[200];
  472. struct map_session_data *pl_sd;
  473. memset(character, '\0', sizeof(character));
  474. memset(output, '\0', sizeof(output));
  475. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  476. clif_displaymessage(fd, "Please, enter a player name (usage: #reset <charname>).");
  477. return -1;
  478. }
  479. if ((pl_sd = map_nick2sd(character)) != NULL) {
  480. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset a character only for lower or same GM level
  481. pc_resetstate(pl_sd);
  482. pc_resetskill(pl_sd,1);
  483. sprintf(output, msg_table[208], character); // '%s' skill and stats points reseted!
  484. clif_displaymessage(fd, output);
  485. } else {
  486. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  487. return -1;
  488. }
  489. } else {
  490. clif_displaymessage(fd, msg_table[3]); // Character not found.
  491. return -1;
  492. }
  493. return 0;
  494. }
  495. /*==========================================
  496. *
  497. *------------------------------------------
  498. */
  499. int charcommand_option(
  500. const int fd, struct map_session_data* sd,
  501. const char* command, const char* message)
  502. {
  503. char character[NAME_LENGTH];
  504. int opt1 = 0, opt2 = 0, opt3 = 0;
  505. struct map_session_data* pl_sd;
  506. memset(character, '\0', sizeof(character));
  507. if (!message || !*message ||
  508. sscanf(message, "%d %d %d %23[^\n]", &opt1, &opt2, &opt3, character) < 4 ||
  509. opt1 < 0 || opt2 < 0 || opt3 < 0) {
  510. clif_displaymessage(fd, "Please, enter valid options and a player name (usage: #option <param1> <param2> <param3> <charname>).");
  511. return -1;
  512. }
  513. if ((pl_sd = map_nick2sd(character)) != NULL) {
  514. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change option only to lower or same level
  515. pl_sd->sc.opt1 = opt1;
  516. pl_sd->sc.opt2 = opt2;
  517. pc_setoption(pl_sd, opt3);
  518. clif_displaymessage(fd, msg_table[58]); // Character's options changed.
  519. } else {
  520. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  521. return -1;
  522. }
  523. } else {
  524. clif_displaymessage(fd, msg_table[3]); // Character not found.
  525. return -1;
  526. }
  527. return 0;
  528. }
  529. /*==========================================
  530. *
  531. *------------------------------------------
  532. */
  533. int charcommand_save(
  534. const int fd, struct map_session_data* sd,
  535. const char* command, const char* message)
  536. {
  537. char map_name[MAP_NAME_LENGTH_EXT];
  538. char character[NAME_LENGTH];
  539. struct map_session_data* pl_sd;
  540. int x = 0, y = 0;
  541. int m;
  542. memset(map_name, '\0', sizeof(map_name));
  543. memset(character, '\0', sizeof(character));
  544. if (!message || !*message || sscanf(message, "%15s %d %d %23[^\n]", map_name, &x, &y, character) < 4 || x < 0 || y < 0) {
  545. clif_displaymessage(fd, "Please, enter a valid save point and a player name (usage: #save <map> <x> <y> <charname>).");
  546. return -1;
  547. }
  548. if ((pl_sd = map_nick2sd(character)) != NULL) {
  549. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change save point only to lower or same gm level
  550. m = map_mapname2mapid(map_name);
  551. if (m < 0 && !mapindex_name2id(map_name)) {
  552. clif_displaymessage(fd, msg_table[1]); // Map not found.
  553. return -1;
  554. } else {
  555. //FIXME: What do you do if the map is in another map server with the nowarpto flag?
  556. if (m>=0 && map[m].flag.nosave && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  557. clif_displaymessage(fd, "You are not authorised to set this map as a save map.");
  558. return -1;
  559. }
  560. if (m>=0)
  561. pc_setsavepoint(pl_sd, map[m].index, x, y);
  562. else
  563. pc_setsavepoint(pl_sd, mapindex_name2id(map_name), x, y);
  564. clif_displaymessage(fd, msg_table[57]); // Character's respawn point changed.
  565. }
  566. } else {
  567. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  568. return -1;
  569. }
  570. } else {
  571. clif_displaymessage(fd, msg_table[3]); // Character not found.
  572. return -1;
  573. }
  574. return 0;
  575. }
  576. /*==========================================
  577. *
  578. *------------------------------------------
  579. */
  580. //** Character Stats All by fritz
  581. int charcommand_stats_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  582. {
  583. char output[1024], gmlevel[1024];
  584. int i;
  585. int count, users;
  586. struct map_session_data *pl_sd, **pl_allsd;
  587. memset(output, '\0', sizeof(output));
  588. memset(gmlevel, '\0', sizeof(gmlevel));
  589. count = 0;
  590. pl_allsd = map_getallusers(&users);
  591. for(i = 0; i < users; i++) {
  592. if ((pl_sd = pl_allsd[i]))
  593. {
  594. if (pc_isGM(pl_sd) > 0)
  595. sprintf(gmlevel, "| GM Lvl: %d", pc_isGM(pl_sd));
  596. else
  597. sprintf(gmlevel, " ");
  598. sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp);
  599. clif_displaymessage(fd, output);
  600. sprintf(output, "STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", pl_sd->status.str, pl_sd->status.agi, pl_sd->status.vit, pl_sd->status.int_, pl_sd->status.dex, pl_sd->status.luk, pl_sd->status.zeny, gmlevel);
  601. clif_displaymessage(fd, output);
  602. clif_displaymessage(fd, "--------");
  603. count++;
  604. }
  605. }
  606. if (count == 0)
  607. clif_displaymessage(fd, msg_table[28]); // No player found.
  608. else if (count == 1)
  609. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  610. else {
  611. sprintf(output, msg_table[30], count); // %d players found.
  612. clif_displaymessage(fd, output);
  613. }
  614. return 0;
  615. }
  616. /*==========================================
  617. * CharSpiritBall Function by PalasX
  618. *------------------------------------------
  619. */
  620. int charcommand_spiritball(const int fd, struct map_session_data* sd,const char* command, const char* message)
  621. {
  622. struct map_session_data *pl_sd;
  623. char character[NAME_LENGTH];
  624. int spirit = 0;
  625. memset(character, '\0', sizeof(character));
  626. if(!message || !*message || sscanf(message, "%d %23[^\n]", &spirit, character) < 2 || spirit < 0 || spirit > 1000) {
  627. clif_displaymessage(fd, "Usage: @spiritball <number: 0-1000>) <CHARACTER_NAME>.");
  628. return -1;
  629. }
  630. if((pl_sd = map_nick2sd(character)) != NULL) {
  631. if (spirit >= 0 && spirit <= 0x7FFF) {
  632. if (pl_sd->spiritball != spirit || spirit > 999) {
  633. if (pl_sd->spiritball > 0)
  634. pc_delspiritball(pl_sd, pl_sd->spiritball, 1);
  635. pl_sd->spiritball = spirit;
  636. clif_spiritball(pl_sd);
  637. // no message, player can look the difference
  638. if (spirit > 1000)
  639. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  640. } else {
  641. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  642. return -1;
  643. }
  644. } else {
  645. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  646. return -1;
  647. }
  648. } else {
  649. clif_displaymessage(fd, msg_table[3]); // Character not found.
  650. return -1;
  651. }
  652. return 0;
  653. }
  654. /*==========================================
  655. * #itemlist <character>: Displays the list of a player's items.
  656. *------------------------------------------
  657. */
  658. int
  659. charcommand_itemlist(
  660. const int fd, struct map_session_data* sd,
  661. const char* command, const char* message)
  662. {
  663. struct map_session_data *pl_sd;
  664. struct item_data *item_data, *item_temp;
  665. int i, j, equip, count, counter, counter2;
  666. char character[NAME_LENGTH], output[200], equipstr[100], outputtmp[200];
  667. struct item *i_item; //Current inventory item.
  668. nullpo_retr(-1, sd);
  669. memset(character, '\0', sizeof(character));
  670. memset(output, '\0', sizeof(output));
  671. memset(equipstr, '\0', sizeof(equipstr));
  672. memset(outputtmp, '\0', sizeof(outputtmp));
  673. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  674. clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
  675. return -1;
  676. }
  677. if ((pl_sd = map_nick2sd(character)) != NULL) {
  678. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  679. counter = 0;
  680. count = 0;
  681. for (i = 0; i < MAX_INVENTORY; i++) {
  682. i_item = &pl_sd->status.inventory[i];
  683. if (pl_sd->status.inventory[i].nameid > 0 && (item_data = itemdb_exists(i_item->nameid)) != NULL) {
  684. counter = counter + i_item->amount;
  685. count++;
  686. if (count == 1) {
  687. sprintf(output, "------ Items list of '%s' ------", pl_sd->status.name);
  688. clif_displaymessage(fd, output);
  689. }
  690. if ((equip = i_item->equip)) {
  691. strcpy(equipstr, "| equiped: ");
  692. if (equip & EQP_GARMENT)
  693. strcat(equipstr, "robe/gargment, ");
  694. if (equip & EQP_ACC_L)
  695. strcat(equipstr, "left accessory, ");
  696. if (equip & EQP_ARMOR)
  697. strcat(equipstr, "body/armor, ");
  698. if ((equip & EQP_ARMS) == EQP_HAND_R)
  699. strcat(equipstr, "right hand, ");
  700. if ((equip & EQP_ARMS) == EQP_HAND_L)
  701. strcat(equipstr, "left hand, ");
  702. if ((equip & EQP_ARMS) == EQP_ARMS)
  703. strcat(equipstr, "both hands, ");
  704. if (equip & EQP_SHOES)
  705. strcat(equipstr, "feet, ");
  706. if (equip & EQP_ACC_R)
  707. strcat(equipstr, "right accessory, ");
  708. if ((equip & EQP_HELM) == EQP_HEAD_LOW)
  709. strcat(equipstr, "lower head, ");
  710. if ((equip & EQP_HELM) == EQP_HEAD_TOP)
  711. strcat(equipstr, "top head, ");
  712. if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP))
  713. strcat(equipstr, "lower/top head, ");
  714. if ((equip & EQP_HELM) == EQP_HEAD_MID)
  715. strcat(equipstr, "mid head, ");
  716. if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID))
  717. strcat(equipstr, "lower/mid head, ");
  718. if ((equip & EQP_HELM) == EQP_HELM)
  719. strcat(equipstr, "lower/mid/top head, ");
  720. // remove final ', '
  721. equipstr[strlen(equipstr) - 2] = '\0';
  722. } else
  723. memset(equipstr, '\0', sizeof(equipstr));
  724. if (i_item->refine)
  725. sprintf(output, "%d %s %+d (%s %+d, id: %d) %s", i_item->amount, item_data->name, i_item->refine, item_data->jname, i_item->refine, i_item->nameid, equipstr);
  726. else
  727. sprintf(output, "%d %s (%s, id: %d) %s", i_item->amount, item_data->name, item_data->jname, i_item->nameid, equipstr);
  728. clif_displaymessage(fd, output);
  729. memset(output, '\0', sizeof(output));
  730. counter2 = 0;
  731. if(i_item->card[0]==CARD0_PET) { //pet eggs
  732. if (i_item->card[3])
  733. sprintf(outputtmp, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(i_item->card[1], i_item->card[2]));
  734. else
  735. sprintf(outputtmp, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(i_item->card[1], i_item->card[2]));
  736. strcat(output, outputtmp);
  737. } else
  738. if(i_item->card[0]==CARD0_FORGE) { //forged items.
  739. sprintf(outputtmp, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(i_item->card[2], i_item->card[3]), i_item->card[1]>>8, i_item->card[1]&0x0f);
  740. } else
  741. if(i_item->card[0]==CARD0_CREATE) { //created items.
  742. sprintf(outputtmp, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(i_item->card[2], i_item->card[3]));
  743. strcat(output, outputtmp);
  744. } else //Normal slots
  745. for (j = 0; j < item_data->slot; j++) {
  746. if (pl_sd->status.inventory[i].card[j]) {
  747. if ((item_temp = itemdb_exists(i_item->card[j])) != NULL) {
  748. if (output[0] == '\0')
  749. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  750. else
  751. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  752. strcat(output, outputtmp);
  753. }
  754. }
  755. }
  756. if (output[0] != '\0') {
  757. output[strlen(output) - 2] = ')';
  758. output[strlen(output) - 1] = '\0';
  759. clif_displaymessage(fd, output);
  760. }
  761. }
  762. }
  763. if (count == 0)
  764. clif_displaymessage(fd, "No item found on this player.");
  765. else {
  766. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  767. clif_displaymessage(fd, output);
  768. }
  769. } else {
  770. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  771. return -1;
  772. }
  773. } else {
  774. clif_displaymessage(fd, msg_table[3]); // Character not found.
  775. return -1;
  776. }
  777. return 0;
  778. }
  779. /*==========================================
  780. * #effect by [MouseJstr]
  781. *
  782. * Create a effect localized on another character
  783. *------------------------------------------
  784. */
  785. int
  786. charcommand_effect(const int fd, struct map_session_data* sd,
  787. const char* command, const char* message)
  788. {
  789. struct map_session_data *pl_sd = NULL;
  790. char target[NAME_LENGTH];
  791. int type = 0;
  792. nullpo_retr(-1, sd);
  793. if (!message || !*message || sscanf(message, "%d %23s", &type, target) != 2) {
  794. clif_displaymessage(fd, "usage: #effect <type+> <target>.");
  795. return -1;
  796. }
  797. if((pl_sd=map_nick2sd(target)) == NULL)
  798. return -1;
  799. clif_specialeffect(&pl_sd->bl, type, AREA);
  800. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  801. return 0;
  802. }
  803. /*==========================================
  804. * #storagelist <character>: Displays the items list of a player's storage.
  805. *------------------------------------------
  806. */
  807. int
  808. charcommand_storagelist(
  809. const int fd, struct map_session_data* sd,
  810. const char* command, const char* message)
  811. {
  812. struct storage *stor;
  813. struct map_session_data *pl_sd;
  814. struct item_data *item_data, *item_temp;
  815. int i, j, count, counter, counter2;
  816. char character[NAME_LENGTH], output[200], outputtmp[200];
  817. nullpo_retr(-1, sd);
  818. memset(character, '\0', sizeof(character));
  819. memset(output, '\0', sizeof(output));
  820. memset(outputtmp, '\0', sizeof(outputtmp));
  821. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  822. clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
  823. return -1;
  824. }
  825. if ((pl_sd = map_nick2sd(character)) != NULL) {
  826. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  827. if((stor = account2storage2(pl_sd->status.account_id)) != NULL) {
  828. counter = 0;
  829. count = 0;
  830. for (i = 0; i < MAX_STORAGE; i++) {
  831. if (stor->storage_[i].nameid > 0 && (item_data = itemdb_search(stor->storage_[i].nameid)) != NULL) {
  832. counter = counter + stor->storage_[i].amount;
  833. count++;
  834. if (count == 1) {
  835. sprintf(output, "------ Storage items list of '%s' ------", pl_sd->status.name);
  836. clif_displaymessage(fd, output);
  837. }
  838. if (stor->storage_[i].refine)
  839. sprintf(output, "%d %s %+d (%s %+d, id: %d)", stor->storage_[i].amount, item_data->name, stor->storage_[i].refine, item_data->jname, stor->storage_[i].refine, stor->storage_[i].nameid);
  840. else
  841. sprintf(output, "%d %s (%s, id: %d)", stor->storage_[i].amount, item_data->name, item_data->jname, stor->storage_[i].nameid);
  842. clif_displaymessage(fd, output);
  843. memset(output, '\0', sizeof(output));
  844. counter2 = 0;
  845. for (j = 0; j < item_data->slot; j++) {
  846. if (stor->storage_[i].card[j]) {
  847. if ((item_temp = itemdb_search(stor->storage_[i].card[j])) != NULL) {
  848. if (output[0] == '\0')
  849. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  850. else
  851. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  852. strcat(output, outputtmp);
  853. }
  854. }
  855. }
  856. if (output[0] != '\0') {
  857. output[strlen(output) - 2] = ')';
  858. output[strlen(output) - 1] = '\0';
  859. clif_displaymessage(fd, output);
  860. }
  861. }
  862. }
  863. if (count == 0)
  864. clif_displaymessage(fd, "No item found in the storage of this player.");
  865. else {
  866. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  867. clif_displaymessage(fd, output);
  868. }
  869. } else {
  870. clif_displaymessage(fd, "This player has no storage.");
  871. return 0;
  872. }
  873. } else {
  874. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  875. return -1;
  876. }
  877. } else {
  878. clif_displaymessage(fd, msg_table[3]); // Character not found.
  879. return -1;
  880. }
  881. return 0;
  882. }
  883. static void
  884. charcommand_giveitem_sub(struct map_session_data *sd,struct item_data *item_data,int number)
  885. {
  886. int flag = 0;
  887. int loop = 1, get_count = number,i;
  888. struct item item_tmp;
  889. if(sd && item_data){
  890. if (item_data->type == 4 || item_data->type == 5 ||
  891. item_data->type == 7 || item_data->type == 8) {
  892. loop = number;
  893. get_count = 1;
  894. }
  895. for (i = 0; i < loop; i++) {
  896. memset(&item_tmp, 0, sizeof(item_tmp));
  897. item_tmp.nameid = item_data->nameid;
  898. item_tmp.identify = 1;
  899. if ((flag = pc_additem((struct map_session_data*)sd,
  900. &item_tmp, get_count)))
  901. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  902. }
  903. //Logs (A)dmins items [Lupus]
  904. if(log_config.enable_logs&0x400)
  905. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  906. }
  907. }
  908. /*==========================================
  909. * #item command (usage: #item <name/id_of_item> <quantity> <player>)
  910. * by MC Cameri
  911. *------------------------------------------
  912. */
  913. int charcommand_item(
  914. const int fd, struct map_session_data* sd,
  915. const char* command, const char* message)
  916. {
  917. char item_name[100];
  918. char character[NAME_LENGTH];
  919. struct map_session_data *pl_sd;
  920. int number = 0, item_id, flag;
  921. struct item item_tmp;
  922. struct item_data *item_data;
  923. int get_count, i, pet_id;
  924. char tmp_cmdoutput[1024];
  925. nullpo_retr(-1, sd);
  926. memset(item_name, '\0', sizeof(item_name));
  927. if (!message || !*message || (
  928. sscanf(message, "\"%99[^\"]\" %d %23[^\n]", item_name, &number, character) < 3 &&
  929. sscanf(message, "%99s %d %23[^\n]", item_name, &number, character) < 3
  930. )) {
  931. clif_displaymessage(fd, "Please, enter an item name/id (usage: #item <item name or ID> <quantity> <char name>).");
  932. return -1;
  933. }
  934. if (number <= 0)
  935. number = 1;
  936. item_id = 0;
  937. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  938. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  939. item_id = item_data->nameid;
  940. if (item_id >= 500) {
  941. get_count = number;
  942. // check pet egg
  943. pet_id = search_petDB_index(item_id, PET_EGG);
  944. if (item_data->type == 4 || item_data->type == 5 ||
  945. item_data->type == 7 || item_data->type == 8) {
  946. get_count = 1;
  947. }
  948. if ((pl_sd = map_nick2sd(character)) != NULL) {
  949. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  950. for (i = 0; i < number; i += get_count) {
  951. // if pet egg
  952. if (pet_id >= 0) {
  953. pl_sd->catch_target_class = pet_db[pet_id].class_;
  954. intif_create_pet(pl_sd->status.account_id, pl_sd->status.char_id,
  955. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  956. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  957. 100, 0, 1, pet_db[pet_id].jname);
  958. // if not pet egg
  959. } else {
  960. memset(&item_tmp, 0, sizeof(item_tmp));
  961. item_tmp.nameid = item_id;
  962. item_tmp.identify = 1;
  963. if ((flag = pc_additem(pl_sd, &item_tmp, get_count)))
  964. clif_additem(pl_sd, 0, 0, flag);
  965. }
  966. }
  967. //Logs (A)dmins items [Lupus]
  968. if(log_config.enable_logs&0x400)
  969. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  970. clif_displaymessage(fd, msg_table[18]); // Item created.
  971. } else {
  972. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  973. return -1;
  974. }
  975. } else if(/* from jA's @giveitem */strcmpi(character,"all")==0 || strcmpi(character,"everyone")==0){
  976. struct map_session_data **pl_allsd;
  977. int users;
  978. pl_allsd = map_getallusers(&users);
  979. for (i = 0; i < users; i++) {
  980. if ((pl_sd = pl_allsd[i])) {
  981. charcommand_giveitem_sub(pl_sd,item_data,number);
  982. snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "You got %s %d.", item_name,number);
  983. clif_displaymessage(pl_sd->fd, tmp_cmdoutput);
  984. }
  985. }
  986. snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "%s received %s %d.","Everyone",item_name,number);
  987. clif_displaymessage(fd, tmp_cmdoutput);
  988. } else {
  989. clif_displaymessage(fd, msg_table[3]); // Character not found.
  990. return -1;
  991. }
  992. } else {
  993. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  994. return -1;
  995. }
  996. return 0;
  997. }
  998. /*==========================================
  999. * #warp/#rura/#rura+ <mapname> <x> <y> <char name>
  1000. *------------------------------------------
  1001. */
  1002. int charcommand_warp(
  1003. const int fd, struct map_session_data* sd,
  1004. const char* command, const char* message)
  1005. {
  1006. char map_name[MAP_NAME_LENGTH_EXT];
  1007. char character[NAME_LENGTH];
  1008. int x = 0, y = 0;
  1009. struct map_session_data *pl_sd;
  1010. int m;
  1011. nullpo_retr(-1, sd);
  1012. memset(map_name, '\0', sizeof(map_name));
  1013. memset(character, '\0', sizeof(character));
  1014. if (!message || !*message || sscanf(message, "%15s %d %d %23[^\n]", map_name, &x, &y, character) < 4) {
  1015. clif_displaymessage(fd, "Usage: #warp/#rura/#rura+ <mapname> <x> <y> <char name>");
  1016. return -1;
  1017. }
  1018. if ((pl_sd = map_nick2sd(character)) == NULL) {
  1019. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1020. return -1;
  1021. }
  1022. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level
  1023. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1024. return -1;
  1025. }
  1026. m = map_mapname2mapid(map_name);
  1027. if (m < 0) {
  1028. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1029. return -1;
  1030. }
  1031. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOREACH)) {
  1032. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1033. x = y = 0;
  1034. }
  1035. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1036. clif_displaymessage(fd, "You are not authorised to warp someone to this map.");
  1037. return -1;
  1038. }
  1039. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1040. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  1041. return -1;
  1042. }
  1043. if (pc_setpos(pl_sd, map[m].index, x, y, 3) == 0) {
  1044. clif_displaymessage(pl_sd->fd, msg_table[0]); // Warped.
  1045. clif_displaymessage(fd, msg_table[15]); // Player warped (message sent to player too).
  1046. return 0;
  1047. }
  1048. //No error message specified...?
  1049. return -1;
  1050. }
  1051. /*==========================================
  1052. * #zeny <charname>
  1053. *------------------------------------------
  1054. */
  1055. int charcommand_zeny(
  1056. const int fd, struct map_session_data* sd,
  1057. const char* command, const char* message)
  1058. {
  1059. struct map_session_data *pl_sd;
  1060. char character[NAME_LENGTH];
  1061. int zeny = 0, new_zeny;
  1062. nullpo_retr(-1, sd);
  1063. memset(character, '\0', sizeof(character));
  1064. if (!message || !*message || sscanf(message, "%d %23[^\n]", &zeny, character) < 2 || zeny == 0) {
  1065. clif_displaymessage(fd, "Please, enter a number and a player name (usage: #zeny <zeny> <name>).");
  1066. return -1;
  1067. }
  1068. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1069. new_zeny = pl_sd->status.zeny + zeny;
  1070. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  1071. new_zeny = MAX_ZENY;
  1072. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  1073. new_zeny = 0;
  1074. if (new_zeny != pl_sd->status.zeny) {
  1075. pl_sd->status.zeny = new_zeny;
  1076. clif_updatestatus(pl_sd, SP_ZENY);
  1077. clif_displaymessage(fd, msg_table[211]); // Character's number of zenys changed!
  1078. } else {
  1079. if (zeny < 0)
  1080. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  1081. else
  1082. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  1083. return -1;
  1084. }
  1085. } else {
  1086. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1087. return -1;
  1088. }
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. * #fakename <char name> <fake name>
  1093. *------------------------------------------
  1094. */
  1095. int charcommand_fakename(
  1096. const int fd, struct map_session_data* sd,
  1097. const char* command, const char* message)
  1098. {
  1099. struct map_session_data *pl_sd;
  1100. char name[NAME_LENGTH];
  1101. char char_name[NAME_LENGTH];
  1102. nullpo_retr(-1, sd);
  1103. name[0] = '\0'; //If you don't pass a second word, name is left as garbage, most definitely not a blank name! [Skotlex]
  1104. if (!message || !*message || sscanf(message, "%23s %23[^\n]", char_name, name) < 1) {
  1105. clif_displaymessage(sd->fd,"Usage: #fakename <char name> <fake name>.");
  1106. clif_displaymessage(sd->fd,"Or: #fakename <char name> to disable.");
  1107. return 0;
  1108. }
  1109. if(!(pl_sd = map_nick2sd(char_name))) {
  1110. clif_displaymessage(sd->fd,"Character not found.");
  1111. return -1;
  1112. }
  1113. if(!name[0]) {
  1114. if(strlen(pl_sd->fakename) > 1) {
  1115. pl_sd->fakename[0]='\0';
  1116. clif_charnameack(0, &pl_sd->bl);
  1117. clif_displaymessage(sd->fd,"Returned to real name.");
  1118. } else {
  1119. clif_displaymessage(sd->fd,"Character does not has a fake name.");
  1120. }
  1121. return 0;
  1122. }
  1123. if(strlen(name) < 2) {
  1124. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  1125. return 0;
  1126. }
  1127. memcpy(pl_sd->fakename,name, NAME_LENGTH-1);
  1128. clif_charnameack(0, &pl_sd->bl);
  1129. clif_displaymessage(sd->fd,"Fake name enabled.");
  1130. return 0;
  1131. }
  1132. /*==========================================
  1133. * #baselvl <#> <nickname>
  1134. * Transferred by: Kevin
  1135. *------------------------------------------
  1136. */
  1137. int charcommand_baselevel(
  1138. const int fd, struct map_session_data* sd,
  1139. const char* command, const char* message)
  1140. {
  1141. struct map_session_data *pl_sd;
  1142. char player[NAME_LENGTH];
  1143. int level = 0, i, status_point=0;
  1144. nullpo_retr(-1, sd);
  1145. if (!message || !*message || sscanf(message, "%d %23[^\n]", &level, player) < 2 || level == 0) {
  1146. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: #baselvl <#> <nickname>).");
  1147. return -1;
  1148. }
  1149. if ((pl_sd = map_nick2sd(player)) == NULL) {
  1150. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1151. return -1;
  1152. }
  1153. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  1154. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1155. return -1;
  1156. }
  1157. if (level > 0) {
  1158. if (pl_sd->status.base_level == pc_maxbaselv(pl_sd)) { // check for max level by Valaris
  1159. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  1160. return 0;
  1161. } // End Addition
  1162. if ((unsigned int)level > pc_maxbaselv(pl_sd) ||
  1163. pl_sd->status.base_level > pc_maxbaselv(pl_sd) -level)
  1164. level = pc_maxbaselv(pl_sd) - pl_sd->status.base_level;
  1165. for (i = 1; i <= level; i++)
  1166. status_point += (pl_sd->status.base_level + i + 14) / 5;
  1167. if (pl_sd->status.status_point > USHRT_MAX - status_point)
  1168. pl_sd->status.status_point = USHRT_MAX;
  1169. else
  1170. pl_sd->status.status_point += status_point;
  1171. pl_sd->status.base_level += (unsigned int)level;
  1172. clif_updatestatus(pl_sd, SP_BASELEVEL);
  1173. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  1174. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  1175. status_calc_pc(pl_sd, 0);
  1176. status_percent_heal(&pl_sd->bl, 100, 100);
  1177. clif_misceffect(&pl_sd->bl, 0);
  1178. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  1179. } else {
  1180. if (pl_sd->status.base_level == 1) {
  1181. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  1182. return -1;
  1183. }
  1184. level *= -1;
  1185. if ((unsigned int)level >= pl_sd->status.base_level)
  1186. level = pl_sd->status.base_level -1;
  1187. for (i = 0; i > -level; i--)
  1188. status_point += (pl_sd->status.base_level +i + 14) / 5;
  1189. if (pl_sd->status.status_point < status_point)
  1190. pc_resetstate(pl_sd);
  1191. if (pl_sd->status.status_point < status_point)
  1192. pl_sd->status.status_point = 0;
  1193. else
  1194. pl_sd->status.status_point -= status_point;
  1195. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  1196. pl_sd->status.base_level -= (unsigned int)level;
  1197. clif_updatestatus(pl_sd, SP_BASELEVEL);
  1198. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  1199. status_calc_pc(pl_sd, 0);
  1200. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  1201. }
  1202. return 0; //正常終了
  1203. }
  1204. /*==========================================
  1205. * #jlvl <#> <nickname>
  1206. * Transferred by: Kevin
  1207. *------------------------------------------
  1208. */
  1209. int charcommand_joblevel(
  1210. const int fd, struct map_session_data* sd,
  1211. const char* command, const char* message)
  1212. {
  1213. struct map_session_data *pl_sd;
  1214. char player[NAME_LENGTH];
  1215. int level = 0;
  1216. //転生や養子の場合の元の職業を算出する
  1217. nullpo_retr(-1, sd);
  1218. if (!message || !*message || sscanf(message, "%d %23[^\n]", &level, player) < 2 || level == 0) {
  1219. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: #joblvl <#> <nickname>).");
  1220. return -1;
  1221. }
  1222. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1223. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  1224. if (level > 0) {
  1225. if (pl_sd->status.job_level == pc_maxjoblv(pl_sd)) {
  1226. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  1227. return -1;
  1228. }
  1229. if ((unsigned int)level > pc_maxjoblv(pl_sd) ||
  1230. pl_sd->status.job_level > pc_maxjoblv(pl_sd) -level)
  1231. level = pc_maxjoblv(pl_sd) - pl_sd->status.job_level;
  1232. pl_sd->status.job_level += (unsigned int)level;
  1233. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  1234. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  1235. if (pl_sd->status.skill_point > USHRT_MAX - level)
  1236. pl_sd->status.skill_point = USHRT_MAX;
  1237. else
  1238. pl_sd->status.skill_point += level;
  1239. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  1240. status_calc_pc(pl_sd, 0);
  1241. clif_misceffect(&pl_sd->bl, 1);
  1242. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  1243. } else {
  1244. if (pl_sd->status.job_level == 1) {
  1245. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  1246. return -1;
  1247. }
  1248. level*=-1;
  1249. if ((unsigned int)level >= pl_sd->status.job_level)
  1250. level = pl_sd->status.job_level-1;
  1251. pl_sd->status.job_level -= (unsigned int)level;
  1252. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  1253. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  1254. if (pl_sd->status.skill_point < level)
  1255. pc_resetskill(pl_sd, 0); //Need more skill points to substract
  1256. if (pl_sd->status.skill_point < level)
  1257. pl_sd->status.skill_point = 0;
  1258. else
  1259. pl_sd->status.skill_point -= level;
  1260. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  1261. status_calc_pc(pl_sd, 0);
  1262. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  1263. }
  1264. } else {
  1265. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1266. return -1;
  1267. }
  1268. } else {
  1269. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1270. return -1;
  1271. }
  1272. return 0;
  1273. }
  1274. /*==========================================
  1275. * #questskill <skill_#> <nickname>
  1276. * Transferred by: Kevin
  1277. *------------------------------------------
  1278. */
  1279. int charcommand_questskill(
  1280. const int fd, struct map_session_data* sd,
  1281. const char* command, const char* message)
  1282. {
  1283. struct map_session_data *pl_sd;
  1284. char player[NAME_LENGTH];
  1285. int skill_id = 0;
  1286. nullpo_retr(-1, sd);
  1287. if (!message || !*message || sscanf(message, "%d %23[^\n]", &skill_id, player) < 2 || skill_id < 0) {
  1288. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: #questskill <#:0+> <nickname>).");
  1289. return -1;
  1290. }
  1291. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  1292. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  1293. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1294. if (pc_checkskill(pl_sd, skill_id) == 0) {
  1295. pc_skill(pl_sd, skill_id, 1, 0);
  1296. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  1297. } else {
  1298. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  1299. return -1;
  1300. }
  1301. } else {
  1302. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1303. return -1;
  1304. }
  1305. } else {
  1306. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  1307. return -1;
  1308. }
  1309. } else {
  1310. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  1311. return -1;
  1312. }
  1313. return 0;
  1314. }
  1315. /*==========================================
  1316. * #lostskill <skill_#> <nickname>
  1317. * Transferred by: Kevin
  1318. *------------------------------------------
  1319. */
  1320. int charcommand_lostskill(
  1321. const int fd, struct map_session_data* sd,
  1322. const char* command, const char* message)
  1323. {
  1324. struct map_session_data *pl_sd;
  1325. char player[NAME_LENGTH];
  1326. int skill_id = 0;
  1327. nullpo_retr(-1, sd);
  1328. if (!message || !*message || sscanf(message, "%d %23[^\n]", &skill_id, player) < 2 || skill_id < 0) {
  1329. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  1330. return -1;
  1331. }
  1332. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  1333. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  1334. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1335. if (pc_checkskill(pl_sd, skill_id) > 0) {
  1336. pl_sd->status.skill[skill_id].lv = 0;
  1337. pl_sd->status.skill[skill_id].flag = 0;
  1338. clif_skillinfoblock(pl_sd);
  1339. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  1340. } else {
  1341. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  1342. return -1;
  1343. }
  1344. } else {
  1345. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1346. return -1;
  1347. }
  1348. } else {
  1349. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  1350. return -1;
  1351. }
  1352. } else {
  1353. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  1354. return -1;
  1355. }
  1356. return 0;
  1357. }
  1358. /*==========================================
  1359. * Character Skill Reset
  1360. *------------------------------------------
  1361. */
  1362. int charcommand_skreset(
  1363. const int fd, struct map_session_data* sd,
  1364. const char* command, const char* message)
  1365. {
  1366. struct map_session_data *pl_sd;
  1367. char player[NAME_LENGTH];
  1368. char tmp_cmdoutput[1024];
  1369. nullpo_retr(-1, sd);
  1370. if (!message || !*message || sscanf(message, "%23[^\n]", player) < 1) {
  1371. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  1372. return -1;
  1373. }
  1374. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1375. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  1376. pc_resetskill(pl_sd,1);
  1377. sprintf(tmp_cmdoutput, msg_table[206], player); // '%s' skill points reseted!
  1378. clif_displaymessage(fd, tmp_cmdoutput);
  1379. } else {
  1380. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1381. return -1;
  1382. }
  1383. } else {
  1384. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1385. return -1;
  1386. }
  1387. return 0;
  1388. }
  1389. /*==========================================
  1390. * Character Stat Reset
  1391. *------------------------------------------
  1392. */
  1393. int charcommand_streset(
  1394. const int fd, struct map_session_data* sd,
  1395. const char* command, const char* message)
  1396. {
  1397. struct map_session_data *pl_sd;
  1398. char player[NAME_LENGTH];
  1399. char tmp_cmdoutput[1024];
  1400. nullpo_retr(-1, sd);
  1401. if (!message || !*message || sscanf(message, "%23[^\n]", player) < 1) {
  1402. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  1403. return -1;
  1404. }
  1405. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1406. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  1407. pc_resetstate(pl_sd);
  1408. sprintf(tmp_cmdoutput, msg_table[207], player); // '%s' stats points reseted!
  1409. clif_displaymessage(fd, tmp_cmdoutput);
  1410. } else {
  1411. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1412. return -1;
  1413. }
  1414. } else {
  1415. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1416. return -1;
  1417. }
  1418. return 0;
  1419. }
  1420. /*==========================================
  1421. * Character Model by chbrules
  1422. *------------------------------------------
  1423. */
  1424. int charcommand_model(
  1425. const int fd, struct map_session_data* sd,
  1426. const char* command, const char* message)
  1427. {
  1428. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1429. struct map_session_data *pl_sd;
  1430. char player[NAME_LENGTH];
  1431. char tmp_cmdoutput[1024];
  1432. nullpo_retr(-1, sd);
  1433. if (!message || !*message || sscanf(message, "%d %d %d %23[^\n]", &hair_style, &hair_color, &cloth_color, player) < 4 || hair_style < 0 || hair_color < 0 || cloth_color < 0) {
  1434. sprintf(tmp_cmdoutput, "Please, enter a valid model and a player name (usage: @charmodel <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d> <name>).",
  1435. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1436. clif_displaymessage(fd, tmp_cmdoutput);
  1437. return -1;
  1438. }
  1439. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1440. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1441. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1442. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1443. /* Removed this check for being too strange. [Skotlex]
  1444. if (cloth_color != 0 &&
  1445. pl_sd->status.sex == 1 &&
  1446. (pl_sd->status.class_ == JOB_ASSASSIN || pl_sd->status.class_ == JOB_ROGUE)) {
  1447. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  1448. return -1;
  1449. } else {
  1450. */
  1451. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  1452. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  1453. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  1454. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  1455. // }
  1456. } else {
  1457. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  1458. return -1;
  1459. }
  1460. } else {
  1461. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1462. return -1;
  1463. }
  1464. return 0;
  1465. }
  1466. /*==========================================
  1467. * Character Skill Point (Rewritten by [Yor])
  1468. *------------------------------------------
  1469. */
  1470. int charcommand_skpoint(
  1471. const int fd, struct map_session_data* sd,
  1472. const char* command, const char* message)
  1473. {
  1474. struct map_session_data *pl_sd;
  1475. char player[NAME_LENGTH];
  1476. int new_skill_point;
  1477. int point = 0;
  1478. nullpo_retr(-1, sd);
  1479. if (!message || !*message || sscanf(message, "%d %23[^\n]", &point, player) < 2 || point == 0) {
  1480. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  1481. return -1;
  1482. }
  1483. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1484. if (point > 0 && pl_sd->status.skill_point > USHRT_MAX - point)
  1485. new_skill_point = USHRT_MAX;
  1486. else if (point < 0 && pl_sd->status.skill_point < -point)
  1487. new_skill_point = 0;
  1488. else
  1489. new_skill_point = pl_sd->status.skill_point + point;
  1490. if (new_skill_point != (int)pl_sd->status.skill_point) {
  1491. pl_sd->status.skill_point = new_skill_point;
  1492. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  1493. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  1494. } else {
  1495. if (point < 0)
  1496. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  1497. else
  1498. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  1499. return -1;
  1500. }
  1501. } else {
  1502. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1503. return -1;
  1504. }
  1505. return 0;
  1506. }
  1507. /*==========================================
  1508. * Character Status Point (rewritten by [Yor])
  1509. *------------------------------------------
  1510. */
  1511. int charcommand_stpoint(
  1512. const int fd, struct map_session_data* sd,
  1513. const char* command, const char* message)
  1514. {
  1515. struct map_session_data *pl_sd;
  1516. char player[NAME_LENGTH];
  1517. int new_status_point;
  1518. int point = 0;
  1519. nullpo_retr(-1, sd);
  1520. if (!message || !*message || sscanf(message, "%d %23[^\n]", &point, player) < 2 || point == 0) {
  1521. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  1522. return -1;
  1523. }
  1524. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1525. if (point > 0 && pl_sd->status.status_point > USHRT_MAX - point)
  1526. new_status_point = USHRT_MAX;
  1527. else if (point < 0 && pl_sd->status.status_point < -point)
  1528. new_status_point = 0;
  1529. else
  1530. new_status_point = pl_sd->status.status_point + point;
  1531. if (new_status_point != (int)pl_sd->status.status_point) {
  1532. pl_sd->status.status_point = new_status_point;
  1533. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  1534. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  1535. } else {
  1536. if (point < 0)
  1537. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  1538. else
  1539. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  1540. return -1;
  1541. }
  1542. } else {
  1543. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1544. return -1;
  1545. }
  1546. return 0;
  1547. }
  1548. /*==========================================
  1549. * charchangesex command (usage: charchangesex <player_name>)
  1550. *------------------------------------------
  1551. */
  1552. int charcommand_changesex(
  1553. const int fd, struct map_session_data* sd,
  1554. const char* command, const char* message)
  1555. {
  1556. char player[NAME_LENGTH];
  1557. nullpo_retr(-1, sd);
  1558. if (!message || !*message || sscanf(message, "%23[^\n]", player) < 1) {
  1559. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  1560. return -1;
  1561. }
  1562. // check player name
  1563. if (strlen(player) < 4) {
  1564. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  1565. return -1;
  1566. } else if (strlen(player) > 23) {
  1567. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  1568. return -1;
  1569. } else {
  1570. chrif_char_ask_name(sd->status.account_id, player, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  1571. clif_displaymessage(fd, msg_table[88]); // Character name sent to char-server to ask it.
  1572. }
  1573. return 0;
  1574. }
  1575. /*==========================================
  1576. * Feel (SG save map) Reset
  1577. *------------------------------------------
  1578. */
  1579. int charcommand_feelreset(
  1580. const int fd, struct map_session_data* sd,
  1581. const char* command, const char* message)
  1582. {
  1583. char character[NAME_LENGTH];
  1584. char output[200];
  1585. struct map_session_data *pl_sd;
  1586. memset(character, '\0', sizeof(character));
  1587. memset(output, '\0', sizeof(output));
  1588. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1589. clif_displaymessage(fd, "Please, enter a player name (usage: #feelreset <charname>).");
  1590. return -1;
  1591. }
  1592. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1593. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset a character only for lower or same GM level
  1594. pc_resetfeel(pl_sd);
  1595. sprintf(output, msg_table[267], character); // '%s' designated maps reseted!
  1596. clif_displaymessage(fd, output);
  1597. } else {
  1598. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1599. return -1;
  1600. }
  1601. } else {
  1602. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1603. return -1;
  1604. }
  1605. return 0;
  1606. }
  1607. /*==========================================
  1608. * #help - Char commands [Kayla]
  1609. *------------------------------------------
  1610. */
  1611. int charcommand_help(
  1612. const int fd, struct map_session_data* sd,
  1613. const char* command, const char* message)
  1614. {
  1615. char buf[2048], w1[2048], w2[2048];
  1616. int i, gm_level;
  1617. FILE* fp;
  1618. nullpo_retr(-1, sd);
  1619. memset(buf, '\0', sizeof(buf));
  1620. if ((fp = fopen(charhelp_txt, "r")) != NULL) {
  1621. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  1622. gm_level = pc_isGM(sd);
  1623. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  1624. if (buf[0] == '/' && buf[1] == '/')
  1625. continue;
  1626. for (i = 0; buf[i] != '\0'; i++) {
  1627. if (buf[i] == '\r' || buf[i] == '\n') {
  1628. buf[i] = '\0';
  1629. break;
  1630. }
  1631. }
  1632. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1633. clif_displaymessage(fd, buf);
  1634. else if (gm_level >= atoi(w1))
  1635. clif_displaymessage(fd, w2);
  1636. }
  1637. fclose(fp);
  1638. } else {
  1639. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  1640. return -1;
  1641. }
  1642. return 0;
  1643. }