charcommand.c 59 KB

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