charcommand.c 59 KB

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