charcommand.c 61 KB

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