charcommand.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <math.h>
  6. #include "../common/socket.h"
  7. #include "../common/timer.h"
  8. #include "../common/nullpo.h"
  9. #include "log.h"
  10. #include "clif.h"
  11. #include "chrif.h"
  12. #include "intif.h"
  13. #include "itemdb.h"
  14. #include "map.h"
  15. #include "pc.h"
  16. #include "status.h"
  17. #include "skill.h"
  18. #include "mob.h"
  19. #include "pet.h"
  20. #include "battle.h"
  21. #include "party.h"
  22. #include "guild.h"
  23. #include "charcommand.h"
  24. #include "atcommand.h"
  25. #include "script.h"
  26. #include "npc.h"
  27. #include "trade.h"
  28. #include "core.h"
  29. #include "showmsg.h"
  30. static char command_symbol = '#';
  31. extern char *msg_table[1000]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  32. #define CCMD_FUNC(x) int charcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  33. CCMD_FUNC(jobchange);
  34. CCMD_FUNC(petrename);
  35. CCMD_FUNC(petfriendly);
  36. CCMD_FUNC(stats);
  37. CCMD_FUNC(option);
  38. CCMD_FUNC(save);
  39. CCMD_FUNC(stats_all);
  40. CCMD_FUNC(reset);
  41. CCMD_FUNC(spiritball);
  42. CCMD_FUNC(itemlist);
  43. CCMD_FUNC(effect);
  44. CCMD_FUNC(storagelist);
  45. CCMD_FUNC(item);
  46. CCMD_FUNC(warp);
  47. CCMD_FUNC(zeny);
  48. CCMD_FUNC(showexp);
  49. CCMD_FUNC(showdelay);
  50. #ifdef TXT_ONLY
  51. /* TXT_ONLY */
  52. /* TXT_ONLY */
  53. #else
  54. /* SQL-only */
  55. /* SQL Only */
  56. #endif
  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. { CharCommandShowExp, "#showexp", 0, charcommand_showexp},
  83. { CharCommandShowDelay, "#showdelay", 0, charcommand_showdelay},
  84. #ifdef TXT_ONLY
  85. /* TXT_ONLY */
  86. /* TXT_ONLY */
  87. #else
  88. /* SQL-only */
  89. /* SQL Only */
  90. #endif
  91. // add new commands before this line
  92. { CharCommand_Unknown, NULL, 1, NULL }
  93. };
  94. int get_charcommand_level(const CharCommandType type) {
  95. int i;
  96. for (i = 0; charcommand_info[i].type != CharCommand_None; i++)
  97. if (charcommand_info[i].type == type)
  98. return charcommand_info[i].level;
  99. return 100; // 100: command can not be used
  100. }
  101. /*==========================================
  102. *is_charcommand @コマンドに存在するかどうか確認する
  103. *------------------------------------------
  104. */
  105. CharCommandType
  106. is_charcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  107. const char* str = message;
  108. int s_flag = 0;
  109. CharCommandInfo info;
  110. CharCommandType type;
  111. nullpo_retr(CharCommand_None, sd);
  112. if (!message || !*message)
  113. return CharCommand_None;
  114. memset(&info, 0, sizeof(info));
  115. str += strlen(sd->status.name);
  116. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  117. if (*str == ':')
  118. s_flag = 1;
  119. str++;
  120. }
  121. if (!*str)
  122. return CharCommand_None;
  123. type = charcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  124. if (type != CharCommand_None) {
  125. char command[100];
  126. char output[200];
  127. const char* p = str;
  128. memset(command, '\0', sizeof(command));
  129. memset(output, '\0', sizeof(output));
  130. while (*p && !isspace(*p))
  131. p++;
  132. if (p - str >= sizeof(command)) // too long
  133. return CharCommand_Unknown;
  134. strncpy(command, str, p - str);
  135. while (isspace(*p))
  136. p++;
  137. if (type == CharCommand_Unknown || info.proc == NULL) {
  138. snprintf(output, sizeof(output),msg_txt(153), command); // %s is Unknown Command.
  139. clif_displaymessage(fd, output);
  140. } else {
  141. if (info.proc(fd, sd, command, p) != 0) {
  142. // Command can not be executed
  143. snprintf(output, sizeof(output), msg_txt(154), command); // %s failed.
  144. clif_displaymessage(fd, output);
  145. }
  146. }
  147. return info.type;
  148. }
  149. return CharCommand_None;
  150. }
  151. /*==========================================
  152. *
  153. *------------------------------------------
  154. */
  155. CharCommandType charcommand(const int level, const char* message, struct CharCommandInfo* info) {
  156. char* p = (char *)message;
  157. if (!info)
  158. return CharCommand_None;
  159. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  160. return CharCommand_None;
  161. if (!p || !*p) {
  162. fprintf(stderr, "char command message is empty\n");
  163. return CharCommand_None;
  164. }
  165. if (*p == command_symbol) { // check first char.
  166. char command[101];
  167. int i = 0;
  168. memset(info, 0, sizeof(CharCommandInfo));
  169. sscanf(p, "%100s", command);
  170. command[sizeof(command)-1] = '\0';
  171. while (charcommand_info[i].type != CharCommand_Unknown) {
  172. if (strcmpi(command+1, charcommand_info[i].command+1) == 0 && level >= charcommand_info[i].level) {
  173. p[0] = charcommand_info[i].command[0]; // set correct first symbol for after.
  174. break;
  175. }
  176. i++;
  177. }
  178. if (charcommand_info[i].type == CharCommand_Unknown) {
  179. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  180. if (level == 0)
  181. return CharCommand_None;
  182. else
  183. return CharCommand_Unknown;
  184. }
  185. memcpy(info, &charcommand_info[i], sizeof charcommand_info[i]);
  186. } else {
  187. return CharCommand_None;
  188. }
  189. return info->type;
  190. }
  191. /*==========================================
  192. *
  193. *------------------------------------------
  194. */
  195. static CharCommandInfo* get_charcommandinfo_byname(const char* name) {
  196. int i;
  197. for (i = 0; charcommand_info[i].type != CharCommand_Unknown; i++)
  198. if (strcmpi(charcommand_info[i].command + 1, name) == 0)
  199. return &charcommand_info[i];
  200. return NULL;
  201. }
  202. /*==========================================
  203. *
  204. *------------------------------------------
  205. */
  206. int charcommand_config_read(const char *cfgName) {
  207. char line[1024], w1[1024], w2[1024];
  208. CharCommandInfo* p;
  209. FILE* fp;
  210. if ((fp = fopen(cfgName, "r")) == NULL) {
  211. printf("CharCommands configuration file not found: %s\n", cfgName);
  212. return 1;
  213. }
  214. while (fgets(line, sizeof(line)-1, fp)) {
  215. if (line[0] == '/' && line[1] == '/')
  216. continue;
  217. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  218. continue;
  219. p = get_charcommandinfo_byname(w1);
  220. if (p != NULL) {
  221. p->level = atoi(w2);
  222. if (p->level > 100)
  223. p->level = 100;
  224. else if (p->level < 0)
  225. p->level = 0;
  226. }
  227. if (strcmpi(w1, "import") == 0)
  228. charcommand_config_read(w2);
  229. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  230. w2[0] != '/' && // symbol of standard ragnarok GM commands
  231. w2[0] != '%' // symbol of party chat speaking
  232. )
  233. command_symbol = w2[0];
  234. }
  235. fclose(fp);
  236. return 0;
  237. }
  238. /*==========================================
  239. * 対象キャラクターを転職させる upper指定で転生や養子も可能
  240. *------------------------------------------
  241. */
  242. int charcommand_jobchange(
  243. const int fd, struct map_session_data* sd,
  244. const char* command, const char* message)
  245. {
  246. char character[100];
  247. struct map_session_data* pl_sd;
  248. int job = 0, upper = -1;
  249. memset(character, '\0', sizeof(character));
  250. if (!message || !*message) {
  251. clif_displaymessage(fd, "Please, enter a job and a player name (usage: #job/#jobchange <job ID> <char name>).");
  252. return -1;
  253. }
  254. if (sscanf(message, "%d %d %99[^\n]", &job, &upper, character) < 3) { //upper指定してある
  255. upper = -1;
  256. if (sscanf(message, "%d %99[^\n]", &job, character) < 2) { //upper指定してない上に何か足りない
  257. clif_displaymessage(fd, "Please, enter a job and a player name (usage: #job/#jobchange <job ID> <char name>).");
  258. return -1;
  259. }
  260. }
  261. if ((pl_sd = map_nick2sd(character)) != NULL) {
  262. int j;
  263. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job only to lower or same level
  264. if ((job >= 0 && job < MAX_PC_CLASS)) {
  265. // fix pecopeco display
  266. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  267. if (pc_isriding(sd)) {
  268. if (pl_sd->status.class_ == 13)
  269. pl_sd->status.class_ = pl_sd->view_class = 7;
  270. if (pl_sd->status.class_ == 21)
  271. pl_sd->status.class_ = pl_sd->view_class = 14;
  272. if (pl_sd->status.class_ == 4014)
  273. pl_sd->status.class_ = pl_sd->view_class = 4008;
  274. if (pl_sd->status.class_ == 4022)
  275. pl_sd->status.class_ = pl_sd->view_class = 4015;
  276. pl_sd->status.option &= ~0x0020;
  277. clif_changeoption(&pl_sd->bl);
  278. status_calc_pc(pl_sd, 0);
  279. }
  280. } else {
  281. if (!pc_isriding(sd)) {
  282. if (job == 13)
  283. job = 7;
  284. if (job == 21)
  285. job = 14;
  286. if (job == 4014)
  287. job = 4008;
  288. if (job == 4022)
  289. job = 4015;
  290. }
  291. }
  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[100];
  325. struct map_session_data *pl_sd;
  326. memset(character, '\0', sizeof(character));
  327. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  328. clif_displaymessage(fd, "Please, enter a player name (usage: #petrename <char name>).");
  329. return -1;
  330. }
  331. if ((pl_sd = map_nick2sd(character)) != NULL) {
  332. if (pl_sd->status.pet_id > 0 && pl_sd->pd) {
  333. if (pl_sd->pet.rename_flag != 0) {
  334. pl_sd->pet.rename_flag = 0;
  335. intif_save_petdata(pl_sd->status.account_id, &pl_sd->pet);
  336. clif_send_petstatus(pl_sd);
  337. clif_displaymessage(fd, msg_table[189]); // This player can now rename his/her pet.
  338. } else {
  339. clif_displaymessage(fd, msg_table[190]); // This player can already rename his/her pet.
  340. return -1;
  341. }
  342. } else {
  343. clif_displaymessage(fd, msg_table[191]); // Sorry, but this player has no pet.
  344. return -1;
  345. }
  346. } else {
  347. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  348. return -1;
  349. }
  350. return 0;
  351. }
  352. /*==========================================
  353. *
  354. *------------------------------------------
  355. */
  356. int charcommand_petfriendly(
  357. const int fd, struct map_session_data* sd,
  358. const char* command, const char* message)
  359. {
  360. int friendly = 0;
  361. int t = 0;
  362. char character[100];
  363. struct map_session_data *pl_sd;
  364. memset(character, '\0', sizeof(character));
  365. if (!message || !*message || sscanf(message,"%d %s",&friendly,character) < 2) {
  366. clif_displaymessage(fd, "Please, enter a valid value (usage: "
  367. "#petfriendly <0-1000> <player>).");
  368. return -1;
  369. }
  370. if (((pl_sd = map_nick2sd(character)) != NULL) && pc_isGM(sd)>pc_isGM(pl_sd)) {
  371. if (pl_sd->status.pet_id > 0 && pl_sd->pd) {
  372. if (friendly >= 0 && friendly <= 1000) {
  373. if (friendly != pl_sd->pet.intimate) {
  374. t = pl_sd->pet.intimate;
  375. pl_sd->pet.intimate = friendly;
  376. clif_send_petstatus(pl_sd);
  377. clif_pet_emotion(pl_sd->pd,0);
  378. if (battle_config.pet_status_support) {
  379. if ((pl_sd->pet.intimate > 0 && t <= 0) ||
  380. (pl_sd->pet.intimate <= 0 && t > 0)) {
  381. if (pl_sd->bl.prev != NULL)
  382. status_calc_pc(pl_sd, 0);
  383. else
  384. status_calc_pc(pl_sd, 2);
  385. }
  386. }
  387. clif_displaymessage(pl_sd->fd, msg_table[182]); // Pet friendly value changed!
  388. clif_displaymessage(sd->fd, msg_table[182]); // Pet friendly value changed!
  389. } else {
  390. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  391. return -1;
  392. }
  393. } else {
  394. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  395. return -1;
  396. }
  397. } else {
  398. return -1;
  399. }
  400. } else {
  401. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  402. return -1;
  403. }
  404. return 0;
  405. }
  406. /*==========================================
  407. *
  408. *------------------------------------------
  409. */
  410. int charcommand_stats(
  411. const int fd, struct map_session_data* sd,
  412. const char* command, const char* message)
  413. {
  414. char character[100];
  415. char job_jobname[100];
  416. char output[200];
  417. struct map_session_data *pl_sd;
  418. int i;
  419. memset(character, '\0', sizeof(character));
  420. memset(job_jobname, '\0', sizeof(job_jobname));
  421. memset(output, '\0', sizeof(output));
  422. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  423. clif_displaymessage(fd, "Please, enter a player name (usage: #stats <char name>).");
  424. return -1;
  425. }
  426. if ((pl_sd = map_nick2sd(character)) != NULL) {
  427. struct {
  428. const char* format;
  429. int value;
  430. } output_table[] = {
  431. { "Base Level - %d", pl_sd->status.base_level },
  432. { job_jobname, pl_sd->status.job_level },
  433. { "Hp - %d", pl_sd->status.hp },
  434. { "MaxHp - %d", pl_sd->status.max_hp },
  435. { "Sp - %d", pl_sd->status.sp },
  436. { "MaxSp - %d", pl_sd->status.max_sp },
  437. { "Str - %3d", pl_sd->status.str },
  438. { "Agi - %3d", pl_sd->status.agi },
  439. { "Vit - %3d", pl_sd->status.vit },
  440. { "Int - %3d", pl_sd->status.int_ },
  441. { "Dex - %3d", pl_sd->status.dex },
  442. { "Luk - %3d", pl_sd->status.luk },
  443. { "Zeny - %d", pl_sd->status.zeny },
  444. { NULL, 0 }
  445. };
  446. sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class_), "(level %d)");
  447. sprintf(output, msg_table[53], pl_sd->status.name); // '%s' stats:
  448. clif_displaymessage(fd, output);
  449. for (i = 0; output_table[i].format != NULL; i++) {
  450. sprintf(output, output_table[i].format, output_table[i].value);
  451. clif_displaymessage(fd, output);
  452. }
  453. } else {
  454. clif_displaymessage(fd, msg_table[3]); // Character not found.
  455. return -1;
  456. }
  457. return 0;
  458. }
  459. /*==========================================
  460. * Character Reset
  461. *------------------------------------------
  462. */
  463. int charcommand_reset(
  464. const int fd, struct map_session_data* sd,
  465. const char* command, const char* message)
  466. {
  467. char character[100];
  468. char output[200];
  469. struct map_session_data *pl_sd;
  470. memset(character, '\0', sizeof(character));
  471. memset(output, '\0', sizeof(output));
  472. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  473. clif_displaymessage(fd, "Please, enter a player name (usage: #reset <charname>).");
  474. return -1;
  475. }
  476. if ((pl_sd = map_nick2sd(character)) != NULL) {
  477. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset a character only for lower or same GM level
  478. pc_resetstate(pl_sd);
  479. pc_resetskill(pl_sd);
  480. sprintf(output, msg_table[208], character); // '%s' skill and stats points reseted!
  481. clif_displaymessage(fd, output);
  482. } else {
  483. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  484. return -1;
  485. }
  486. } else {
  487. clif_displaymessage(fd, msg_table[3]); // Character not found.
  488. return -1;
  489. }
  490. return 0;
  491. }
  492. /*==========================================
  493. *
  494. *------------------------------------------
  495. */
  496. int charcommand_option(
  497. const int fd, struct map_session_data* sd,
  498. const char* command, const char* message)
  499. {
  500. char character[100];
  501. int opt1 = 0, opt2 = 0, opt3 = 0;
  502. struct map_session_data* pl_sd;
  503. memset(character, '\0', sizeof(character));
  504. if (!message || !*message ||
  505. sscanf(message, "%d %d %d %99[^\n]", &opt1, &opt2, &opt3, character) < 4 ||
  506. opt1 < 0 || opt2 < 0 || opt3 < 0) {
  507. clif_displaymessage(fd, "Please, enter valid options and a player name (usage: #option <param1> <param2> <param3> <charname>).");
  508. return -1;
  509. }
  510. if ((pl_sd = map_nick2sd(character)) != NULL) {
  511. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change option only to lower or same level
  512. pl_sd->opt1 = opt1;
  513. pl_sd->opt2 = opt2;
  514. pl_sd->status.option = opt3;
  515. // fix pecopeco display
  516. if (pl_sd->status.class_ == 13 || pl_sd->status.class_ == 21 || pl_sd->status.class_ == 4014 || pl_sd->status.class_ == 4022) {
  517. if (!pc_isriding(pl_sd)) { // pl_sd have the new value...
  518. if (pl_sd->status.class_ == 13)
  519. pl_sd->status.class_ = pl_sd->view_class = 7;
  520. else if (pl_sd->status.class_ == 21)
  521. pl_sd->status.class_ = pl_sd->view_class = 14;
  522. else if (pl_sd->status.class_ == 4014)
  523. pl_sd->status.class_ = pl_sd->view_class = 4008;
  524. else if (pl_sd->status.class_ == 4022)
  525. pl_sd->status.class_ = pl_sd->view_class = 4015;
  526. }
  527. } else {
  528. if (pc_isriding(pl_sd)) { // pl_sd have the new value...
  529. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  530. pl_sd->status.option &= ~0x0020;
  531. } else {
  532. if (pl_sd->status.class_ == 7)
  533. pl_sd->status.class_ = pl_sd->view_class = 13;
  534. else if (pl_sd->status.class_ == 14)
  535. pl_sd->status.class_ = pl_sd->view_class = 21;
  536. else if (pl_sd->status.class_ == 4008)
  537. pl_sd->status.class_ = pl_sd->view_class = 4014;
  538. else if (pl_sd->status.class_ == 4015)
  539. pl_sd->status.class_ = pl_sd->view_class = 4022;
  540. else
  541. pl_sd->status.option &= ~0x0020;
  542. }
  543. }
  544. }
  545. clif_changeoption(&pl_sd->bl);
  546. status_calc_pc(pl_sd, 0);
  547. clif_displaymessage(fd, msg_table[58]); // Character's options changed.
  548. } else {
  549. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  550. return -1;
  551. }
  552. } else {
  553. clif_displaymessage(fd, msg_table[3]); // Character not found.
  554. return -1;
  555. }
  556. return 0;
  557. }
  558. /*==========================================
  559. *
  560. *------------------------------------------
  561. */
  562. int charcommand_save(
  563. const int fd, struct map_session_data* sd,
  564. const char* command, const char* message)
  565. {
  566. char map_name[100];
  567. char character[100];
  568. struct map_session_data* pl_sd;
  569. int x = 0, y = 0;
  570. int m;
  571. memset(map_name, '\0', sizeof(map_name));
  572. memset(character, '\0', sizeof(character));
  573. if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4 || x < 0 || y < 0) {
  574. clif_displaymessage(fd, "Please, enter a valid save point and a player name (usage: #save <map> <x> <y> <charname>).");
  575. return -1;
  576. }
  577. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  578. strcat(map_name, ".gat");
  579. if ((pl_sd = map_nick2sd(character)) != NULL) {
  580. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change save point only to lower or same gm level
  581. m = map_mapname2mapid(map_name);
  582. if (m < 0) {
  583. clif_displaymessage(fd, msg_table[1]); // Map not found.
  584. return -1;
  585. } else {
  586. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  587. clif_displaymessage(fd, "You are not authorised to set this map as a save map.");
  588. return -1;
  589. }
  590. pc_setsavepoint(pl_sd, map_name, x, y);
  591. clif_displaymessage(fd, msg_table[57]); // Character's respawn point changed.
  592. }
  593. } else {
  594. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  595. return -1;
  596. }
  597. } else {
  598. clif_displaymessage(fd, msg_table[3]); // Character not found.
  599. return -1;
  600. }
  601. return 0;
  602. }
  603. /*==========================================
  604. *
  605. *------------------------------------------
  606. */
  607. //** Character Stats All by fritz
  608. int charcommand_stats_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  609. {
  610. char output[1024], gmlevel[1024];
  611. int i;
  612. int count;
  613. struct map_session_data *pl_sd;
  614. memset(output, '\0', sizeof(output));
  615. memset(gmlevel, '\0', sizeof(gmlevel));
  616. count = 0;
  617. for(i = 0; i < fd_max; i++) {
  618. if (session[i] && (pl_sd = (struct map_session_data *) session[i]->session_data) && pl_sd->state.auth) {
  619. if (pc_isGM(pl_sd) > 0)
  620. sprintf(gmlevel, "| GM Lvl: %d", pc_isGM(pl_sd));
  621. else
  622. sprintf(gmlevel, " ");
  623. 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);
  624. clif_displaymessage(fd, output);
  625. 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);
  626. clif_displaymessage(fd, output);
  627. clif_displaymessage(fd, "--------");
  628. count++;
  629. }
  630. }
  631. if (count == 0)
  632. clif_displaymessage(fd, msg_table[28]); // No player found.
  633. else if (count == 1)
  634. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  635. else {
  636. sprintf(output, msg_table[30], count); // %d players found.
  637. clif_displaymessage(fd, output);
  638. }
  639. return 0;
  640. }
  641. /*==========================================
  642. * CharSpiritBall Function by PalasX
  643. *------------------------------------------
  644. */
  645. int charcommand_spiritball(const int fd, struct map_session_data* sd,const char* command, const char* message)
  646. {
  647. struct map_session_data *pl_sd;
  648. char character[100];
  649. int spirit = 0;
  650. memset(character, '\0', sizeof(character));
  651. if(!message || !*message || sscanf(message, "%d %99[^\n]", &spirit, character) < 2 || spirit < 0 || spirit > 1000) {
  652. clif_displaymessage(fd, "Usage: @spiritball <number: 0-1000>) <CHARACTER_NAME>.");
  653. return -1;
  654. }
  655. if((pl_sd = map_nick2sd(character)) != NULL) {
  656. if (spirit >= 0 && spirit <= 0x7FFF) {
  657. if (pl_sd->spiritball != spirit || spirit > 999) {
  658. if (pl_sd->spiritball > 0)
  659. pc_delspiritball(pl_sd, pl_sd->spiritball, 1);
  660. pl_sd->spiritball = spirit;
  661. clif_spiritball(pl_sd);
  662. // no message, player can look the difference
  663. if (spirit > 1000)
  664. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  665. } else {
  666. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  667. return -1;
  668. }
  669. } else {
  670. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  671. return -1;
  672. }
  673. } else {
  674. clif_displaymessage(fd, msg_table[3]); // Character not found.
  675. return -1;
  676. }
  677. return 0;
  678. }
  679. /*==========================================
  680. * #itemlist <character>: Displays the list of a player's items.
  681. *------------------------------------------
  682. */
  683. int
  684. charcommand_itemlist(
  685. const int fd, struct map_session_data* sd,
  686. const char* command, const char* message)
  687. {
  688. struct map_session_data *pl_sd;
  689. struct item_data *item_data, *item_temp;
  690. int i, j, equip, count, counter, counter2;
  691. char character[100], output[200], equipstr[100], outputtmp[200];
  692. nullpo_retr(-1, sd);
  693. memset(character, '\0', sizeof(character));
  694. memset(output, '\0', sizeof(output));
  695. memset(equipstr, '\0', sizeof(equipstr));
  696. memset(outputtmp, '\0', sizeof(outputtmp));
  697. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  698. clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
  699. return -1;
  700. }
  701. if ((pl_sd = map_nick2sd(character)) != NULL) {
  702. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  703. counter = 0;
  704. count = 0;
  705. for (i = 0; i < MAX_INVENTORY; i++) {
  706. if (pl_sd->status.inventory[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.inventory[i].nameid)) != NULL) {
  707. counter = counter + pl_sd->status.inventory[i].amount;
  708. count++;
  709. if (count == 1) {
  710. sprintf(output, "------ Items list of '%s' ------", pl_sd->status.name);
  711. clif_displaymessage(fd, output);
  712. }
  713. if ((equip = pl_sd->status.inventory[i].equip)) {
  714. strcpy(equipstr, "| equiped: ");
  715. if (equip & 4)
  716. strcat(equipstr, "robe/gargment, ");
  717. if (equip & 8)
  718. strcat(equipstr, "left accessory, ");
  719. if (equip & 16)
  720. strcat(equipstr, "body/armor, ");
  721. if ((equip & 34) == 2)
  722. strcat(equipstr, "right hand, ");
  723. if ((equip & 34) == 32)
  724. strcat(equipstr, "left hand, ");
  725. if ((equip & 34) == 34)
  726. strcat(equipstr, "both hands, ");
  727. if (equip & 64)
  728. strcat(equipstr, "feet, ");
  729. if (equip & 128)
  730. strcat(equipstr, "right accessory, ");
  731. if ((equip & 769) == 1)
  732. strcat(equipstr, "lower head, ");
  733. if ((equip & 769) == 256)
  734. strcat(equipstr, "top head, ");
  735. if ((equip & 769) == 257)
  736. strcat(equipstr, "lower/top head, ");
  737. if ((equip & 769) == 512)
  738. strcat(equipstr, "mid head, ");
  739. if ((equip & 769) == 512)
  740. strcat(equipstr, "lower/mid head, ");
  741. if ((equip & 769) == 769)
  742. strcat(equipstr, "lower/mid/top head, ");
  743. // remove final ', '
  744. equipstr[strlen(equipstr) - 2] = '\0';
  745. } else
  746. memset(equipstr, '\0', sizeof(equipstr));
  747. if (sd->status.inventory[i].refine)
  748. sprintf(output, "%d %s %+d (%s %+d, id: %d) %s", pl_sd->status.inventory[i].amount, item_data->name, pl_sd->status.inventory[i].refine, item_data->jname, pl_sd->status.inventory[i].refine, pl_sd->status.inventory[i].nameid, equipstr);
  749. else
  750. sprintf(output, "%d %s (%s, id: %d) %s", pl_sd->status.inventory[i].amount, item_data->name, item_data->jname, pl_sd->status.inventory[i].nameid, equipstr);
  751. clif_displaymessage(fd, output);
  752. memset(output, '\0', sizeof(output));
  753. counter2 = 0;
  754. for (j = 0; j < item_data->slot; j++) {
  755. if (pl_sd->status.inventory[i].card[j]) {
  756. if ((item_temp = itemdb_search(pl_sd->status.inventory[i].card[j])) != NULL) {
  757. if (output[0] == '\0')
  758. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  759. else
  760. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  761. strcat(output, outputtmp);
  762. }
  763. }
  764. }
  765. if (output[0] != '\0') {
  766. output[strlen(output) - 2] = ')';
  767. output[strlen(output) - 1] = '\0';
  768. clif_displaymessage(fd, output);
  769. }
  770. }
  771. }
  772. if (count == 0)
  773. clif_displaymessage(fd, "No item found on this player.");
  774. else {
  775. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  776. clif_displaymessage(fd, output);
  777. }
  778. } else {
  779. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  780. return -1;
  781. }
  782. } else {
  783. clif_displaymessage(fd, msg_table[3]); // Character not found.
  784. return -1;
  785. }
  786. return 0;
  787. }
  788. /*==========================================
  789. * #effect by [MouseJstr]
  790. *
  791. * Create a effect localized on another character
  792. *------------------------------------------
  793. */
  794. int
  795. charcommand_effect(const int fd, struct map_session_data* sd,
  796. const char* command, const char* message)
  797. {
  798. struct map_session_data *pl_sd = NULL;
  799. char target[255];
  800. int type = 0;
  801. nullpo_retr(-1, sd);
  802. if (!message || !*message || sscanf(message, "%d %s", &type, target) != 2) {
  803. clif_displaymessage(fd, "usage: #effect <type+> <target>.");
  804. return -1;
  805. }
  806. if((pl_sd=map_nick2sd((char *) target)) == NULL)
  807. return -1;
  808. clif_specialeffect(&pl_sd->bl, type, 0);
  809. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  810. return 0;
  811. }
  812. /*==========================================
  813. * #storagelist <character>: Displays the items list of a player's storage.
  814. *------------------------------------------
  815. */
  816. int
  817. charcommand_storagelist(
  818. const int fd, struct map_session_data* sd,
  819. const char* command, const char* message)
  820. {
  821. struct storage *stor;
  822. struct map_session_data *pl_sd;
  823. struct item_data *item_data, *item_temp;
  824. int i, j, count, counter, counter2;
  825. char character[100], output[200], outputtmp[200];
  826. nullpo_retr(-1, sd);
  827. memset(character, '\0', sizeof(character));
  828. memset(output, '\0', sizeof(output));
  829. memset(outputtmp, '\0', sizeof(outputtmp));
  830. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  831. clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
  832. return -1;
  833. }
  834. if ((pl_sd = map_nick2sd(character)) != NULL) {
  835. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  836. if((stor = account2storage2(pl_sd->status.account_id)) != NULL) {
  837. counter = 0;
  838. count = 0;
  839. for (i = 0; i < MAX_STORAGE; i++) {
  840. if (stor->storage_[i].nameid > 0 && (item_data = itemdb_search(stor->storage_[i].nameid)) != NULL) {
  841. counter = counter + stor->storage_[i].amount;
  842. count++;
  843. if (count == 1) {
  844. sprintf(output, "------ Storage items list of '%s' ------", pl_sd->status.name);
  845. clif_displaymessage(fd, output);
  846. }
  847. if (stor->storage_[i].refine)
  848. 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);
  849. else
  850. sprintf(output, "%d %s (%s, id: %d)", stor->storage_[i].amount, item_data->name, item_data->jname, stor->storage_[i].nameid);
  851. clif_displaymessage(fd, output);
  852. memset(output, '\0', sizeof(output));
  853. counter2 = 0;
  854. for (j = 0; j < item_data->slot; j++) {
  855. if (stor->storage_[i].card[j]) {
  856. if ((item_temp = itemdb_search(stor->storage_[i].card[j])) != NULL) {
  857. if (output[0] == '\0')
  858. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  859. else
  860. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  861. strcat(output, outputtmp);
  862. }
  863. }
  864. }
  865. if (output[0] != '\0') {
  866. output[strlen(output) - 2] = ')';
  867. output[strlen(output) - 1] = '\0';
  868. clif_displaymessage(fd, output);
  869. }
  870. }
  871. }
  872. if (count == 0)
  873. clif_displaymessage(fd, "No item found in the storage of this player.");
  874. else {
  875. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  876. clif_displaymessage(fd, output);
  877. }
  878. } else {
  879. clif_displaymessage(fd, "This player has no storage.");
  880. return 0;
  881. }
  882. } else {
  883. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  884. return -1;
  885. }
  886. } else {
  887. clif_displaymessage(fd, msg_table[3]); // Character not found.
  888. return -1;
  889. }
  890. return 0;
  891. }
  892. static void
  893. charcommand_giveitem_sub(struct map_session_data *sd,struct item_data *item_data,int number)
  894. {
  895. int flag = 0;
  896. int loop = 1, get_count = number,i;
  897. struct item item_tmp;
  898. if(sd && item_data){
  899. if (item_data->type == 4 || item_data->type == 5 ||
  900. item_data->type == 7 || item_data->type == 8) {
  901. loop = number;
  902. get_count = 1;
  903. }
  904. for (i = 0; i < loop; i++) {
  905. memset(&item_tmp, 0, sizeof(item_tmp));
  906. item_tmp.nameid = item_data->nameid;
  907. item_tmp.identify = 1;
  908. if ((flag = pc_additem((struct map_session_data*)sd,
  909. &item_tmp, get_count)))
  910. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  911. }
  912. }
  913. }
  914. /*==========================================
  915. * #item command (usage: #item <name/id_of_item> <quantity> <player>)
  916. * by MC Cameri
  917. *------------------------------------------
  918. */
  919. int charcommand_item(
  920. const int fd, struct map_session_data* sd,
  921. const char* command, const char* message)
  922. {
  923. char item_name[100];
  924. char character[100];
  925. struct map_session_data *pl_sd;
  926. int number = 0, item_id, flag;
  927. struct item item_tmp;
  928. struct item_data *item_data;
  929. int get_count, i, pet_id;
  930. nullpo_retr(-1, sd);
  931. memset(item_name, '\0', sizeof(item_name));
  932. if (!message || !*message || sscanf(message, "%99s %d %99[^\n]", item_name, &number, character) < 3) {
  933. clif_displaymessage(fd, "Please, enter an item name/id (usage: #item <item name or ID> <quantity> <char name>).");
  934. return -1;
  935. }
  936. if (number <= 0)
  937. number = 1;
  938. item_id = 0;
  939. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  940. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  941. item_id = item_data->nameid;
  942. if (item_id >= 500) {
  943. get_count = number;
  944. // check pet egg
  945. pet_id = search_petDB_index(item_id, PET_EGG);
  946. if (item_data->type == 4 || item_data->type == 5 ||
  947. item_data->type == 7 || item_data->type == 8) {
  948. get_count = 1;
  949. }
  950. if ((pl_sd = map_nick2sd(character)) != NULL) {
  951. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  952. for (i = 0; i < number; i += get_count) {
  953. // if pet egg
  954. if (pet_id >= 0) {
  955. pl_sd->catch_target_class = pet_db[pet_id].class_;
  956. intif_create_pet(pl_sd->status.account_id, pl_sd->status.char_id,
  957. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  958. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  959. 100, 0, 1, pet_db[pet_id].jname);
  960. // if not pet egg
  961. } else {
  962. memset(&item_tmp, 0, sizeof(item_tmp));
  963. item_tmp.nameid = item_id;
  964. item_tmp.identify = 1;
  965. if ((flag = pc_additem(pl_sd, &item_tmp, get_count)))
  966. clif_additem(pl_sd, 0, 0, flag);
  967. }
  968. }
  969. clif_displaymessage(fd, msg_table[18]); // Item created.
  970. } else {
  971. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  972. return -1;
  973. }
  974. } else if(/* from jA's @giveitem */strcmpi(character,"all")==0 || strcmpi(character,"everyone")==0){
  975. for (i = 0; i < fd_max; i++) {
  976. if (session[i] && (pl_sd = (struct map_session_data *) session[i]->session_data)){
  977. charcommand_giveitem_sub(pl_sd,item_data,number);
  978. snprintf(tmp_output, sizeof(tmp_output), "You got %s %d.", item_name,number);
  979. clif_displaymessage(pl_sd->fd, tmp_output);
  980. }
  981. }
  982. snprintf(tmp_output, sizeof(tmp_output), "%s received %s %d.","Everyone",item_name,number);
  983. clif_displaymessage(fd, tmp_output);
  984. } else {
  985. clif_displaymessage(fd, msg_table[3]); // Character not found.
  986. return -1;
  987. }
  988. } else {
  989. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  990. return -1;
  991. }
  992. return 0;
  993. }
  994. /*==========================================
  995. * #warp/#rura/#rura+ <mapname> <x> <y> <char name>
  996. *------------------------------------------
  997. */
  998. int charcommand_warp(
  999. const int fd, struct map_session_data* sd,
  1000. const char* command, const char* message)
  1001. {
  1002. char map_name[100];
  1003. char character[100];
  1004. int x = 0, y = 0;
  1005. struct map_session_data *pl_sd;
  1006. int m;
  1007. nullpo_retr(-1, sd);
  1008. memset(map_name, '\0', sizeof(map_name));
  1009. memset(character, '\0', sizeof(character));
  1010. if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4) {
  1011. clif_displaymessage(fd, "Usage: #warp/#rura/#rura+ <mapname> <x> <y> <char name>");
  1012. return -1;
  1013. }
  1014. if (x <= 0)
  1015. x = rand() % 399 + 1;
  1016. if (y <= 0)
  1017. y = rand() % 399 + 1;
  1018. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1019. strcat(map_name, ".gat");
  1020. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1021. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level
  1022. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1023. m = map_mapname2mapid(map_name);
  1024. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1025. clif_displaymessage(fd, "You are not authorised to warp someone to this map.");
  1026. return -1;
  1027. }
  1028. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1029. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  1030. return -1;
  1031. }
  1032. if (pc_setpos(pl_sd, map_name, x, y, 3) == 0) {
  1033. clif_displaymessage(pl_sd->fd, msg_table[0]); // Warped.
  1034. clif_displaymessage(fd, msg_table[15]); // Player warped (message sends to player too).
  1035. } else {
  1036. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1037. return -1;
  1038. }
  1039. } else {
  1040. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1041. return -1;
  1042. }
  1043. } else {
  1044. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1045. return -1;
  1046. }
  1047. } else {
  1048. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1049. return -1;
  1050. }
  1051. return 0;
  1052. }
  1053. /*==========================================
  1054. * #zeny <charname>
  1055. *------------------------------------------
  1056. */
  1057. int charcommand_zeny(
  1058. const int fd, struct map_session_data* sd,
  1059. const char* command, const char* message)
  1060. {
  1061. struct map_session_data *pl_sd;
  1062. char character[100];
  1063. int zeny = 0, new_zeny;
  1064. nullpo_retr(-1, sd);
  1065. memset(character, '\0', sizeof(character));
  1066. if (!message || !*message || sscanf(message, "%d %99[^\n]", &zeny, character) < 2 || zeny == 0) {
  1067. clif_displaymessage(fd, "Please, enter a number and a player name (usage: #zeny <zeny> <name>).");
  1068. return -1;
  1069. }
  1070. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1071. new_zeny = pl_sd->status.zeny + zeny;
  1072. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  1073. new_zeny = MAX_ZENY;
  1074. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  1075. new_zeny = 0;
  1076. if (new_zeny != pl_sd->status.zeny) {
  1077. pl_sd->status.zeny = new_zeny;
  1078. clif_updatestatus(pl_sd, SP_ZENY);
  1079. clif_displaymessage(fd, msg_table[211]); // Character's number of zenys changed!
  1080. } else {
  1081. if (zeny < 0)
  1082. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  1083. else
  1084. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  1085. return -1;
  1086. }
  1087. } else {
  1088. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1089. return -1;
  1090. }
  1091. return 0;
  1092. }
  1093. /*===================================
  1094. * Remove some messages
  1095. *-----------------------------------
  1096. */
  1097. int charcommand_showexp(
  1098. const int fd, struct map_session_data* sd,
  1099. const char* command, const char* message)
  1100. {
  1101. if (sd->noexp) {
  1102. sd->noexp = 0;
  1103. clif_displaymessage(fd, "Gained exp is now shown");
  1104. return 0;
  1105. }
  1106. else {
  1107. sd->noexp = 1;
  1108. clif_displaymessage(fd, "Gained exp is now NOT shown");
  1109. return 0;
  1110. }
  1111. }
  1112. int charcommand_showdelay(
  1113. const int fd, struct map_session_data* sd,
  1114. const char* command, const char* message)
  1115. {
  1116. if (sd->nodelay) {
  1117. sd->nodelay = 0;
  1118. clif_displaymessage(fd, "Skill delay failure is now shown");
  1119. return 0;
  1120. }
  1121. else {
  1122. sd->nodelay = 1;
  1123. clif_displaymessage(fd, "Skill delay failure is NOT now shown");
  1124. return 0;
  1125. }
  1126. }