Guest User

Untitled

a guest
Jul 31st, 2012
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 354.36 KB | None | 0 0
  1. // (c) 2008 - 2011 eAmod Project; Andres Garbanzo / Zephyrus
  2. //
  3. // - Skype: Zephyrus_cr
  4. // - Site: http://dev.terra-gaming.com
  5. //
  6. // This file is NOT public - you are not allowed to distribute it.
  7. // Authorized Server List : http://dev.terra-gaming.com/index.php?/topic/72-authorized-eamod-servers/
  8. // eAmod is a non Free, extended version of eAthena Ragnarok Private Server.
  9.  
  10. #include "../common/cbasetypes.h"
  11. #include "../common/mmo.h"
  12. #include "../common/timer.h"
  13. #include "../common/nullpo.h"
  14. #include "../common/core.h"
  15. #include "../common/showmsg.h"
  16. #include "../common/malloc.h"
  17. #include "../common/socket.h"
  18. #include "../common/strlib.h"
  19. #include "../common/utils.h"
  20.  
  21. #include "atcommand.h"
  22. #include "battle.h"
  23. #include "battleground.h"
  24. #include "chat.h"
  25. #include "channel.h"
  26. #include "clif.h"
  27. #include "chrif.h"
  28. #include "duel.h"
  29. #include "intif.h"
  30. #include "itemdb.h"
  31. #include "log.h"
  32. #include "map.h"
  33. #include "pc.h"
  34. #include "status.h"
  35. #include "skill.h"
  36. #include "mob.h"
  37. #include "npc.h"
  38. #include "pet.h"
  39. #include "homunculus.h"
  40. #include "mercenary.h"
  41. #include "party.h"
  42. #include "guild.h"
  43. #include "script.h"
  44. #include "storage.h"
  45. #include "trade.h"
  46. #include "unit.h"
  47. #include "achievement.h"
  48. #include "faction.h"
  49.  
  50. #ifndef TXT_ONLY
  51. #include "mail.h"
  52. #endif
  53.  
  54. #include <stdio.h>
  55. #include <stdlib.h>
  56. #include <string.h>
  57. #include <math.h>
  58.  
  59. // extern variables
  60. char atcommand_symbol = '@'; // first char of the commands
  61. char charcommand_symbol = '#';
  62. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  63.  
  64. // local declarations
  65. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  66.  
  67. typedef struct AtCommandInfo
  68. {
  69. const char* command;
  70. int level;
  71. int level2;
  72. int premium;
  73. AtCommandFunc func;
  74. } AtCommandInfo;
  75.  
  76. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  77. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  78. static bool premium_usage = false;
  79.  
  80. ACMD_FUNC(commands);
  81.  
  82.  
  83. /*=========================================
  84. * Generic variables
  85. *-----------------------------------------*/
  86. char atcmd_output[CHAT_SIZE_MAX];
  87. char atcmd_player_name[NAME_LENGTH];
  88. char atcmd_temp[100];
  89.  
  90. // compare function for sorting high to lowest
  91. int hightolow_compare (const void * a, const void * b)
  92. {
  93. return ( *(int*)b - *(int*)a );
  94. }
  95.  
  96. // compare function for sorting lowest to highest
  97. int lowtohigh_compare (const void * a, const void * b)
  98. {
  99. return ( *(int*)a - *(int*)b );
  100. }
  101.  
  102. //-----------------------------------------------------------
  103. // Return the message string of the specified number by [Yor]
  104. //-----------------------------------------------------------
  105. const char* msg_txt(int msg_number)
  106. {
  107. if (msg_number >= 0 && msg_number < MAX_MSG &&
  108. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  109. return msg_table[msg_number];
  110.  
  111. return "??";
  112. }
  113.  
  114. //-----------------------------------------------------------
  115. // Returns Players title (from msg_athena.conf) [Lupus]
  116. //-----------------------------------------------------------
  117. static char* player_title_txt(int level)
  118. {
  119. const char* format;
  120. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  121. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  122. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  123. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  124. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  125. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  126. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  127. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  128. : "";
  129. sprintf(atcmd_temp, format, level);
  130. return atcmd_temp;
  131. }
  132.  
  133.  
  134. /*==========================================
  135. * Read Message Data
  136. *------------------------------------------*/
  137. int msg_config_read(const char* cfgName)
  138. {
  139. int msg_number;
  140. char line[1024], w1[1024], w2[1024];
  141. FILE *fp;
  142. static int called = 1;
  143.  
  144. if ((fp = fopen(cfgName, "r")) == NULL) {
  145. ShowError("Messages file not found: %s\n", cfgName);
  146. return 1;
  147. }
  148.  
  149. if ((--called) == 0)
  150. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  151.  
  152. while(fgets(line, sizeof(line), fp))
  153. {
  154. if (line[0] == '/' && line[1] == '/')
  155. continue;
  156. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  157. continue;
  158.  
  159. if (strcmpi(w1, "import") == 0)
  160. msg_config_read(w2);
  161. else
  162. {
  163. msg_number = atoi(w1);
  164. if (msg_number >= 0 && msg_number < MAX_MSG)
  165. {
  166. if (msg_table[msg_number] != NULL)
  167. aFree(msg_table[msg_number]);
  168. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  169. strcpy(msg_table[msg_number],w2);
  170. }
  171. }
  172. }
  173.  
  174. fclose(fp);
  175.  
  176. return 0;
  177. }
  178.  
  179. /*==========================================
  180. * Cleanup Message Data
  181. *------------------------------------------*/
  182. void do_final_msg(void)
  183. {
  184. int i;
  185. for (i = 0; i < MAX_MSG; i++)
  186. aFree(msg_table[i]);
  187. }
  188.  
  189.  
  190. /*==========================================
  191. * @send (used for testing packet sends from the client)
  192. *------------------------------------------*/
  193. ACMD_FUNC(send)
  194. {
  195. int len=0,off,end,type;
  196. long num;
  197. (void)command; // not used
  198.  
  199. // read message type as hex number (without the 0x)
  200. if(!message || !*message ||
  201. !((sscanf(message, "len %x", &type)==1 && (len=1))
  202. || sscanf(message, "%x", &type)==1) )
  203. {
  204. clif_displaymessage(fd, "Usage:");
  205. clif_displaymessage(fd, " @send len <packet hex number>");
  206. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  207. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  208. return -1;
  209. }
  210.  
  211. #define PARSE_ERROR(error,p) \
  212. {\
  213. clif_displaymessage(fd, (error));\
  214. sprintf(atcmd_output, ">%s", (p));\
  215. clif_displaymessage(fd, atcmd_output);\
  216. }
  217. //define PARSE_ERROR
  218.  
  219. #define CHECK_EOS(p) \
  220. if(*(p) == 0){\
  221. clif_displaymessage(fd, "Unexpected end of string");\
  222. return -1;\
  223. }
  224. //define CHECK_EOS
  225.  
  226. #define SKIP_VALUE(p) \
  227. {\
  228. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  229. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  230. }
  231. //define SKIP_VALUE
  232.  
  233. #define GET_VALUE(p,num) \
  234. {\
  235. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  236. PARSE_ERROR("Invalid number in:",(p));\
  237. return -1;\
  238. }\
  239. }
  240. //define GET_VALUE
  241.  
  242. if (type > 0 && type < MAX_PACKET_DB) {
  243.  
  244. if(len)
  245. {// show packet length
  246. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  247. clif_displaymessage(fd, atcmd_output);
  248. return 0;
  249. }
  250.  
  251. len=packet_db[sd->packet_ver][type].len;
  252. off=2;
  253. if(len == 0)
  254. {// unknown packet - ERROR
  255. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  256. clif_displaymessage(fd, atcmd_output);
  257. return -1;
  258. } else if(len == -1)
  259. {// dynamic packet
  260. len=SHRT_MAX-4; // maximum length
  261. off=4;
  262. }
  263. WFIFOHEAD(fd, len);
  264. WFIFOW(fd,0)=TOW(type);
  265.  
  266. // parse packet contents
  267. SKIP_VALUE(message);
  268. while(*message != 0 && off < len){
  269. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  270. {// default (byte)
  271. GET_VALUE(message,num);
  272. WFIFOB(fd,off)=TOB(num);
  273. ++off;
  274. } else if(TOUPPER(*message) == 'B')
  275. {// byte
  276. ++message;
  277. GET_VALUE(message,num);
  278. WFIFOB(fd,off)=TOB(num);
  279. ++off;
  280. } else if(TOUPPER(*message) == 'W')
  281. {// word (2 bytes)
  282. ++message;
  283. GET_VALUE(message,num);
  284. WFIFOW(fd,off)=TOW(num);
  285. off+=2;
  286. } else if(TOUPPER(*message) == 'L')
  287. {// long word (4 bytes)
  288. ++message;
  289. GET_VALUE(message,num);
  290. WFIFOL(fd,off)=TOL(num);
  291. off+=4;
  292. } else if(TOUPPER(*message) == 'S')
  293. {// string - escapes are valid
  294. // get string length - num <= 0 means not fixed length (default)
  295. ++message;
  296. if(*message == '"'){
  297. num=0;
  298. } else {
  299. GET_VALUE(message,num);
  300. while(*message != '"')
  301. {// find start of string
  302. if(*message == 0 || ISSPACE(*message)){
  303. PARSE_ERROR("Not a string:",message);
  304. return -1;
  305. }
  306. ++message;
  307. }
  308. }
  309.  
  310. // parse string
  311. ++message;
  312. CHECK_EOS(message);
  313. end=(num<=0? 0: min(off+((int)num),len));
  314. for(; *message != '"' && (off < end || end == 0); ++off){
  315. if(*message == '\\'){
  316. ++message;
  317. CHECK_EOS(message);
  318. switch(*message){
  319. case 'a': num=0x07; break; // Bell
  320. case 'b': num=0x08; break; // Backspace
  321. case 't': num=0x09; break; // Horizontal tab
  322. case 'n': num=0x0A; break; // Line feed
  323. case 'v': num=0x0B; break; // Vertical tab
  324. case 'f': num=0x0C; break; // Form feed
  325. case 'r': num=0x0D; break; // Carriage return
  326. case 'e': num=0x1B; break; // Escape
  327. default: num=*message; break;
  328. case 'x': // Hexadecimal
  329. {
  330. ++message;
  331. CHECK_EOS(message);
  332. if(!ISXDIGIT(*message)){
  333. PARSE_ERROR("Not a hexadecimal digit:",message);
  334. return -1;
  335. }
  336. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  337. if(ISXDIGIT(*message)){
  338. ++message;
  339. CHECK_EOS(message);
  340. num<<=8;
  341. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  342. }
  343. WFIFOB(fd,off)=TOB(num);
  344. ++message;
  345. CHECK_EOS(message);
  346. continue;
  347. }
  348. case '0':
  349. case '1':
  350. case '2':
  351. case '3':
  352. case '4':
  353. case '5':
  354. case '6':
  355. case '7': // Octal
  356. {
  357. num=*message-'0'; // 1st octal digit
  358. ++message;
  359. CHECK_EOS(message);
  360. if(ISDIGIT(*message) && *message < '8'){
  361. num<<=3;
  362. num+=*message-'0'; // 2nd octal digit
  363. ++message;
  364. CHECK_EOS(message);
  365. if(ISDIGIT(*message) && *message < '8'){
  366. num<<=3;
  367. num+=*message-'0'; // 3rd octal digit
  368. ++message;
  369. CHECK_EOS(message);
  370. }
  371. }
  372. WFIFOB(fd,off)=TOB(num);
  373. continue;
  374. }
  375. }
  376. } else
  377. num=*message;
  378. WFIFOB(fd,off)=TOB(num);
  379. ++message;
  380. CHECK_EOS(message);
  381. }//for
  382. while(*message != '"')
  383. {// ignore extra characters
  384. ++message;
  385. CHECK_EOS(message);
  386. }
  387.  
  388. // terminate the string
  389. if(off < end)
  390. {// fill the rest with 0's
  391. memset(WFIFOP(fd,off),0,end-off);
  392. off=end;
  393. }
  394. } else
  395. {// unknown
  396. PARSE_ERROR("Unknown type of value in:",message);
  397. return -1;
  398. }
  399. SKIP_VALUE(message);
  400. }
  401.  
  402. if(packet_db[sd->packet_ver][type].len == -1)
  403. {// send dynamic packet
  404. WFIFOW(fd,2)=TOW(off);
  405. WFIFOSET(fd,off);
  406. } else
  407. {// send static packet
  408. if(off < len)
  409. memset(WFIFOP(fd,off),0,len-off);
  410. WFIFOSET(fd,len);
  411. }
  412. } else {
  413. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  414. return -1;
  415. }
  416. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  417. clif_displaymessage(fd, atcmd_output);
  418. return 0;
  419. #undef PARSE_ERROR
  420. #undef CHECK_EOS
  421. #undef SKIP_VALUE
  422. #undef GET_VALUE
  423. }
  424.  
  425. /*==========================================
  426. * @rura, @warp, @mapmove
  427. *------------------------------------------*/
  428. ACMD_FUNC(mapmove)
  429. {
  430. char map_name[MAP_NAME_LENGTH_EXT];
  431. unsigned short mapindex;
  432. short x = 0, y = 0;
  433. int m = -1;
  434.  
  435. nullpo_retr(-1, sd);
  436.  
  437. memset(map_name, '\0', sizeof(map_name));
  438.  
  439. if (!message || !*message ||
  440. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  441. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  442.  
  443. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  444. return -1;
  445. }
  446.  
  447. if( battle_config.pvpmode_nowarp_cmd && sd->state.pvpmode )
  448. {
  449. clif_displaymessage(sd->fd,"You can not use @go while on PVP Mode.");
  450. return -1;
  451. }
  452.  
  453. mapindex = mapindex_name2id(map_name);
  454. if (mapindex)
  455. m = map_mapindex2mapid(mapindex);
  456.  
  457. if (!mapindex) { // m < 0 means on different server! [Kevin]
  458. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  459. return -1;
  460. }
  461.  
  462. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  463. { //This is to prevent the pc_setpos call from printing an error.
  464. clif_displaymessage(fd, msg_txt(2));
  465. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  466. x = y = 0; //Invalid cell, use random spot.
  467. }
  468. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  469. clif_displaymessage(fd, msg_txt(247));
  470. return -1;
  471. }
  472. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  473. clif_displaymessage(fd, msg_txt(248));
  474. return -1;
  475. }
  476. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  477. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  478. return -1;
  479. }
  480.  
  481. clif_displaymessage(fd, msg_txt(0)); // Warped.
  482. return 0;
  483. }
  484.  
  485. /*==========================================
  486. * Displays where a character is. Corrected version by Silent. [Skotlex]
  487. *------------------------------------------*/
  488. ACMD_FUNC(where)
  489. {
  490. struct map_session_data* pl_sd;
  491.  
  492. nullpo_retr(-1, sd);
  493. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  494.  
  495. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  496. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  497. return -1;
  498. }
  499.  
  500. pl_sd = map_nick2sd(atcmd_player_name);
  501. if( pl_sd == NULL
  502. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  503. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  504. ) {
  505. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  506. return -1;
  507. }
  508.  
  509. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  510. clif_displaymessage(fd, atcmd_output);
  511.  
  512. return 0;
  513. }
  514.  
  515. /*==========================================
  516. *
  517. *------------------------------------------*/
  518. ACMD_FUNC(jumpto)
  519. {
  520. struct map_session_data *pl_sd = NULL;
  521.  
  522. nullpo_retr(-1, sd);
  523.  
  524. if (!message || !*message) {
  525. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  526. return -1;
  527. }
  528.  
  529. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  530. {
  531. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  532. return -1;
  533. }
  534.  
  535. if (pl_sd == sd)
  536. {
  537. clif_displaymessage(fd, "But you are already where you are...");
  538. return -1;
  539. }
  540.  
  541. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  542. {
  543. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  544. return -1;
  545. }
  546.  
  547. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  548. {
  549. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  550. return -1;
  551. }
  552.  
  553. if( pc_isdead(sd) )
  554. {
  555. clif_displaymessage(fd, "You cannot use this command when dead.");
  556. return -1;
  557. }
  558.  
  559. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  560. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  561. clif_displaymessage(fd, atcmd_output);
  562.  
  563. return 0;
  564. }
  565.  
  566. /*==========================================
  567. *
  568. *------------------------------------------*/
  569. ACMD_FUNC(jump)
  570. {
  571. short x = 0, y = 0;
  572.  
  573. nullpo_retr(-1, sd);
  574.  
  575. memset(atcmd_output, '\0', sizeof(atcmd_output));
  576.  
  577. sscanf(message, "%hd %hd", &x, &y);
  578.  
  579. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  580. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  581. return -1;
  582. }
  583.  
  584. if( pc_isdead(sd) )
  585. {
  586. clif_displaymessage(fd, "You cannot use this command when dead.");
  587. return -1;
  588. }
  589.  
  590. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  591. { //This is to prevent the pc_setpos call from printing an error.
  592. clif_displaymessage(fd, msg_txt(2));
  593. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  594. x = y = 0; //Invalid cell, use random spot.
  595. }
  596.  
  597. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  598. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  599. clif_displaymessage(fd, atcmd_output);
  600. return 0;
  601. }
  602.  
  603. /*==========================================
  604. * @who3 = Player name, his location
  605. *------------------------------------------*/
  606. ACMD_FUNC(who3)
  607. {
  608. char temp0[100];
  609. struct map_session_data *pl_sd;
  610. struct s_mapiterator* iter;
  611. int j, count;
  612. int pl_GM_level, GM_level;
  613. char match_text[100];
  614. char player_name[NAME_LENGTH];
  615.  
  616. nullpo_retr(-1, sd);
  617.  
  618. memset(atcmd_output, '\0', sizeof(atcmd_output));
  619. memset(match_text, '\0', sizeof(match_text));
  620. memset(player_name, '\0', sizeof(player_name));
  621.  
  622. if (sscanf(message, "%99[^\n]", match_text) < 1)
  623. strcpy(match_text, "");
  624. for (j = 0; match_text[j]; j++)
  625. match_text[j] = TOLOWER(match_text[j]);
  626.  
  627. count = 0;
  628. GM_level = pc_isGM(sd);
  629.  
  630. iter = mapit_getallusers();
  631. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  632. {
  633. pl_GM_level = pc_isGM(pl_sd);
  634. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  635. {// you can look only lower or same level
  636. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  637. for (j = 0; player_name[j]; j++)
  638. player_name[j] = TOLOWER(player_name[j]);
  639. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  640.  
  641. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  642. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  643. } else {
  644. atcmd_output[0]=0;
  645. }
  646. //Player name
  647. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  648. strcat(atcmd_output,temp0);
  649. //Player title, if exists
  650. if (pl_GM_level > 0) {
  651. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  652. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  653. strcat(atcmd_output,temp0);
  654. }
  655. //Players Location: map x y
  656. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  657. strcat(atcmd_output,temp0);
  658.  
  659. clif_displaymessage(fd, atcmd_output);
  660. count++;
  661. }
  662. }
  663. }
  664. mapit_free(iter);
  665.  
  666. if (count == 0)
  667. clif_displaymessage(fd, msg_txt(28)); // No player found.
  668. else if (count == 1)
  669. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  670. else {
  671. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  672. clif_displaymessage(fd, atcmd_output);
  673. }
  674.  
  675. return 0;
  676. }
  677.  
  678. /*==========================================
  679. * Player name, BLevel, Job,
  680. *------------------------------------------*/
  681. ACMD_FUNC(who2)
  682. {
  683. char temp0[100];
  684. struct map_session_data *pl_sd;
  685. struct s_mapiterator* iter;
  686. int j, count;
  687. int pl_GM_level, GM_level;
  688. char match_text[100];
  689. char player_name[NAME_LENGTH];
  690.  
  691. nullpo_retr(-1, sd);
  692.  
  693. memset(atcmd_output, '\0', sizeof(atcmd_output));
  694. memset(match_text, '\0', sizeof(match_text));
  695. memset(player_name, '\0', sizeof(player_name));
  696.  
  697. if (sscanf(message, "%99[^\n]", match_text) < 1)
  698. strcpy(match_text, "");
  699. for (j = 0; match_text[j]; j++)
  700. match_text[j] = TOLOWER(match_text[j]);
  701.  
  702. count = 0;
  703. GM_level = pc_isGM(sd);
  704.  
  705. iter = mapit_getallusers();
  706. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  707. {
  708. pl_GM_level = pc_isGM(pl_sd);
  709. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  710. {// you can look only lower or same level
  711. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  712. for (j = 0; player_name[j]; j++)
  713. player_name[j] = TOLOWER(player_name[j]);
  714. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  715. //Players Name
  716. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  717. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  718. //Player title, if exists
  719. if (pl_GM_level > 0) {
  720. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  721. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  722. strcat(atcmd_output,temp0);
  723. }
  724. //Players Base Level / Job name
  725. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  726. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  727. strcat(atcmd_output,temp0);
  728.  
  729. clif_displaymessage(fd, atcmd_output);
  730. count++;
  731. }
  732. }
  733. }
  734. mapit_free(iter);
  735.  
  736. if (count == 0)
  737. clif_displaymessage(fd, msg_txt(28)); // No player found.
  738. else if (count == 1)
  739. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  740. else {
  741. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  742. clif_displaymessage(fd, atcmd_output);
  743. }
  744.  
  745. return 0;
  746. }
  747.  
  748. /*==========================================
  749. * Player name, Playrs Party / Guild name
  750. *------------------------------------------*/
  751. ACMD_FUNC(who)
  752. {
  753. char temp0[100];
  754. struct map_session_data *pl_sd;
  755. struct s_mapiterator* iter;
  756. int j, count;
  757. int pl_GM_level, GM_level;
  758. char match_text[100];
  759. char player_name[NAME_LENGTH];
  760. struct guild *g;
  761. struct party_data *p;
  762.  
  763. nullpo_retr(-1, sd);
  764.  
  765. memset(temp0, '\0', sizeof(temp0));
  766. memset(atcmd_output, '\0', sizeof(atcmd_output));
  767. memset(match_text, '\0', sizeof(match_text));
  768. memset(player_name, '\0', sizeof(player_name));
  769.  
  770. if (sscanf(message, "%99[^\n]", match_text) < 1)
  771. strcpy(match_text, "");
  772. for (j = 0; match_text[j]; j++)
  773. match_text[j] = TOLOWER(match_text[j]);
  774.  
  775. count = 0;
  776. GM_level = pc_isGM(sd);
  777.  
  778. iter = mapit_getallusers();
  779. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  780. {
  781. pl_GM_level = pc_isGM(pl_sd);
  782. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  783. {// you can look only lower or same level
  784. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  785. for (j = 0; player_name[j]; j++)
  786. player_name[j] = TOLOWER(player_name[j]);
  787. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  788. g = guild_search(pl_sd->status.guild_id);
  789. p = party_search(pl_sd->status.party_id);
  790. //Players Name
  791. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  792. //Player title, if exists
  793. if (pl_GM_level > 0) {
  794. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  795. strcat(atcmd_output,temp0);
  796. }
  797. //Players Party if exists
  798. if (p != NULL) {
  799. //sprintf(temp0," | Party: '%s'", p->name);
  800. sprintf(temp0, msg_txt(335), p->party.name);
  801. strcat(atcmd_output,temp0);
  802. }
  803. //Players Guild if exists
  804. if (g != NULL) {
  805. //sprintf(temp0," | Guild: '%s'", g->name);
  806. sprintf(temp0, msg_txt(336), g->name);
  807. strcat(atcmd_output,temp0);
  808. }
  809. clif_displaymessage(fd, atcmd_output);
  810. count++;
  811. }
  812. }
  813. }
  814. mapit_free(iter);
  815.  
  816. if (count == 0)
  817. clif_displaymessage(fd, msg_txt(28)); // No player found.
  818. else if (count == 1)
  819. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  820. else {
  821. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  822. clif_displaymessage(fd, atcmd_output);
  823. }
  824.  
  825. return 0;
  826. }
  827.  
  828. /*==========================================
  829. *
  830. *------------------------------------------*/
  831. ACMD_FUNC(whomap3)
  832. {
  833. struct map_session_data *pl_sd;
  834. struct s_mapiterator* iter;
  835. int count;
  836. int pl_GM_level, GM_level;
  837. int map_id;
  838. char map_name[MAP_NAME_LENGTH_EXT];
  839.  
  840. memset(atcmd_output, '\0', sizeof(atcmd_output));
  841. memset(map_name, '\0', sizeof(map_name));
  842.  
  843. if (!message || !*message)
  844. map_id = sd->bl.m;
  845. else {
  846. sscanf(message, "%15s", map_name);
  847. if ((map_id = map_mapname2mapid(map_name)) < 0)
  848. map_id = sd->bl.m;
  849. }
  850.  
  851. count = 0;
  852. GM_level = pc_isGM(sd);
  853.  
  854. iter = mapit_getallusers();
  855. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  856. {
  857. pl_GM_level = pc_isGM(pl_sd);
  858. if( pl_sd->bl.m != map_id )
  859. continue;
  860. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  861. continue;
  862.  
  863. if (pl_GM_level > 0)
  864. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  865. else
  866. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  867. clif_displaymessage(fd, atcmd_output);
  868. count++;
  869. }
  870. mapit_free(iter);
  871.  
  872. if (count == 0)
  873. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  874. else if (count == 1)
  875. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  876. else {
  877. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  878. }
  879. clif_displaymessage(fd, atcmd_output);
  880.  
  881. return 0;
  882. }
  883.  
  884. /*==========================================
  885. *
  886. *------------------------------------------*/
  887. ACMD_FUNC(whomap2)
  888. {
  889. struct map_session_data *pl_sd;
  890. struct s_mapiterator* iter;
  891. int count;
  892. int pl_GM_level, GM_level;
  893. int map_id = 0;
  894. char map_name[MAP_NAME_LENGTH_EXT];
  895.  
  896. nullpo_retr(-1, sd);
  897.  
  898. memset(atcmd_output, '\0', sizeof(atcmd_output));
  899. memset(map_name, '\0', sizeof(map_name));
  900.  
  901. if (!message || !*message)
  902. map_id = sd->bl.m;
  903. else {
  904. sscanf(message, "%15s", map_name);
  905. if ((map_id = map_mapname2mapid(map_name)) < 0)
  906. map_id = sd->bl.m;
  907. }
  908.  
  909. count = 0;
  910. GM_level = pc_isGM(sd);
  911.  
  912. iter = mapit_getallusers();
  913. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  914. {
  915. pl_GM_level = pc_isGM(pl_sd);
  916. if( pl_sd->bl.m != map_id )
  917. continue;
  918. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  919. continue;
  920.  
  921. if (pl_GM_level > 0)
  922. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  923. else
  924. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  925. clif_displaymessage(fd, atcmd_output);
  926. count++;
  927. }
  928. mapit_free(iter);
  929.  
  930. if (count == 0)
  931. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  932. else if (count == 1)
  933. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  934. else {
  935. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  936. }
  937. clif_displaymessage(fd, atcmd_output);
  938.  
  939. return 0;
  940. }
  941.  
  942. /*==========================================
  943. *
  944. *------------------------------------------*/
  945. ACMD_FUNC(whomap)
  946. {
  947. char temp0[100];
  948. char temp1[100];
  949. struct map_session_data *pl_sd;
  950. struct s_mapiterator* iter;
  951. int count;
  952. int pl_GM_level, GM_level;
  953. int map_id = 0;
  954. char map_name[MAP_NAME_LENGTH_EXT];
  955. struct guild *g;
  956. struct party_data *p;
  957.  
  958. nullpo_retr(-1, sd);
  959.  
  960. memset(temp0, '\0', sizeof(temp0));
  961. memset(temp1, '\0', sizeof(temp1));
  962. memset(atcmd_output, '\0', sizeof(atcmd_output));
  963. memset(map_name, '\0', sizeof(map_name));
  964.  
  965. if (!message || !*message)
  966. map_id = sd->bl.m;
  967. else {
  968. sscanf(message, "%15s", map_name);
  969. if ((map_id = map_mapname2mapid(map_name)) < 0)
  970. map_id = sd->bl.m;
  971. }
  972.  
  973. count = 0;
  974. GM_level = pc_isGM(sd);
  975.  
  976. iter = mapit_getallusers();
  977. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  978. {
  979. pl_GM_level = pc_isGM(pl_sd);
  980. if( pl_sd->bl.m != map_id )
  981. continue;
  982. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  983. continue;
  984.  
  985. g = guild_search(pl_sd->status.guild_id);
  986. if (g == NULL)
  987. sprintf(temp1, "None");
  988. else
  989. sprintf(temp1, "%s", g->name);
  990. p = party_search(pl_sd->status.party_id);
  991. if (p == NULL)
  992. sprintf(temp0, "None");
  993. else
  994. sprintf(temp0, "%s", p->party.name);
  995. if (pl_GM_level > 0)
  996. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  997. else
  998. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  999. clif_displaymessage(fd, atcmd_output);
  1000. count++;
  1001. }
  1002. mapit_free(iter);
  1003.  
  1004. if (count == 0)
  1005. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1006. else if (count == 1)
  1007. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1008. else {
  1009. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1010. }
  1011. clif_displaymessage(fd, atcmd_output);
  1012.  
  1013. return 0;
  1014. }
  1015.  
  1016. /*==========================================
  1017. *
  1018. *------------------------------------------*/
  1019. ACMD_FUNC(whogm)
  1020. {
  1021. struct map_session_data* pl_sd;
  1022. struct s_mapiterator* iter;
  1023. int j, count;
  1024. int pl_GM_level, GM_level;
  1025. char match_text[CHAT_SIZE_MAX];
  1026. char player_name[NAME_LENGTH];
  1027. struct guild *g;
  1028. struct party_data *p;
  1029.  
  1030. nullpo_retr(-1, sd);
  1031.  
  1032. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1033. memset(match_text, '\0', sizeof(match_text));
  1034. memset(player_name, '\0', sizeof(player_name));
  1035.  
  1036. if (sscanf(message, "%199[^\n]", match_text) < 1)
  1037. strcpy(match_text, "");
  1038. for (j = 0; match_text[j]; j++)
  1039. match_text[j] = TOLOWER(match_text[j]);
  1040.  
  1041. count = 0;
  1042. GM_level = pc_isGM(sd);
  1043.  
  1044. iter = mapit_getallusers();
  1045. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  1046. {
  1047. pl_GM_level = pc_isGM(pl_sd);
  1048. if (!pl_GM_level)
  1049. continue;
  1050.  
  1051. if (match_text[0])
  1052. {
  1053. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1054. for (j = 0; player_name[j]; j++)
  1055. player_name[j] = TOLOWER(player_name[j]);
  1056. // search with no case sensitive
  1057. if (strstr(player_name, match_text) == NULL)
  1058. continue;
  1059. }
  1060. if (pl_GM_level > GM_level) {
  1061. if (pl_sd->sc.option & OPTION_INVISIBLE)
  1062. continue;
  1063. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  1064. clif_displaymessage(fd, atcmd_output);
  1065. count++;
  1066. continue;
  1067. }
  1068.  
  1069. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  1070. pl_sd->status.name, pl_GM_level,
  1071. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1072. clif_displaymessage(fd, atcmd_output);
  1073.  
  1074. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  1075. pl_sd->status.base_level,
  1076. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1077. clif_displaymessage(fd, atcmd_output);
  1078.  
  1079. p = party_search(pl_sd->status.party_id);
  1080. g = guild_search(pl_sd->status.guild_id);
  1081.  
  1082. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  1083. p?p->party.name:"None", g?g->name:"None");
  1084.  
  1085. clif_displaymessage(fd, atcmd_output);
  1086. count++;
  1087. }
  1088. mapit_free(iter);
  1089.  
  1090. if (count == 0)
  1091. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1092. else if (count == 1)
  1093. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1094. else {
  1095. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1096. clif_displaymessage(fd, atcmd_output);
  1097. }
  1098.  
  1099. return 0;
  1100. }
  1101.  
  1102. /*==========================================
  1103. *
  1104. *------------------------------------------*/
  1105. ACMD_FUNC(save)
  1106. {
  1107. nullpo_retr(-1, sd);
  1108.  
  1109. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1110. if (sd->status.pet_id > 0 && sd->pd)
  1111. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1112.  
  1113. chrif_save(sd,0);
  1114.  
  1115. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  1116.  
  1117. return 0;
  1118. }
  1119.  
  1120. /*==========================================
  1121. *
  1122. *------------------------------------------*/
  1123. ACMD_FUNC(load)
  1124. {
  1125. int m;
  1126.  
  1127. nullpo_retr(-1, sd);
  1128.  
  1129. m = map_mapindex2mapid(sd->status.save_point.map);
  1130. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1131. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  1132. return -1;
  1133. }
  1134. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1135. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1136. return -1;
  1137. }
  1138.  
  1139. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  1140. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  1141.  
  1142. return 0;
  1143. }
  1144.  
  1145. /*==========================================
  1146. *
  1147. *------------------------------------------*/
  1148. ACMD_FUNC(speed)
  1149. {
  1150. int speed;
  1151.  
  1152. nullpo_retr(-1, sd);
  1153.  
  1154. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1155.  
  1156. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  1157. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1158. clif_displaymessage(fd, atcmd_output);
  1159. return -1;
  1160. }
  1161.  
  1162. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  1163. status_calc_bl(&sd->bl, SCB_SPEED);
  1164. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1165. return 0;
  1166. }
  1167.  
  1168. /*==========================================
  1169. *
  1170. *------------------------------------------*/
  1171. ACMD_FUNC(storage)
  1172. {
  1173. nullpo_retr(-1, sd);
  1174.  
  1175. if( sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag )
  1176. return -1;
  1177.  
  1178. if( premium_usage && map_flag_gvg(sd->bl.m) )
  1179. return -1;
  1180.  
  1181. if (storage_storageopen(sd) == 1)
  1182. { //Already open.
  1183. clif_displaymessage(fd, msg_txt(250));
  1184. return -1;
  1185. }
  1186.  
  1187. clif_displaymessage(fd, "Storage opened.");
  1188.  
  1189. return 0;
  1190. }
  1191.  
  1192.  
  1193. /*==========================================
  1194. *
  1195. *------------------------------------------*/
  1196. ACMD_FUNC(guildstorage)
  1197. {
  1198. nullpo_retr(-1, sd);
  1199.  
  1200. if (!sd->status.guild_id) {
  1201. clif_displaymessage(fd, msg_txt(252));
  1202. return -1;
  1203. }
  1204.  
  1205. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1206. return -1;
  1207.  
  1208. if (sd->state.storage_flag == 1 || sd->state.storage_flag == 3) {
  1209. clif_displaymessage(fd, msg_txt(250));
  1210. return -1;
  1211. }
  1212.  
  1213. if (sd->state.storage_flag == 2) {
  1214. clif_displaymessage(fd, msg_txt(251));
  1215. return -1;
  1216. }
  1217.  
  1218. storage_guild_storageopen(sd);
  1219. clif_displaymessage(fd, "Guild storage opened.");
  1220. return 0;
  1221. }
  1222.  
  1223. /*==========================================
  1224. *
  1225. *------------------------------------------*/
  1226. ACMD_FUNC(option)
  1227. {
  1228. int param1 = 0, param2 = 0, param3 = 0;
  1229. nullpo_retr(-1, sd);
  1230.  
  1231. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1232. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1233. return -1;
  1234. }
  1235.  
  1236. sd->sc.opt1 = param1;
  1237. sd->sc.opt2 = param2;
  1238. pc_setoption(sd, param3);
  1239.  
  1240. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1241.  
  1242. return 0;
  1243. }
  1244.  
  1245. /*==========================================
  1246. *
  1247. *------------------------------------------*/
  1248. ACMD_FUNC(hide)
  1249. {
  1250. nullpo_retr(-1, sd);
  1251. if (sd->sc.option & OPTION_INVISIBLE) {
  1252. sd->sc.option &= ~OPTION_INVISIBLE;
  1253. if (sd->disguise)
  1254. status_set_viewdata(&sd->bl, sd->disguise);
  1255. else
  1256. status_set_viewdata(&sd->bl, sd->status.class_);
  1257. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1258. } else {
  1259. sd->sc.option |= OPTION_INVISIBLE;
  1260. sd->vd.class_ = INVISIBLE_CLASS;
  1261. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1262. }
  1263. clif_changeoption(&sd->bl);
  1264.  
  1265. return 0;
  1266. }
  1267.  
  1268. /*==========================================
  1269. * Changes a character's class
  1270. *------------------------------------------*/
  1271. ACMD_FUNC(jobchange)
  1272. {
  1273. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1274. int job = 0, upper = 0;
  1275. nullpo_retr(-1, sd);
  1276.  
  1277. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1278. {
  1279. int i, found = 0;
  1280. const struct { char name[16]; int id; } jobs[] = {
  1281. { "novice", 0 },
  1282. { "swordsman", 1 },
  1283. { "mage", 2 },
  1284. { "archer", 3 },
  1285. { "acolyte", 4 },
  1286. { "merchant", 5 },
  1287. { "thief", 6 },
  1288. { "knight", 7 },
  1289. { "priest", 8 },
  1290. { "priestess", 8 },
  1291. { "wizard", 9 },
  1292. { "blacksmith", 10 },
  1293. { "hunter", 11 },
  1294. { "assassin", 12 },
  1295. { "crusader", 14 },
  1296. { "monk", 15 },
  1297. { "sage", 16 },
  1298. { "rogue", 17 },
  1299. { "alchemist", 18 },
  1300. { "bard", 19 },
  1301. { "dancer", 20 },
  1302. { "super novice", 23 },
  1303. { "supernovice", 23 },
  1304. { "gunslinger", 24 },
  1305. { "gunner", 24 },
  1306. { "ninja", 25 },
  1307. { "high novice", 4001 },
  1308. { "swordsman high", 4002 },
  1309. { "mage high", 4003 },
  1310. { "archer high", 4004 },
  1311. { "acolyte high", 4005 },
  1312. { "merchant high", 4006 },
  1313. { "thief high", 4007 },
  1314. { "lord knight", 4008 },
  1315. { "high priest", 4009 },
  1316. { "high priestess", 4009 },
  1317. { "high wizard", 4010 },
  1318. { "whitesmith", 4011 },
  1319. { "sniper", 4012 },
  1320. { "assassin cross", 4013 },
  1321. { "paladin", 4015 },
  1322. { "champion", 4016 },
  1323. { "professor", 4017 },
  1324. { "stalker", 4018 },
  1325. { "creator", 4019 },
  1326. { "clown", 4020 },
  1327. { "gypsy", 4021 },
  1328. { "baby novice", 4023 },
  1329. { "baby swordsman", 4024 },
  1330. { "baby mage", 4025 },
  1331. { "baby archer", 4026 },
  1332. { "baby acolyte", 4027 },
  1333. { "baby merchant", 4028 },
  1334. { "baby thief", 4029 },
  1335. { "baby knight", 4030 },
  1336. { "baby priest", 4031 },
  1337. { "baby priestess", 4031 },
  1338. { "baby wizard", 4032 },
  1339. { "baby blacksmith",4033 },
  1340. { "baby hunter", 4034 },
  1341. { "baby assassin", 4035 },
  1342. { "baby crusader", 4037 },
  1343. { "baby monk", 4038 },
  1344. { "baby sage", 4039 },
  1345. { "baby rogue", 4040 },
  1346. { "baby alchemist", 4041 },
  1347. { "baby bard", 4042 },
  1348. { "baby dancer", 4043 },
  1349. { "super baby", 4045 },
  1350. { "taekwon", 4046 },
  1351. { "taekwon boy", 4046 },
  1352. { "taekwon girl", 4046 },
  1353. { "star gladiator", 4047 },
  1354. { "soul linker", 4049 },
  1355. };
  1356.  
  1357. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1358. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1359. job = jobs[i].id;
  1360. upper = 0;
  1361. found = 1;
  1362. break;
  1363. }
  1364. }
  1365.  
  1366. if (!found) {
  1367. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1368. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 N/A");
  1369. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1370. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1371. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1372. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1373. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1374. clif_displaymessage(fd, " 6 Thief 13 N/A 20 Dancer 27 N/A");
  1375. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 N/A");
  1376. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1377. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1378. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1379. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1380. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1381. clif_displaymessage(fd, "4007 Thief High 4014 N/A 4021 Gypsy");
  1382. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 N/A");
  1383. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1384. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1385. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1386. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1387. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1388. clif_displaymessage(fd, "4029 Baby Thief 4036 N/A 4043 Baby Dancer");
  1389. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1390. return -1;
  1391. }
  1392. }
  1393.  
  1394. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1395. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1396. ) // Deny direct transformation into dummy jobs
  1397. return 0;
  1398.  
  1399. if (pcdb_checkid(job))
  1400. {
  1401. if (pc_jobchange(sd, job, upper) == 0)
  1402. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1403. else {
  1404. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1405. return -1;
  1406. }
  1407. } else {
  1408. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1409. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 N/A");
  1410. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1411. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1412. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1413. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1414. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1415. clif_displaymessage(fd, " 6 Thief 13 N/A 20 Dancer 27 N/A");
  1416. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 N/A");
  1417. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1418. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1419. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1420. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1421. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1422. clif_displaymessage(fd, "4007 Thief High 4014 N/A 4021 Gypsy");
  1423. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 N/A");
  1424. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1425. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1426. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1427. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1428. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1429. clif_displaymessage(fd, "4029 Baby Thief 4036 N/A 4043 Baby Dancer");
  1430. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1431. return -1;
  1432. }
  1433.  
  1434. return 0;
  1435. }
  1436.  
  1437. /*==========================================
  1438. *
  1439. *------------------------------------------*/
  1440. ACMD_FUNC(die)
  1441. {
  1442. nullpo_retr(-1, sd);
  1443. clif_specialeffect(&sd->bl,450,SELF);
  1444. status_kill(&sd->bl);
  1445. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1446.  
  1447. return 0;
  1448. }
  1449.  
  1450. /*==========================================
  1451. *
  1452. *------------------------------------------*/
  1453. ACMD_FUNC(kill)
  1454. {
  1455. struct map_session_data *pl_sd;
  1456. nullpo_retr(-1, sd);
  1457.  
  1458. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1459.  
  1460. if (!message || !*message) {
  1461. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1462. return -1;
  1463. }
  1464.  
  1465. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1466. {
  1467. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1468. return -1;
  1469. }
  1470.  
  1471. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1472. { // you can kill only lower or same level
  1473. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1474. return -1;
  1475. }
  1476.  
  1477. status_kill(&pl_sd->bl);
  1478. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1479. if (fd != pl_sd->fd)
  1480. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1481.  
  1482. return 0;
  1483. }
  1484.  
  1485. /*==========================================
  1486. *
  1487. *------------------------------------------*/
  1488. ACMD_FUNC(alive)
  1489. {
  1490. nullpo_retr(-1, sd);
  1491. if (!status_revive(&sd->bl, 100, 100))
  1492. {
  1493. clif_displaymessage(fd, "You're not dead.");
  1494. return -1;
  1495. }
  1496. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1497. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1498. return 0;
  1499. }
  1500.  
  1501. /*==========================================
  1502. * +kamic [LuzZza]
  1503. *------------------------------------------*/
  1504. ACMD_FUNC(kami)
  1505. {
  1506. unsigned long color=0;
  1507. nullpo_retr(-1, sd);
  1508.  
  1509. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1510.  
  1511. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1512.  
  1513. if (!message || !*message) {
  1514. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1515. return -1;
  1516. }
  1517.  
  1518. sscanf(message, "%199[^\n]", atcmd_output);
  1519. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1520.  
  1521. } else {
  1522.  
  1523. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1524. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1525. return -1;
  1526. }
  1527.  
  1528. if(color > 0xFFFFFF) {
  1529. clif_displaymessage(fd, "Invalid color.");
  1530. return -1;
  1531. }
  1532.  
  1533. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1534. }
  1535. return 0;
  1536. }
  1537.  
  1538. /*==========================================
  1539. *
  1540. *------------------------------------------*/
  1541. ACMD_FUNC(heal)
  1542. {
  1543. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1544. nullpo_retr(-1, sd);
  1545.  
  1546. sscanf(message, "%d %d", &hp, &sp);
  1547.  
  1548. // some overflow checks
  1549. if( hp == INT_MIN ) hp++;
  1550. if( sp == INT_MIN ) sp++;
  1551.  
  1552. if ( hp == 0 && sp == 0 ) {
  1553. if (!status_percent_heal(&sd->bl, 100, 100))
  1554. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1555. else
  1556. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1557. return 0;
  1558. }
  1559.  
  1560. if ( hp > 0 && sp >= 0 ) {
  1561. if(!status_heal(&sd->bl, hp, sp, 0))
  1562. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1563. else
  1564. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1565. return 0;
  1566. }
  1567.  
  1568. if ( hp < 0 && sp <= 0 ) {
  1569. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1570. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1571. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1572. return 0;
  1573. }
  1574.  
  1575. //Opposing signs.
  1576. if ( hp ) {
  1577. if (hp > 0)
  1578. status_heal(&sd->bl, hp, 0, 0);
  1579. else {
  1580. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1581. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1582. }
  1583. }
  1584.  
  1585. if ( sp ) {
  1586. if (sp > 0)
  1587. status_heal(&sd->bl, 0, sp, 0);
  1588. else
  1589. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1590. }
  1591.  
  1592. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1593. return 0;
  1594. }
  1595.  
  1596. /*==========================================
  1597. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1598. *------------------------------------------*/
  1599. ACMD_FUNC(item)
  1600. {
  1601. char item_name[100];
  1602. int number = 0, item_id, flag, type = 0;
  1603. struct item item_tmp;
  1604. struct item_data *item_data;
  1605. int get_count, i;
  1606. nullpo_retr(-1, sd);
  1607.  
  1608. memset(item_name, '\0', sizeof(item_name));
  1609.  
  1610. if (!message || !*message || (
  1611. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1612. sscanf(message, "%99s %d", item_name, &number) < 1
  1613. )) {
  1614. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1615. return -1;
  1616. }
  1617.  
  1618. if (number <= 0)
  1619. number = 1;
  1620.  
  1621. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1622. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1623. {
  1624. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1625. return -1;
  1626. }
  1627.  
  1628. if( !strcmpi(command+1,"bounditem") )
  1629. type = 1;
  1630. else if( !strcmpi(command+1,"costumeitem") )
  1631. {
  1632. if( !battle_config.costume_reserved_char_id )
  1633. {
  1634. clif_displaymessage(fd, "Costume convertion is disable. Set a value for costume_reserved_char_id on your eAmod.conf file.");
  1635. return -1;
  1636. }
  1637. if( !(item_data->equip&EQP_HEAD_LOW) &&
  1638. !(item_data->equip&EQP_HEAD_MID) &&
  1639. !(item_data->equip&EQP_HEAD_TOP) &&
  1640. !(item_data->equip&EQP_COS_HEAD_LOW) &&
  1641. !(item_data->equip&EQP_COS_HEAD_MID) &&
  1642. !(item_data->equip&EQP_COS_HEAD_TOP) )
  1643. {
  1644. clif_displaymessage(fd, "You cannot costume this item. Costume only work for headgears");
  1645. return -1;
  1646. }
  1647. type = 2;
  1648. }
  1649.  
  1650. item_id = item_data->nameid;
  1651. get_count = number;
  1652. //Check if it's stackable.
  1653. if( !itemdb_isstackable2(item_data) )
  1654. {
  1655. if( type == 1 && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) )
  1656. {
  1657. clif_displaymessage(fd, "Cannot create bounded pet eggs or pet armors.");
  1658. return -1;
  1659. }
  1660. get_count = 1;
  1661. }
  1662. else if( type == 1 )
  1663. {
  1664. clif_displaymessage(fd, "Cannot create bounded stackable items.");
  1665. return -1;
  1666. }
  1667.  
  1668. for( i = 0; i < number; i += get_count )
  1669. {
  1670. // if not pet egg
  1671. if( !pet_create_egg(sd, item_id) )
  1672. {
  1673. memset(&item_tmp, 0, sizeof(item_tmp));
  1674. item_tmp.nameid = item_id;
  1675. item_tmp.identify = 1;
  1676. if( type == 1 )
  1677. item_tmp.bound = 1;
  1678. else if( type == 2 )
  1679. { // Costume Item
  1680. item_tmp.card[0] = CARD0_CREATE;
  1681. item_tmp.card[2] = GetWord(battle_config.costume_reserved_char_id, 0);
  1682. item_tmp.card[3] = GetWord(battle_config.costume_reserved_char_id, 1);
  1683. }
  1684.  
  1685. if( (flag = pc_additem(sd, &item_tmp, get_count,LOG_TYPE_COMMAND)) )
  1686. clif_additem(sd, 0, 0, flag);
  1687. }
  1688. }
  1689.  
  1690. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1691. return 0;
  1692. }
  1693.  
  1694. /*==========================================
  1695. *
  1696. *------------------------------------------*/
  1697. ACMD_FUNC(item2)
  1698. {
  1699. struct item item_tmp;
  1700. struct item_data *item_data;
  1701. char item_name[100];
  1702. int item_id, number = 0;
  1703. int identify = 0, refine = 0, attr = 0;
  1704. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1705. int flag, bound = 0;
  1706. int loop, get_count, i;
  1707. nullpo_retr(-1, sd);
  1708.  
  1709. memset(item_name, '\0', sizeof(item_name));
  1710.  
  1711. if (!message || !*message || (
  1712. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1713. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1714. )) {
  1715. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1716. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1717. return -1;
  1718. }
  1719.  
  1720. if (number <= 0)
  1721. number = 1;
  1722.  
  1723. item_id = 0;
  1724. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1725. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1726. item_id = item_data->nameid;
  1727.  
  1728. if( item_id > 500 )
  1729. {
  1730. if( !strcmpi(command+1,"bounditem2") )
  1731. bound = 1;
  1732.  
  1733. if( !itemdb_isstackable2(item_data) )
  1734. {
  1735. if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) )
  1736. {
  1737. clif_displaymessage(fd, "Cannot create bounded pet eggs or pet armors.");
  1738. return -1;
  1739. }
  1740.  
  1741. loop = number;
  1742. get_count = 1;
  1743. if( item_data->type == IT_PETEGG )
  1744. {
  1745. identify = 1;
  1746. refine = 0;
  1747. }
  1748. if( item_data->type == IT_PETARMOR )
  1749. refine = 0;
  1750. if( refine > MAX_REFINE )
  1751. refine = MAX_REFINE;
  1752. }
  1753. else
  1754. {
  1755. if( bound )
  1756. {
  1757. clif_displaymessage(fd, "Cannot create bounded stackable items.");
  1758. return -1;
  1759. }
  1760.  
  1761. loop = 1;
  1762. get_count = number;
  1763. identify = 1;
  1764. refine = attr = 0;
  1765. }
  1766.  
  1767. for( i = 0; i < loop; i++ )
  1768. {
  1769. memset(&item_tmp, 0, sizeof(item_tmp));
  1770. item_tmp.nameid = item_id;
  1771. item_tmp.identify = identify;
  1772. item_tmp.refine = refine;
  1773. item_tmp.attribute = attr;
  1774. item_tmp.card[0] = c1;
  1775. item_tmp.card[1] = c2;
  1776. item_tmp.card[2] = c3;
  1777. item_tmp.card[3] = c4;
  1778. item_tmp.bound = bound;
  1779.  
  1780. if( (flag = pc_additem(sd, &item_tmp, get_count,LOG_TYPE_COMMAND)) )
  1781. clif_additem(sd, 0, 0, flag);
  1782. }
  1783.  
  1784. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1785. }
  1786. else
  1787. {
  1788. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1789. return -1;
  1790. }
  1791.  
  1792. return 0;
  1793. }
  1794.  
  1795. /*==========================================
  1796. *
  1797. *------------------------------------------*/
  1798. ACMD_FUNC(itemreset)
  1799. {
  1800. int i;
  1801. nullpo_retr(-1, sd);
  1802.  
  1803. for (i = 0; i < MAX_INVENTORY; i++) {
  1804. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  1805. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1806. }
  1807. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1808.  
  1809. return 0;
  1810. }
  1811.  
  1812. /*==========================================
  1813. * Atcommand @lvlup
  1814. *------------------------------------------*/
  1815. ACMD_FUNC(baselevelup)
  1816. {
  1817. int level=0, i=0, status_point=0;
  1818. nullpo_retr(-1, sd);
  1819. level = atoi(message);
  1820.  
  1821. if (!message || !*message || !level) {
  1822. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1823. return -1;
  1824. }
  1825.  
  1826. if (level > 0) {
  1827. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1828. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1829. return -1;
  1830. } // End Addition
  1831. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1832. level = pc_maxbaselv(sd) - sd->status.base_level;
  1833. for (i = 0; i < level; i++)
  1834. status_point += pc_gets_status_point(sd->status.base_level + i);
  1835.  
  1836. sd->status.status_point += status_point;
  1837. sd->status.base_level += (unsigned int)level;
  1838. status_percent_heal(&sd->bl, 100, 100);
  1839. clif_misceffect(&sd->bl, 0);
  1840. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1841. } else {
  1842. if (sd->status.base_level == 1) {
  1843. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1844. return -1;
  1845. }
  1846. level*=-1;
  1847. if ((unsigned int)level >= sd->status.base_level)
  1848. level = sd->status.base_level-1;
  1849. for (i = 0; i > -level; i--)
  1850. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1851. if (sd->status.status_point < status_point)
  1852. pc_resetstate(sd);
  1853. if (sd->status.status_point < status_point)
  1854. sd->status.status_point = 0;
  1855. else
  1856. sd->status.status_point -= status_point;
  1857. sd->status.base_level -= (unsigned int)level;
  1858. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1859. }
  1860. sd->status.base_exp = 0;
  1861. clif_updatestatus(sd, SP_STATUSPOINT);
  1862. clif_updatestatus(sd, SP_BASELEVEL);
  1863. clif_updatestatus(sd, SP_BASEEXP);
  1864. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1865. status_calc_pc(sd, 0);
  1866. if(sd->status.party_id)
  1867. party_send_levelup(sd);
  1868. return 0;
  1869. }
  1870.  
  1871. /*==========================================
  1872. *
  1873. *------------------------------------------*/
  1874. ACMD_FUNC(joblevelup)
  1875. {
  1876. int level=0;
  1877. nullpo_retr(-1, sd);
  1878.  
  1879. level = atoi(message);
  1880.  
  1881. if (!message || !*message || !level) {
  1882. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1883. return -1;
  1884. }
  1885. if (level > 0) {
  1886. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1887. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1888. return -1;
  1889. }
  1890. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1891. level = pc_maxjoblv(sd) - sd->status.job_level;
  1892. sd->status.job_level += (unsigned int)level;
  1893. sd->status.skill_point += level;
  1894. clif_misceffect(&sd->bl, 1);
  1895. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1896. } else {
  1897. if (sd->status.job_level == 1) {
  1898. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1899. return -1;
  1900. }
  1901. level *=-1;
  1902. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1903. level = sd->status.job_level-1;
  1904. sd->status.job_level -= (unsigned int)level;
  1905. if (sd->status.skill_point < level)
  1906. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1907. if (sd->status.skill_point < level)
  1908. sd->status.skill_point = 0;
  1909. else
  1910. sd->status.skill_point -= level;
  1911. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1912. }
  1913. sd->status.job_exp = 0;
  1914. clif_updatestatus(sd, SP_JOBLEVEL);
  1915. clif_updatestatus(sd, SP_JOBEXP);
  1916. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1917. clif_updatestatus(sd, SP_SKILLPOINT);
  1918. status_calc_pc(sd, 0);
  1919.  
  1920. return 0;
  1921. }
  1922.  
  1923. /*==========================================
  1924. * @help
  1925. *------------------------------------------*/
  1926. ACMD_FUNC(help)
  1927. {
  1928. char buf[2048], w1[2048], w2[2048];
  1929. int i, gm_level;
  1930. FILE* fp;
  1931. nullpo_retr(-1, sd);
  1932.  
  1933. memset(buf, '\0', sizeof(buf));
  1934.  
  1935. if ((fp = fopen(help_txt, "r")) != NULL) {
  1936. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1937. gm_level = pc_isGM(sd);
  1938. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1939. if (buf[0] == '/' && buf[1] == '/')
  1940. continue;
  1941. for (i = 0; buf[i] != '\0'; i++) {
  1942. if (buf[i] == '\r' || buf[i] == '\n') {
  1943. buf[i] = '\0';
  1944. break;
  1945. }
  1946. }
  1947. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1948. clif_displaymessage(fd, buf);
  1949. else if (gm_level >= atoi(w1))
  1950. clif_displaymessage(fd, w2);
  1951. }
  1952. fclose(fp);
  1953. } else {
  1954. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1955. return -1;
  1956. }
  1957.  
  1958. return 0;
  1959. }
  1960.  
  1961. /*==========================================
  1962. * @help2 - Char commands [Kayla]
  1963. *------------------------------------------*/
  1964. ACMD_FUNC(help2)
  1965. {
  1966. char buf[2048], w1[2048], w2[2048];
  1967. int i, gm_level;
  1968. FILE* fp;
  1969. nullpo_retr(-1, sd);
  1970.  
  1971. memset(buf, '\0', sizeof(buf));
  1972.  
  1973. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1974. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1975. gm_level = pc_isGM(sd);
  1976. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1977. if (buf[0] == '/' && buf[1] == '/')
  1978. continue;
  1979. for (i = 0; buf[i] != '\0'; i++) {
  1980. if (buf[i] == '\r' || buf[i] == '\n') {
  1981. buf[i] = '\0';
  1982. break;
  1983. }
  1984. }
  1985. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1986. clif_displaymessage(fd, buf);
  1987. else if (gm_level >= atoi(w1))
  1988. clif_displaymessage(fd, w2);
  1989. }
  1990. fclose(fp);
  1991. } else {
  1992. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1993. return -1;
  1994. }
  1995.  
  1996. return 0;
  1997. }
  1998.  
  1999.  
  2000. // helper function, used in foreach calls to stop auto-attack timers
  2001. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  2002. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  2003. {
  2004. struct unit_data *ud = unit_bl2ud(bl);
  2005. int id = va_arg(ap, int);
  2006. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  2007. {
  2008. unit_stop_attack(bl);
  2009. return 1;
  2010. }
  2011. return 0;
  2012. }
  2013. /*==========================================
  2014. *
  2015. *------------------------------------------*/
  2016. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  2017. {
  2018. TBL_PC* sd = (TBL_PC*)bl;
  2019. clif_pvpset(sd, 0, 0, 2);
  2020. if (sd->pvp_timer != INVALID_TIMER) {
  2021. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  2022. sd->pvp_timer = INVALID_TIMER;
  2023. }
  2024. return 0;
  2025. }
  2026.  
  2027. ACMD_FUNC(pvpoff)
  2028. {
  2029. nullpo_retr(-1, sd);
  2030.  
  2031. if (!map[sd->bl.m].flag.pvp) {
  2032. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2033. return -1;
  2034. }
  2035.  
  2036. map[sd->bl.m].flag.pvp = 0;
  2037.  
  2038. if (!battle_config.pk_mode)
  2039. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  2040. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  2041. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2042. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2043. return 0;
  2044. }
  2045.  
  2046. /*==========================================
  2047. *
  2048. *------------------------------------------*/
  2049. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  2050. {
  2051. TBL_PC* sd = (TBL_PC*)bl;
  2052. if (sd->state.pvpmode)
  2053. pc_pvpmodeoff(sd, 1, 1);
  2054. if (sd->pvp_timer == INVALID_TIMER) {
  2055. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  2056. sd->pvp_rank = 0;
  2057. sd->pvp_lastusers = 0;
  2058. sd->pvp_point = 5;
  2059. sd->pvp_won = 0;
  2060. sd->pvp_lost = 0;
  2061. }
  2062. return 0;
  2063. }
  2064.  
  2065. ACMD_FUNC(pvpon)
  2066. {
  2067. nullpo_retr(-1, sd);
  2068.  
  2069. if (map[sd->bl.m].flag.pvp) {
  2070. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2071. return -1;
  2072. }
  2073.  
  2074. map[sd->bl.m].flag.pvp = 1;
  2075.  
  2076. if (!battle_config.pk_mode)
  2077. {// display pvp circle and rank
  2078. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  2079. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  2080. }
  2081.  
  2082. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2083.  
  2084. return 0;
  2085. }
  2086.  
  2087. /*==========================================
  2088. *
  2089. *------------------------------------------*/
  2090. ACMD_FUNC(gvgoff)
  2091. {
  2092. nullpo_retr(-1, sd);
  2093.  
  2094. if (!map[sd->bl.m].flag.gvg) {
  2095. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2096. return -1;
  2097. }
  2098.  
  2099. map[sd->bl.m].flag.gvg = 0;
  2100. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  2101. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2102. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2103.  
  2104. return 0;
  2105. }
  2106.  
  2107. /*==========================================
  2108. *
  2109. *------------------------------------------*/
  2110. ACMD_FUNC(gvgon)
  2111. {
  2112. nullpo_retr(-1, sd);
  2113.  
  2114. if (map[sd->bl.m].flag.gvg) {
  2115. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2116. return -1;
  2117. }
  2118.  
  2119. map[sd->bl.m].flag.gvg = 1;
  2120. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  2121. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2122.  
  2123. return 0;
  2124. }
  2125.  
  2126. /*==========================================
  2127. *
  2128. *------------------------------------------*/
  2129. ACMD_FUNC(model)
  2130. {
  2131. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2132. nullpo_retr(-1, sd);
  2133.  
  2134. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2135.  
  2136. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2137. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2138. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2139. clif_displaymessage(fd, atcmd_output);
  2140. return -1;
  2141. }
  2142.  
  2143. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2144. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2145. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2146. pc_changelook(sd, LOOK_HAIR, hair_style);
  2147. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2148. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2149. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2150. } else {
  2151. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2152. return -1;
  2153. }
  2154.  
  2155. return 0;
  2156. }
  2157.  
  2158. /*==========================================
  2159. * @dye && @ccolor
  2160. *------------------------------------------*/
  2161. ACMD_FUNC(dye)
  2162. {
  2163. int cloth_color = 0;
  2164. nullpo_retr(-1, sd);
  2165.  
  2166. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2167.  
  2168. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2169. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2170. clif_displaymessage(fd, atcmd_output);
  2171. return -1;
  2172. }
  2173.  
  2174. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2175. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2176. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2177. } else {
  2178. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2179. return -1;
  2180. }
  2181.  
  2182. return 0;
  2183. }
  2184.  
  2185. /*==========================================
  2186. * @hairstyle && @hstyle
  2187. *------------------------------------------*/
  2188. ACMD_FUNC(hair_style)
  2189. {
  2190. int hair_style = 0;
  2191. nullpo_retr(-1, sd);
  2192.  
  2193. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2194.  
  2195. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2196. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2197. clif_displaymessage(fd, atcmd_output);
  2198. return -1;
  2199. }
  2200.  
  2201. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2202. pc_changelook(sd, LOOK_HAIR, hair_style);
  2203. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2204. } else {
  2205. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2206. return -1;
  2207. }
  2208.  
  2209. return 0;
  2210. }
  2211.  
  2212. /*==========================================
  2213. * @haircolor && @hcolor
  2214. *------------------------------------------*/
  2215. ACMD_FUNC(hair_color)
  2216. {
  2217. int hair_color = 0;
  2218. nullpo_retr(-1, sd);
  2219.  
  2220. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2221.  
  2222. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2223. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2224. clif_displaymessage(fd, atcmd_output);
  2225. return -1;
  2226. }
  2227.  
  2228. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2229. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2230. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2231. } else {
  2232. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2233. return -1;
  2234. }
  2235.  
  2236. return 0;
  2237. }
  2238.  
  2239. /*==========================================
  2240. * @go [city_number or city_name] - Updated by Harbin
  2241. *------------------------------------------*/
  2242. ACMD_FUNC(go)
  2243. {
  2244. int i;
  2245. int town;
  2246. char map_name[MAP_NAME_LENGTH];
  2247. int m;
  2248.  
  2249. const struct {
  2250. char map[MAP_NAME_LENGTH];
  2251. int x, y;
  2252. } data[] = {
  2253. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2254. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2255. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2256. { MAP_PAYON, 162, 233 }, // 3=Payon
  2257. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2258. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2259. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2260. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2261. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2262. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2263. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2264. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  2265. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2266. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2267. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  2268. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  2269. { MAP_JAIL, 23, 61 }, // 16=Prison
  2270. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2271. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2272. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2273. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2274. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2275. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2276. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2277. { MAP_VEINS, 216, 123 }, // 24=Veins
  2278. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  2279. };
  2280.  
  2281. nullpo_retr(-1, sd);
  2282.  
  2283. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  2284. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2285. return 0;
  2286. }
  2287.  
  2288. if( battle_config.pvpmode_nowarp_cmd && sd->state.pvpmode )
  2289. {
  2290. clif_displaymessage(sd->fd,"You can not use @go while on PVP Mode.");
  2291. return -1;
  2292. }
  2293.  
  2294. memset(map_name, '\0', sizeof(map_name));
  2295. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2296.  
  2297. // get the number
  2298. town = atoi(message);
  2299.  
  2300. // if no value, display all value
  2301. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  2302. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2303. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2304. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2305. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2306. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2307. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  2308. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  2309. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2310. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2311. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2312. clif_displaymessage(fd, " 24=Veins 25=Moscovia");
  2313. return -1;
  2314. }
  2315.  
  2316. // get possible name of the city
  2317. map_name[MAP_NAME_LENGTH-1] = '\0';
  2318. for (i = 0; map_name[i]; i++)
  2319. map_name[i] = TOLOWER(map_name[i]);
  2320. // try to identify the map name
  2321. if (strncmp(map_name, "prontera", 3) == 0) {
  2322. town = 0;
  2323. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2324. town = 1;
  2325. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2326. town = 2;
  2327. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2328. strncmp(map_name, "paion", 3) == 0) {
  2329. town = 3;
  2330. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2331. town = 4;
  2332. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2333. strncmp(map_name, "islude", 3) == 0) {
  2334. town = 5;
  2335. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2336. strcmp(map_name, "al") == 0) {
  2337. town = 6;
  2338. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2339. strcmp(map_name, "christmas") == 0 ||
  2340. strncmp(map_name, "xmas", 3) == 0 ||
  2341. strncmp(map_name, "x-mas", 3) == 0) {
  2342. town = 7;
  2343. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2344. town = 8;
  2345. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2346. town = 9;
  2347. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2348. town = 10;
  2349. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2350. town = 11;
  2351. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2352. town = 12;
  2353. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2354. town = 13;
  2355. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2356. town = 14;
  2357. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2358. strncmp(map_name, "startpoint", 3) == 0 ||
  2359. strncmp(map_name, "begining", 3) == 0) {
  2360. town = 15;
  2361. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2362. strncmp(map_name, "prison", 3) == 0 ||
  2363. strncmp(map_name, "jails", 3) == 0) {
  2364. town = 16;
  2365. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2366. strncmp(map_name, "jawai", 3) == 0) {
  2367. town = 17;
  2368. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2369. strncmp(map_name, "ayotaya", 3) == 0) {
  2370. town = 18;
  2371. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2372. strncmp(map_name, "ainbroch", 5) == 0) {
  2373. town = 19;
  2374. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2375. town = 20;
  2376. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2377. town = 21;
  2378. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2379. town = 22;
  2380. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2381. town = 23;
  2382. } else if (strncmp(map_name, "veins", 3) == 0) {
  2383. town = 24;
  2384. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  2385. town = 25;
  2386. }
  2387.  
  2388. if (town >= 0 && town < ARRAYLENGTH(data))
  2389. {
  2390. m = map_mapname2mapid(data[town].map);
  2391. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2392. clif_displaymessage(fd, msg_txt(247));
  2393. return -1;
  2394. }
  2395. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2396. clif_displaymessage(fd, msg_txt(248));
  2397. return -1;
  2398. }
  2399. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2400. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2401. } else {
  2402. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2403. return -1;
  2404. }
  2405. } else { // if you arrive here, you have an error in town variable when reading of names
  2406. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2407. return -1;
  2408. }
  2409.  
  2410. return 0;
  2411. }
  2412.  
  2413. /*==========================================
  2414. *
  2415. *------------------------------------------*/
  2416. ACMD_FUNC(monster)
  2417. {
  2418. char name[NAME_LENGTH];
  2419. char monster[NAME_LENGTH];
  2420. int mob_id;
  2421. int number = 0;
  2422. int count;
  2423. int i, k, range;
  2424. short mx, my;
  2425. nullpo_retr(-1, sd);
  2426.  
  2427. memset(name, '\0', sizeof(name));
  2428. memset(monster, '\0', sizeof(monster));
  2429. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2430.  
  2431. if (!message || !*message) {
  2432. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2433. return -1;
  2434. }
  2435. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2436. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2437. //All data can be left as it is.
  2438. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2439. //Here, it is possible name was not given and we are using monster for it.
  2440. if (count < 3) //Blank mob's name.
  2441. name[0] = '\0';
  2442. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2443. //All data can be left as it is.
  2444. } else if (sscanf(message, "%23s", monster) > 0) {
  2445. //As before, name may be already filled.
  2446. name[0] = '\0';
  2447. } else {
  2448. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2449. return -1;
  2450. }
  2451.  
  2452. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2453. mob_id = mobdb_checkid(atoi(monster));
  2454.  
  2455. if (mob_id == 0) {
  2456. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2457. return -1;
  2458. }
  2459.  
  2460. if (mob_id == MOBID_EMPERIUM) {
  2461. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2462. return -1;
  2463. }
  2464.  
  2465. if (number <= 0)
  2466. number = 1;
  2467.  
  2468. if( !name[0] )
  2469. strcpy(name, "--ja--");
  2470.  
  2471. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  2472. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2473. number = battle_config.atc_spawn_quantity_limit;
  2474.  
  2475. if (battle_config.etc_log)
  2476. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  2477.  
  2478. count = 0;
  2479. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2480. for (i = 0; i < number; i++) {
  2481. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2482. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2483. count += (k != 0) ? 1 : 0;
  2484. }
  2485.  
  2486. if (count != 0)
  2487. if (number == count)
  2488. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2489. else {
  2490. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2491. clif_displaymessage(fd, atcmd_output);
  2492. }
  2493. else {
  2494. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2495. return -1;
  2496. }
  2497.  
  2498. return 0;
  2499. }
  2500.  
  2501. // small monster spawning [Valaris]
  2502. ACMD_FUNC(monstersmall)
  2503. {
  2504. char name[NAME_LENGTH] = "";
  2505. char monster[NAME_LENGTH] = "";
  2506. int mob_id = 0;
  2507. int number = 0;
  2508. int x = 0;
  2509. int y = 0;
  2510. int count;
  2511. int i;
  2512.  
  2513. nullpo_retr(-1, sd);
  2514.  
  2515. if (!message || !*message) {
  2516. clif_displaymessage(fd, "Give a monster name/id please.");
  2517. return -1;
  2518. }
  2519.  
  2520. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2521. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2522. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2523. clif_displaymessage(fd, "Give a monster name/id please.");
  2524. return -1;
  2525. }
  2526.  
  2527. // If monster identifier/name argument is a name
  2528. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2529. mob_id = atoi(monster);
  2530.  
  2531. if (mob_id == 0) {
  2532. clif_displaymessage(fd, msg_txt(40));
  2533. return -1;
  2534. }
  2535.  
  2536. if (mob_id == MOBID_EMPERIUM) {
  2537. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2538. return -1;
  2539. }
  2540.  
  2541. if (mobdb_checkid(mob_id) == 0) {
  2542. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2543. return -1;
  2544. }
  2545.  
  2546. if (number <= 0)
  2547. number = 1;
  2548.  
  2549. if( !name[0] )
  2550. strcpy(name, "--ja--");
  2551.  
  2552. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  2553. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2554. number = battle_config.atc_spawn_quantity_limit;
  2555.  
  2556. count = 0;
  2557. for (i = 0; i < number; i++) {
  2558. int mx, my;
  2559. if (x <= 0)
  2560. mx = sd->bl.x + (rand() % 11 - 5);
  2561. else
  2562. mx = x;
  2563. if (y <= 0)
  2564. my = sd->bl.y + (rand() % 11 - 5);
  2565. else
  2566. my = y;
  2567. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2568. }
  2569.  
  2570. if (count != 0)
  2571. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2572. else
  2573. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2574.  
  2575. return 0;
  2576. }
  2577. // big monster spawning [Valaris]
  2578. ACMD_FUNC(monsterbig)
  2579. {
  2580. char name[NAME_LENGTH] = "";
  2581. char monster[NAME_LENGTH] = "";
  2582. int mob_id = 0;
  2583. int number = 0;
  2584. int x = 0;
  2585. int y = 0;
  2586. int count;
  2587. int i;
  2588.  
  2589. nullpo_retr(-1, sd);
  2590.  
  2591. if (!message || !*message) {
  2592. clif_displaymessage(fd, "Give a monster name/id please.");
  2593. return -1;
  2594. }
  2595.  
  2596. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2597. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2598. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2599. clif_displaymessage(fd, "Give a monster name/id please.");
  2600. return -1;
  2601. }
  2602.  
  2603. // If monster identifier/name argument is a name
  2604. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2605. mob_id = atoi(monster);
  2606.  
  2607. if (mob_id == 0) {
  2608. clif_displaymessage(fd, msg_txt(40));
  2609. return -1;
  2610. }
  2611.  
  2612. if (mob_id == MOBID_EMPERIUM) {
  2613. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2614. return -1;
  2615. }
  2616.  
  2617. if (mobdb_checkid(mob_id) == 0) {
  2618. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2619. return -1;
  2620. }
  2621.  
  2622. if (number <= 0)
  2623. number = 1;
  2624.  
  2625. if( !name[0] )
  2626. strcpy(name, "--ja--");
  2627.  
  2628. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  2629. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2630. number = battle_config.atc_spawn_quantity_limit;
  2631.  
  2632. count = 0;
  2633. for (i = 0; i < number; i++) {
  2634. int mx, my;
  2635. if (x <= 0)
  2636. mx = sd->bl.x + (rand() % 11 - 5);
  2637. else
  2638. mx = x;
  2639. if (y <= 0)
  2640. my = sd->bl.y + (rand() % 11 - 5);
  2641. else
  2642. my = y;
  2643. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2644. }
  2645.  
  2646. if (count != 0)
  2647. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2648. else
  2649. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2650.  
  2651. return 0;
  2652. }
  2653.  
  2654. /*==========================================
  2655. *
  2656. *------------------------------------------*/
  2657. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2658. {
  2659. struct mob_data *md;
  2660. int flag;
  2661.  
  2662. nullpo_ret(md=(struct mob_data *)bl);
  2663. flag = va_arg(ap, int);
  2664.  
  2665. if (md->guardian_data)
  2666. return 0; //Do not touch WoE mobs!
  2667.  
  2668. if (flag)
  2669. status_zap(bl,md->status.hp, 0);
  2670. else
  2671. status_kill(bl);
  2672. return 1;
  2673. }
  2674.  
  2675. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2676. {
  2677. int map_id;
  2678. char map_name[MAP_NAME_LENGTH_EXT];
  2679.  
  2680. if (!sd) return;
  2681.  
  2682. memset(map_name, '\0', sizeof(map_name));
  2683.  
  2684. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2685. map_id = sd->bl.m;
  2686. else {
  2687. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2688. map_id = sd->bl.m;
  2689. }
  2690.  
  2691. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2692.  
  2693. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2694.  
  2695. return;
  2696. }
  2697.  
  2698. ACMD_FUNC(killmonster)
  2699. {
  2700. atcommand_killmonster_sub(fd, sd, message, 1);
  2701. return 0;
  2702. }
  2703.  
  2704. /*==========================================
  2705. *
  2706. *------------------------------------------*/
  2707. ACMD_FUNC(killmonster2)
  2708. {
  2709. atcommand_killmonster_sub(fd, sd, message, 0);
  2710. return 0;
  2711. }
  2712.  
  2713. /*==========================================
  2714. *
  2715. *------------------------------------------*/
  2716. ACMD_FUNC(refine)
  2717. {
  2718. int i,j, position = 0, refine = 0, current_position, final_refine;
  2719. int count;
  2720. nullpo_retr(-1, sd);
  2721.  
  2722. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2723.  
  2724. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2725. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2726. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2727. clif_displaymessage(fd, atcmd_output);
  2728. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2729. clif_displaymessage(fd, atcmd_output);
  2730. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2731. clif_displaymessage(fd, atcmd_output);
  2732. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2733. clif_displaymessage(fd, atcmd_output);
  2734. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2735. clif_displaymessage(fd, atcmd_output);
  2736. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2737. clif_displaymessage(fd, atcmd_output);
  2738. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2739. clif_displaymessage(fd, atcmd_output);
  2740. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2741. clif_displaymessage(fd, atcmd_output);
  2742. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2743. clif_displaymessage(fd, atcmd_output);
  2744. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2745. clif_displaymessage(fd, atcmd_output);
  2746. return -1;
  2747. }
  2748.  
  2749. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2750.  
  2751. count = 0;
  2752. for (j = 0; j < EQI_MAX_BONUS; j++) {
  2753. if ((i = sd->equip_index[j]) < 0)
  2754. continue;
  2755. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2756. continue;
  2757. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2758. continue;
  2759. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2760. continue;
  2761.  
  2762. if(position && !(sd->status.inventory[i].equip & position))
  2763. continue;
  2764.  
  2765. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2766. if (sd->status.inventory[i].refine != final_refine) {
  2767. sd->status.inventory[i].refine = final_refine;
  2768. current_position = sd->status.inventory[i].equip;
  2769. pc_unequipitem(sd, i, 3);
  2770. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2771. clif_delitem(sd, i, 1, 3);
  2772. clif_additem(sd, i, 1, 0);
  2773. pc_equipitem(sd, i, current_position);
  2774. clif_misceffect(&sd->bl, 3);
  2775. count++;
  2776. }
  2777. }
  2778.  
  2779. if (count == 0)
  2780. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2781. else if (count == 1)
  2782. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2783. else {
  2784. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2785. clif_displaymessage(fd, atcmd_output);
  2786. }
  2787.  
  2788. return 0;
  2789. }
  2790.  
  2791. /*==========================================
  2792. *
  2793. *------------------------------------------*/
  2794. ACMD_FUNC(produce)
  2795. {
  2796. char item_name[100];
  2797. int item_id, attribute = 0, star = 0;
  2798. int flag = 0;
  2799. struct item_data *item_data;
  2800. struct item tmp_item;
  2801. nullpo_retr(-1, sd);
  2802.  
  2803. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2804. memset(item_name, '\0', sizeof(item_name));
  2805.  
  2806. if (!message || !*message || (
  2807. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2808. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2809. )) {
  2810. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2811. return -1;
  2812. }
  2813.  
  2814. item_id = 0;
  2815. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2816. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2817. {
  2818. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2819. return -1;
  2820. }
  2821. item_id = item_data->nameid;
  2822. if (itemdb_isequip2(item_data)) {
  2823. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2824. attribute = ATTRIBUTE_NORMAL;
  2825. if (star < MIN_STAR || star > MAX_STAR)
  2826. star = 0;
  2827. memset(&tmp_item, 0, sizeof tmp_item);
  2828. tmp_item.nameid = item_id;
  2829. tmp_item.amount = 1;
  2830. tmp_item.identify = 1;
  2831. tmp_item.card[0] = CARD0_FORGE;
  2832. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2833. ((star*5) << 8) + attribute:0;
  2834. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2835. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2836. clif_produceeffect(sd, 0, item_id);
  2837. clif_misceffect(&sd->bl, 3);
  2838. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2839. clif_additem(sd, 0, 0, flag);
  2840. } else {
  2841. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2842. clif_displaymessage(fd, atcmd_output);
  2843. return -1;
  2844. }
  2845.  
  2846. return 0;
  2847. }
  2848.  
  2849. /*==========================================
  2850. *
  2851. *------------------------------------------*/
  2852. ACMD_FUNC(memo)
  2853. {
  2854. int position = 0;
  2855. nullpo_retr(-1, sd);
  2856.  
  2857. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2858.  
  2859. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2860. {
  2861. int i;
  2862. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2863. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2864. {
  2865. if( sd->status.memo_point[i].map )
  2866. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  2867. else
  2868. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2869. clif_displaymessage(sd->fd, atcmd_output);
  2870. }
  2871. return 0;
  2872. }
  2873.  
  2874. if( position < 0 || position >= MAX_MEMOPOINTS )
  2875. {
  2876. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2877. clif_displaymessage(fd, atcmd_output);
  2878. return -1;
  2879. }
  2880.  
  2881. pc_memo(sd, position);
  2882. return 0;
  2883. }
  2884.  
  2885. /*==========================================
  2886. *
  2887. *------------------------------------------*/
  2888. ACMD_FUNC(gat)
  2889. {
  2890. int y;
  2891. nullpo_retr(-1, sd);
  2892.  
  2893. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2894.  
  2895. for (y = 2; y >= -2; y--) {
  2896. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2897. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2898. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2899. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2900. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2901. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2902. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2903.  
  2904. clif_displaymessage(fd, atcmd_output);
  2905. }
  2906.  
  2907. return 0;
  2908. }
  2909.  
  2910. /*==========================================
  2911. *
  2912. *------------------------------------------*/
  2913. ACMD_FUNC(displaystatus)
  2914. {
  2915. int i, type, flag, tick;
  2916. nullpo_retr(-1, sd);
  2917.  
  2918. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2919. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2920. return -1;
  2921. }
  2922. if (i < 2) flag = 1;
  2923. if (i < 3) tick = 0;
  2924.  
  2925. clif_status_change(&sd->bl, type, flag, tick);
  2926.  
  2927. return 0;
  2928. }
  2929.  
  2930. /*==========================================
  2931. * @stpoint (Rewritten by [Yor])
  2932. *------------------------------------------*/
  2933. ACMD_FUNC(statuspoint)
  2934. {
  2935. int point;
  2936. unsigned int new_status_point;
  2937.  
  2938. if (!message || !*message || (point = atoi(message)) == 0) {
  2939. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2940. return -1;
  2941. }
  2942.  
  2943. if(point < 0)
  2944. {
  2945. if(sd->status.status_point < (unsigned int)(-point))
  2946. {
  2947. new_status_point = 0;
  2948. }
  2949. else
  2950. {
  2951. new_status_point = sd->status.status_point + point;
  2952. }
  2953. }
  2954. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2955. {
  2956. new_status_point = UINT_MAX;
  2957. }
  2958. else
  2959. {
  2960. new_status_point = sd->status.status_point + point;
  2961. }
  2962.  
  2963. if (new_status_point != sd->status.status_point) {
  2964. sd->status.status_point = new_status_point;
  2965. clif_updatestatus(sd, SP_STATUSPOINT);
  2966. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2967. } else {
  2968. if (point < 0)
  2969. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2970. else
  2971. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2972. return -1;
  2973. }
  2974.  
  2975. return 0;
  2976. }
  2977.  
  2978. /*==========================================
  2979. * @skpoint (Rewritten by [Yor])
  2980. *------------------------------------------*/
  2981. ACMD_FUNC(skillpoint)
  2982. {
  2983. int point;
  2984. unsigned int new_skill_point;
  2985. nullpo_retr(-1, sd);
  2986.  
  2987. if (!message || !*message || (point = atoi(message)) == 0) {
  2988. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2989. return -1;
  2990. }
  2991.  
  2992. if(point < 0)
  2993. {
  2994. if(sd->status.skill_point < (unsigned int)(-point))
  2995. {
  2996. new_skill_point = 0;
  2997. }
  2998. else
  2999. {
  3000. new_skill_point = sd->status.skill_point + point;
  3001. }
  3002. }
  3003. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  3004. {
  3005. new_skill_point = UINT_MAX;
  3006. }
  3007. else
  3008. {
  3009. new_skill_point = sd->status.skill_point + point;
  3010. }
  3011.  
  3012. if (new_skill_point != sd->status.skill_point) {
  3013. sd->status.skill_point = new_skill_point;
  3014. clif_updatestatus(sd, SP_SKILLPOINT);
  3015. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  3016. } else {
  3017. if (point < 0)
  3018. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  3019. else
  3020. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  3021. return -1;
  3022. }
  3023.  
  3024. return 0;
  3025. }
  3026.  
  3027. /*==========================================
  3028. * @zeny (Rewritten by [Yor])
  3029. *------------------------------------------*/
  3030. ACMD_FUNC(zeny)
  3031. {
  3032. int zeny, new_zeny;
  3033. nullpo_retr(-1, sd);
  3034.  
  3035. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3036. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3037. return -1;
  3038. }
  3039.  
  3040. new_zeny = sd->status.zeny + zeny;
  3041. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3042. new_zeny = MAX_ZENY;
  3043. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3044. new_zeny = 0;
  3045.  
  3046. if (new_zeny != sd->status.zeny) {
  3047. sd->status.zeny = new_zeny;
  3048. clif_updatestatus(sd, SP_ZENY);
  3049. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  3050. } else {
  3051. if (zeny < 0)
  3052. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  3053. else
  3054. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  3055. return -1;
  3056. }
  3057.  
  3058. return 0;
  3059. }
  3060.  
  3061. /*==========================================
  3062. *
  3063. *------------------------------------------*/
  3064. ACMD_FUNC(param)
  3065. {
  3066. int i, value = 0, new_value;
  3067. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  3068. short* status[6];
  3069. //we don't use direct initialization because it isn't part of the c standard.
  3070. nullpo_retr(-1, sd);
  3071.  
  3072. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3073.  
  3074. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3075. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  3076. clif_displaymessage(fd, atcmd_output);
  3077. return -1;
  3078. }
  3079.  
  3080. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  3081.  
  3082. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  3083. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  3084. clif_displaymessage(fd, atcmd_output);
  3085. return -1;
  3086. }
  3087.  
  3088. status[0] = &sd->status.str;
  3089. status[1] = &sd->status.agi;
  3090. status[2] = &sd->status.vit;
  3091. status[3] = &sd->status.int_;
  3092. status[4] = &sd->status.dex;
  3093. status[5] = &sd->status.luk;
  3094.  
  3095. if(value < 0 && *status[i] <= -value)
  3096. {
  3097. new_value = 1;
  3098. }
  3099. else if(SHRT_MAX - *status[i] < value)
  3100. {
  3101. new_value = SHRT_MAX;
  3102. }
  3103. else
  3104. {
  3105. new_value = *status[i] + value;
  3106. }
  3107.  
  3108. if (new_value != *status[i]) {
  3109. *status[i] = new_value;
  3110. clif_updatestatus(sd, SP_STR + i);
  3111. clif_updatestatus(sd, SP_USTR + i);
  3112. status_calc_pc(sd, 0);
  3113. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3114. } else {
  3115. if (value < 0)
  3116. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  3117. else
  3118. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  3119. return -1;
  3120. }
  3121.  
  3122. return 0;
  3123. }
  3124.  
  3125. /*==========================================
  3126. * Stat all by fritz (rewritten by [Yor])
  3127. *------------------------------------------*/
  3128. ACMD_FUNC(stat_all)
  3129. {
  3130. int index, count, value, max, new_value;
  3131. short* status[6];
  3132. //we don't use direct initialization because it isn't part of the c standard.
  3133. nullpo_retr(-1, sd);
  3134.  
  3135. status[0] = &sd->status.str;
  3136. status[1] = &sd->status.agi;
  3137. status[2] = &sd->status.vit;
  3138. status[3] = &sd->status.int_;
  3139. status[4] = &sd->status.dex;
  3140. status[5] = &sd->status.luk;
  3141.  
  3142. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3143. value = pc_maxparameter(sd);
  3144. max = pc_maxparameter(sd);
  3145. } else {
  3146. max = SHRT_MAX;
  3147. }
  3148.  
  3149. count = 0;
  3150. for (index = 0; index < ARRAYLENGTH(status); index++) {
  3151.  
  3152. if (value > 0 && *status[index] > max - value)
  3153. new_value = max;
  3154. else if (value < 0 && *status[index] <= -value)
  3155. new_value = 1;
  3156. else
  3157. new_value = *status[index] +value;
  3158.  
  3159. if (new_value != (int)*status[index]) {
  3160. *status[index] = new_value;
  3161. clif_updatestatus(sd, SP_STR + index);
  3162. clif_updatestatus(sd, SP_USTR + index);
  3163. count++;
  3164. }
  3165. }
  3166.  
  3167. if (count > 0) { // if at least 1 stat modified
  3168. status_calc_pc(sd, 0);
  3169. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3170. } else {
  3171. if (value < 0)
  3172. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  3173. else
  3174. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  3175. return -1;
  3176. }
  3177.  
  3178. return 0;
  3179. }
  3180.  
  3181. /*==========================================
  3182. *
  3183. *------------------------------------------*/
  3184. ACMD_FUNC(guildlevelup)
  3185. {
  3186. int level = 0;
  3187. short added_level;
  3188. struct guild *guild_info;
  3189. nullpo_retr(-1, sd);
  3190.  
  3191. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3192. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3193. return -1;
  3194. }
  3195.  
  3196. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3197. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3198. return -1;
  3199. }
  3200. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  3201. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3202. // return -1;
  3203. //}
  3204.  
  3205. added_level = (short)level;
  3206. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3207. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3208. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3209. added_level = 1 - guild_info->guild_lv;
  3210.  
  3211. if (added_level != 0) {
  3212. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  3213. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3214. } else {
  3215. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3216. return -1;
  3217. }
  3218.  
  3219. return 0;
  3220. }
  3221.  
  3222. /*==========================================
  3223. *
  3224. *------------------------------------------*/
  3225. ACMD_FUNC(makeegg)
  3226. {
  3227. struct item_data *item_data;
  3228. int id, pet_id;
  3229. nullpo_retr(-1, sd);
  3230.  
  3231. if (!message || !*message) {
  3232. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  3233. return -1;
  3234. }
  3235.  
  3236. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3237. id = item_data->nameid;
  3238. else
  3239. if ((id = mobdb_searchname(message)) != 0) // for monster name
  3240. ;
  3241. else
  3242. id = atoi(message);
  3243.  
  3244. pet_id = search_petDB_index(id, PET_CLASS);
  3245. if (pet_id < 0)
  3246. pet_id = search_petDB_index(id, PET_EGG);
  3247. if (pet_id >= 0) {
  3248. sd->catch_target_class = pet_db[pet_id].class_;
  3249. intif_create_pet(
  3250. sd->status.account_id, sd->status.char_id,
  3251. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3252. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3253. 100, 0, 1, pet_db[pet_id].jname);
  3254. } else {
  3255. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  3256. return -1;
  3257. }
  3258.  
  3259. return 0;
  3260. }
  3261.  
  3262. /*==========================================
  3263. *
  3264. *------------------------------------------*/
  3265. ACMD_FUNC(hatch)
  3266. {
  3267. nullpo_retr(-1, sd);
  3268. if (sd->status.pet_id <= 0)
  3269. clif_sendegg(sd);
  3270. else {
  3271. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3272. return -1;
  3273. }
  3274.  
  3275. return 0;
  3276. }
  3277.  
  3278. /*==========================================
  3279. *
  3280. *------------------------------------------*/
  3281. ACMD_FUNC(petfriendly)
  3282. {
  3283. int friendly;
  3284. struct pet_data *pd;
  3285. nullpo_retr(-1, sd);
  3286.  
  3287. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3288. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3289. return -1;
  3290. }
  3291.  
  3292. pd = sd->pd;
  3293. if (!pd) {
  3294. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3295. return -1;
  3296. }
  3297.  
  3298. if (friendly < 0 || friendly > 1000)
  3299. {
  3300. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3301. return -1;
  3302. }
  3303.  
  3304. if (friendly == pd->pet.intimate) {
  3305. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  3306. return -1;
  3307. }
  3308.  
  3309. pet_set_intimate(pd, friendly);
  3310. clif_send_petstatus(sd);
  3311. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  3312. return 0;
  3313. }
  3314.  
  3315. /*==========================================
  3316. *
  3317. *------------------------------------------*/
  3318. ACMD_FUNC(pethungry)
  3319. {
  3320. int hungry;
  3321. struct pet_data *pd;
  3322. nullpo_retr(-1, sd);
  3323.  
  3324. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3325. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3326. return -1;
  3327. }
  3328.  
  3329. pd = sd->pd;
  3330. if (!sd->status.pet_id || !pd) {
  3331. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3332. return -1;
  3333. }
  3334. if (hungry < 0 || hungry > 100) {
  3335. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3336. return -1;
  3337. }
  3338. if (hungry == pd->pet.hungry) {
  3339. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  3340. return -1;
  3341. }
  3342.  
  3343. pd->pet.hungry = hungry;
  3344. clif_send_petstatus(sd);
  3345. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  3346.  
  3347. return 0;
  3348. }
  3349.  
  3350. /*==========================================
  3351. *
  3352. *------------------------------------------*/
  3353. ACMD_FUNC(petrename)
  3354. {
  3355. struct pet_data *pd;
  3356. nullpo_retr(-1, sd);
  3357. if (!sd->status.pet_id || !sd->pd) {
  3358. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3359. return -1;
  3360. }
  3361. pd = sd->pd;
  3362. if (!pd->pet.rename_flag) {
  3363. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3364. return -1;
  3365. }
  3366.  
  3367. pd->pet.rename_flag = 0;
  3368. intif_save_petdata(sd->status.account_id, &pd->pet);
  3369. clif_send_petstatus(sd);
  3370. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3371.  
  3372. return 0;
  3373. }
  3374.  
  3375. /*==========================================
  3376. *
  3377. *------------------------------------------*/
  3378. ACMD_FUNC(recall)
  3379. {
  3380. struct map_session_data *pl_sd = NULL;
  3381.  
  3382. nullpo_retr(-1, sd);
  3383.  
  3384. if (!message || !*message) {
  3385. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  3386. return -1;
  3387. }
  3388.  
  3389. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3390. {
  3391. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3392. return -1;
  3393. }
  3394.  
  3395. if (pl_sd == sd)
  3396. {
  3397. clif_displaymessage(fd, "You are already where you are...");
  3398. return -1;
  3399. }
  3400.  
  3401. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3402. {
  3403. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3404. return -1;
  3405. }
  3406.  
  3407. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3408. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3409. return -1;
  3410. }
  3411. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3412. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3413. return -1;
  3414. }
  3415. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3416. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3417. clif_displaymessage(fd, atcmd_output);
  3418.  
  3419. return 0;
  3420. }
  3421.  
  3422. /*==========================================
  3423. * charblock command (usage: charblock <player_name>)
  3424. * This command do a definitiv ban on a player
  3425. *------------------------------------------*/
  3426. ACMD_FUNC(char_block)
  3427. {
  3428. nullpo_retr(-1, sd);
  3429.  
  3430. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3431.  
  3432. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3433. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3434. return -1;
  3435. }
  3436.  
  3437. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3438. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3439.  
  3440. return 0;
  3441. }
  3442.  
  3443. /*==========================================
  3444. * charban command (usage: charban <time> <player_name>)
  3445. * This command do a limited ban on a player
  3446. * Time is done as follows:
  3447. * Adjustment value (-1, 1, +1, etc...)
  3448. * Modified element:
  3449. * a or y: year
  3450. * m: month
  3451. * j or d: day
  3452. * h: hour
  3453. * mn: minute
  3454. * s: second
  3455. * <example> @ban +1m-2mn1s-6y test_player
  3456. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3457. *------------------------------------------*/
  3458. ACMD_FUNC(char_ban)
  3459. {
  3460. char * modif_p;
  3461. int year, month, day, hour, minute, second, value;
  3462. nullpo_retr(-1, sd);
  3463.  
  3464. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3465. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3466.  
  3467. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3468. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3469. return -1;
  3470. }
  3471.  
  3472. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3473.  
  3474. modif_p = atcmd_output;
  3475. year = month = day = hour = minute = second = 0;
  3476. while (modif_p[0] != '\0') {
  3477. value = atoi(modif_p);
  3478. if (value == 0)
  3479. modif_p++;
  3480. else {
  3481. if (modif_p[0] == '-' || modif_p[0] == '+')
  3482. modif_p++;
  3483. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3484. modif_p++;
  3485. if (modif_p[0] == 's') {
  3486. second = value;
  3487. modif_p++;
  3488. } else if (modif_p[0] == 'n') {
  3489. minute = value;
  3490. modif_p++;
  3491. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3492. minute = value;
  3493. modif_p = modif_p + 2;
  3494. } else if (modif_p[0] == 'h') {
  3495. hour = value;
  3496. modif_p++;
  3497. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3498. day = value;
  3499. modif_p++;
  3500. } else if (modif_p[0] == 'm') {
  3501. month = value;
  3502. modif_p++;
  3503. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3504. year = value;
  3505. modif_p++;
  3506. } else if (modif_p[0] != '\0') {
  3507. modif_p++;
  3508. }
  3509. }
  3510. }
  3511. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3512. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3513. return -1;
  3514. }
  3515.  
  3516. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3517. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3518.  
  3519. return 0;
  3520. }
  3521.  
  3522. /*==========================================
  3523. * charunblock command (usage: charunblock <player_name>)
  3524. *------------------------------------------*/
  3525. ACMD_FUNC(char_unblock)
  3526. {
  3527. nullpo_retr(-1, sd);
  3528.  
  3529. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3530.  
  3531. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3532. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3533. return -1;
  3534. }
  3535.  
  3536. // send answer to login server via char-server
  3537. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3538. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3539.  
  3540. return 0;
  3541. }
  3542.  
  3543. /*==========================================
  3544. * charunban command (usage: charunban <player_name>)
  3545. *------------------------------------------*/
  3546. ACMD_FUNC(char_unban)
  3547. {
  3548. nullpo_retr(-1, sd);
  3549.  
  3550. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3551.  
  3552. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3553. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3554. return -1;
  3555. }
  3556.  
  3557. // send answer to login server via char-server
  3558. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3559. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3560.  
  3561. return 0;
  3562. }
  3563.  
  3564. /*==========================================
  3565. *
  3566. *------------------------------------------*/
  3567. ACMD_FUNC(night)
  3568. {
  3569. nullpo_retr(-1, sd);
  3570.  
  3571. if (night_flag != 1) {
  3572. map_night_timer(night_timer_tid, 0, 0, 1);
  3573. } else {
  3574. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3575. return -1;
  3576. }
  3577.  
  3578. return 0;
  3579. }
  3580.  
  3581. /*==========================================
  3582. *
  3583. *------------------------------------------*/
  3584. ACMD_FUNC(day)
  3585. {
  3586. nullpo_retr(-1, sd);
  3587.  
  3588. if (night_flag != 0) {
  3589. map_day_timer(day_timer_tid, 0, 0, 1);
  3590. } else {
  3591. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3592. return -1;
  3593. }
  3594.  
  3595. return 0;
  3596. }
  3597.  
  3598. /*==========================================
  3599. *
  3600. *------------------------------------------*/
  3601. ACMD_FUNC(doom)
  3602. {
  3603. struct map_session_data* pl_sd;
  3604. struct s_mapiterator* iter;
  3605.  
  3606. nullpo_retr(-1, sd);
  3607.  
  3608. iter = mapit_getallusers();
  3609. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3610. {
  3611. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3612. {
  3613. status_kill(&pl_sd->bl);
  3614. clif_specialeffect(&pl_sd->bl,450,AREA);
  3615. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3616. }
  3617. }
  3618. mapit_free(iter);
  3619.  
  3620. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3621.  
  3622. return 0;
  3623. }
  3624.  
  3625. /*==========================================
  3626. *
  3627. *------------------------------------------*/
  3628. ACMD_FUNC(doommap)
  3629. {
  3630. struct map_session_data* pl_sd;
  3631. struct s_mapiterator* iter;
  3632.  
  3633. nullpo_retr(-1, sd);
  3634.  
  3635. iter = mapit_getallusers();
  3636. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3637. {
  3638. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3639. {
  3640. status_kill(&pl_sd->bl);
  3641. clif_specialeffect(&pl_sd->bl,450,AREA);
  3642. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3643. }
  3644. }
  3645. mapit_free(iter);
  3646.  
  3647. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3648.  
  3649. return 0;
  3650. }
  3651.  
  3652. /*==========================================
  3653. *
  3654. *------------------------------------------*/
  3655. static void atcommand_raise_sub(struct map_session_data* sd)
  3656. {
  3657. if (!status_isdead(&sd->bl))
  3658. return;
  3659.  
  3660. if(!status_revive(&sd->bl, 100, 100))
  3661. return;
  3662. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3663. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3664. }
  3665.  
  3666. /*==========================================
  3667. *
  3668. *------------------------------------------*/
  3669. ACMD_FUNC(raise)
  3670. {
  3671. struct map_session_data* pl_sd;
  3672. struct s_mapiterator* iter;
  3673.  
  3674. nullpo_retr(-1, sd);
  3675.  
  3676. iter = mapit_getallusers();
  3677. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3678. atcommand_raise_sub(pl_sd);
  3679. mapit_free(iter);
  3680.  
  3681. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3682.  
  3683. return 0;
  3684. }
  3685.  
  3686. /*==========================================
  3687. *
  3688. *------------------------------------------*/
  3689. ACMD_FUNC(raisemap)
  3690. {
  3691. struct map_session_data* pl_sd;
  3692. struct s_mapiterator* iter;
  3693.  
  3694. nullpo_retr(-1, sd);
  3695.  
  3696. iter = mapit_getallusers();
  3697. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3698. if (sd->bl.m == pl_sd->bl.m)
  3699. atcommand_raise_sub(pl_sd);
  3700. mapit_free(iter);
  3701.  
  3702. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3703.  
  3704. return 0;
  3705. }
  3706.  
  3707. /*==========================================
  3708. *
  3709. *------------------------------------------*/
  3710. ACMD_FUNC(kick)
  3711. {
  3712. struct map_session_data *pl_sd;
  3713. nullpo_retr(-1, sd);
  3714.  
  3715. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3716.  
  3717. if (!message || !*message) {
  3718. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3719. return -1;
  3720. }
  3721.  
  3722. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3723. {
  3724. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3725. return -1;
  3726. }
  3727.  
  3728. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3729. {
  3730. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3731. return -1;
  3732. }
  3733.  
  3734. clif_GM_kick(sd, pl_sd);
  3735.  
  3736. return 0;
  3737. }
  3738.  
  3739. /*==========================================
  3740. *
  3741. *------------------------------------------*/
  3742. ACMD_FUNC(kickall)
  3743. {
  3744. struct map_session_data* pl_sd;
  3745. struct s_mapiterator* iter;
  3746. nullpo_retr(-1, sd);
  3747.  
  3748. iter = mapit_getallusers();
  3749. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3750. {
  3751. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3752. if (sd->status.account_id != pl_sd->status.account_id)
  3753. clif_GM_kick(NULL, pl_sd);
  3754. }
  3755. }
  3756. mapit_free(iter);
  3757.  
  3758. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3759.  
  3760. return 0;
  3761. }
  3762.  
  3763. /*==========================================
  3764. *
  3765. *------------------------------------------*/
  3766. ACMD_FUNC(allskill)
  3767. {
  3768. nullpo_retr(-1, sd);
  3769. pc_allskillup(sd); // all skills
  3770. sd->status.skill_point = 0; // 0 skill points
  3771. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3772. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3773.  
  3774. return 0;
  3775. }
  3776.  
  3777. /*==========================================
  3778. *
  3779. *------------------------------------------*/
  3780. ACMD_FUNC(questskill)
  3781. {
  3782. int skill_id;
  3783. nullpo_retr(-1, sd);
  3784.  
  3785. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3786. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3787. return -1;
  3788. }
  3789. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3790. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3791. return -1;
  3792. }
  3793. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3794. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3795. return -1;
  3796. }
  3797. if (pc_checkskill(sd, skill_id) > 0) {
  3798. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3799. return -1;
  3800. }
  3801.  
  3802. pc_skill(sd, skill_id, 1, 0);
  3803. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3804.  
  3805. return 0;
  3806. }
  3807.  
  3808. /*==========================================
  3809. *
  3810. *------------------------------------------*/
  3811. ACMD_FUNC(lostskill)
  3812. {
  3813. int skill_id;
  3814. nullpo_retr(-1, sd);
  3815.  
  3816. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3817. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3818. return -1;
  3819. }
  3820. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3821. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3822. return -1;
  3823. }
  3824. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3825. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3826. return -1;
  3827. }
  3828. if (pc_checkskill(sd, skill_id) == 0) {
  3829. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3830. return -1;
  3831. }
  3832.  
  3833. sd->status.skill[skill_id].lv = 0;
  3834. sd->status.skill[skill_id].flag = 0;
  3835. clif_deleteskill(sd,skill_id);
  3836. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3837.  
  3838. return 0;
  3839. }
  3840.  
  3841. /*==========================================
  3842. *
  3843. *------------------------------------------*/
  3844. ACMD_FUNC(spiritball)
  3845. {
  3846. int max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3847. int number;
  3848. nullpo_retr(-1, sd);
  3849.  
  3850. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3851. {
  3852. char msg[CHAT_SIZE_MAX];
  3853. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3854. clif_displaymessage(fd, msg);
  3855. return -1;
  3856. }
  3857.  
  3858. if( sd->spiritball > 0 )
  3859. pc_delspiritball(sd, sd->spiritball, 1);
  3860. sd->spiritball = number;
  3861. clif_spiritball(sd);
  3862. // no message, player can look the difference
  3863.  
  3864. return 0;
  3865. }
  3866.  
  3867. /*==========================================
  3868. *
  3869. *------------------------------------------*/
  3870. ACMD_FUNC(party)
  3871. {
  3872. char party[NAME_LENGTH];
  3873. nullpo_retr(-1, sd);
  3874.  
  3875. memset(party, '\0', sizeof(party));
  3876.  
  3877. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3878. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3879. return -1;
  3880. }
  3881.  
  3882. party_create(sd, party, 0, 0);
  3883.  
  3884. return 0;
  3885. }
  3886.  
  3887. /*==========================================
  3888. *
  3889. *------------------------------------------*/
  3890. ACMD_FUNC(guild)
  3891. {
  3892. char guild[NAME_LENGTH];
  3893. int prev;
  3894. nullpo_retr(-1, sd);
  3895.  
  3896. memset(guild, '\0', sizeof(guild));
  3897.  
  3898. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3899. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3900. return -1;
  3901. }
  3902.  
  3903. prev = battle_config.guild_emperium_check;
  3904. battle_config.guild_emperium_check = 0;
  3905. guild_create(sd, guild);
  3906. battle_config.guild_emperium_check = prev;
  3907.  
  3908. return 0;
  3909. }
  3910.  
  3911. /*==========================================
  3912. *
  3913. *------------------------------------------*/
  3914. ACMD_FUNC(agitstart)
  3915. {
  3916. int i;
  3917.  
  3918. nullpo_retr(-1, sd);
  3919. if( agit_flag != 0 )
  3920. {
  3921. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3922. return -1;
  3923. }
  3924.  
  3925. if( (i = atoi(message)) > 0 )
  3926. woe_set = i;
  3927.  
  3928. agit_flag = 1;
  3929. guild_agit_start();
  3930.  
  3931. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3932. return 0;
  3933. }
  3934.  
  3935. /*==========================================
  3936. *
  3937. *------------------------------------------*/
  3938. ACMD_FUNC(agitend)
  3939. {
  3940. nullpo_retr(-1, sd);
  3941. if (agit_flag == 0) {
  3942. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3943. return -1;
  3944. }
  3945.  
  3946. guild_agit_end();
  3947. agit_flag = 0;
  3948. woe_set = 0;
  3949. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3950.  
  3951. return 0;
  3952. }
  3953.  
  3954. /*==========================================
  3955. * @mapexit - shuts down the map server
  3956. *------------------------------------------*/
  3957. ACMD_FUNC(mapexit)
  3958. {
  3959. nullpo_retr(-1, sd);
  3960.  
  3961. do_shutdown();
  3962. return 0;
  3963. }
  3964.  
  3965. /*==========================================
  3966. * idsearch <part_of_name>: revrited by [Yor]
  3967. *------------------------------------------*/
  3968. ACMD_FUNC(idsearch)
  3969. {
  3970. char item_name[100];
  3971. unsigned int i, match;
  3972. struct item_data *item_array[MAX_SEARCH];
  3973. nullpo_retr(-1, sd);
  3974.  
  3975. memset(item_name, '\0', sizeof(item_name));
  3976. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3977.  
  3978. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3979. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3980. return -1;
  3981. }
  3982.  
  3983. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3984. clif_displaymessage(fd, atcmd_output);
  3985. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3986. if (match > MAX_SEARCH) {
  3987. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3988. clif_displaymessage(fd, atcmd_output);
  3989. match = MAX_SEARCH;
  3990. }
  3991. for(i = 0; i < match; i++) {
  3992. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3993. clif_displaymessage(fd, atcmd_output);
  3994. }
  3995. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3996. clif_displaymessage(fd, atcmd_output);
  3997.  
  3998. return 0;
  3999. }
  4000.  
  4001. /*==========================================
  4002. * Recall All Characters Online To Your Location
  4003. *------------------------------------------*/
  4004. ACMD_FUNC(recallall)
  4005. {
  4006. struct map_session_data* pl_sd;
  4007. struct s_mapiterator* iter;
  4008. int count;
  4009. nullpo_retr(-1, sd);
  4010.  
  4011. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4012.  
  4013. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4014. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4015. return -1;
  4016. }
  4017.  
  4018. count = 0;
  4019. iter = mapit_getallusers();
  4020. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4021. {
  4022. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  4023. {
  4024. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4025. count++;
  4026. else {
  4027. if (pc_isdead(pl_sd)) { //Wake them up
  4028. pc_setstand(pl_sd);
  4029. pc_setrestartvalue(pl_sd,1);
  4030. }
  4031. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  4032. }
  4033. }
  4034. }
  4035. mapit_free(iter);
  4036.  
  4037. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4038. if (count) {
  4039. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4040. clif_displaymessage(fd, atcmd_output);
  4041. }
  4042.  
  4043. return 0;
  4044. }
  4045.  
  4046. /*==========================================
  4047. * Recall online characters of a guild to your location
  4048. *------------------------------------------*/
  4049. ACMD_FUNC(guildrecall)
  4050. {
  4051. struct map_session_data* pl_sd;
  4052. struct s_mapiterator* iter;
  4053. int count;
  4054. char guild_name[NAME_LENGTH];
  4055. struct guild *g;
  4056. nullpo_retr(-1, sd);
  4057.  
  4058. memset(guild_name, '\0', sizeof(guild_name));
  4059. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4060.  
  4061. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4062. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4063. return -1;
  4064. }
  4065.  
  4066. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4067. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4068. return -1;
  4069. }
  4070.  
  4071. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  4072. (g = guild_search(atoi(message))) == NULL)
  4073. {
  4074. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4075. return -1;
  4076. }
  4077.  
  4078. count = 0;
  4079.  
  4080. iter = mapit_getallusers();
  4081. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4082. {
  4083. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  4084. {
  4085. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4086. continue; //Skip GMs greater than you.
  4087. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4088. count++;
  4089. else
  4090. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  4091. }
  4092. }
  4093. mapit_free(iter);
  4094.  
  4095. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  4096. clif_displaymessage(fd, atcmd_output);
  4097. if (count) {
  4098. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4099. clif_displaymessage(fd, atcmd_output);
  4100. }
  4101.  
  4102. return 0;
  4103. }
  4104.  
  4105. /*==========================================
  4106. * Recall online characters of a party to your location
  4107. *------------------------------------------*/
  4108. ACMD_FUNC(partyrecall)
  4109. {
  4110. struct map_session_data* pl_sd;
  4111. struct s_mapiterator* iter;
  4112. char party_name[NAME_LENGTH];
  4113. struct party_data *p;
  4114. int count;
  4115. nullpo_retr(-1, sd);
  4116.  
  4117. memset(party_name, '\0', sizeof(party_name));
  4118. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4119.  
  4120. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4121. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4122. return -1;
  4123. }
  4124.  
  4125. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4126. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4127. return -1;
  4128. }
  4129.  
  4130. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  4131. (p = party_search(atoi(message))) == NULL)
  4132. {
  4133. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4134. return -1;
  4135. }
  4136.  
  4137. count = 0;
  4138.  
  4139. iter = mapit_getallusers();
  4140. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4141. {
  4142. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  4143. {
  4144. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4145. continue; //Skip GMs greater than you.
  4146. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4147. count++;
  4148. else
  4149. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  4150. }
  4151. }
  4152. mapit_free(iter);
  4153.  
  4154. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  4155. clif_displaymessage(fd, atcmd_output);
  4156. if (count) {
  4157. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4158. clif_displaymessage(fd, atcmd_output);
  4159. }
  4160.  
  4161. return 0;
  4162. }
  4163.  
  4164. /*==========================================
  4165. *
  4166. *------------------------------------------*/
  4167. ACMD_FUNC(reloaditemdb)
  4168. {
  4169. nullpo_retr(-1, sd);
  4170. itemdb_reload();
  4171. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  4172.  
  4173. return 0;
  4174. }
  4175.  
  4176. /*==========================================
  4177. *
  4178. *------------------------------------------*/
  4179. ACMD_FUNC(reloadmobdb)
  4180. {
  4181. nullpo_retr(-1, sd);
  4182. mob_reload();
  4183. read_petdb();
  4184. merc_reload();
  4185. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  4186.  
  4187. return 0;
  4188. }
  4189.  
  4190. /*==========================================
  4191. *
  4192. *------------------------------------------*/
  4193. ACMD_FUNC(reloadskilldb)
  4194. {
  4195. nullpo_retr(-1, sd);
  4196. skill_reload();
  4197. merc_skill_reload();
  4198. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  4199.  
  4200. return 0;
  4201. }
  4202.  
  4203. /*==========================================
  4204. * @reloadatcommand - reloads atcommand_athena.conf
  4205. *------------------------------------------*/
  4206. ACMD_FUNC(reloadatcommand)
  4207. {
  4208. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4209. clif_displaymessage(fd, msg_txt(254));
  4210. return 0;
  4211. }
  4212. /*==========================================
  4213. * @reloadbattleconf - reloads battle_athena.conf
  4214. *------------------------------------------*/
  4215. ACMD_FUNC(reloadbattleconf)
  4216. {
  4217. struct Battle_Config prev_config;
  4218. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4219.  
  4220. battle_config_read(BATTLE_CONF_FILENAME);
  4221. // It can cause serius problems if we change this setting while server is UP.
  4222. battle_config.anti_mayapurple_hack = prev_config.anti_mayapurple_hack;
  4223.  
  4224. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  4225. || prev_config.item_rate_common != battle_config.item_rate_common
  4226. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  4227. || prev_config.item_rate_card != battle_config.item_rate_card
  4228. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  4229. || prev_config.item_rate_equip != battle_config.item_rate_equip
  4230. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  4231. || prev_config.item_rate_heal != battle_config.item_rate_heal
  4232. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  4233. || prev_config.item_rate_use != battle_config.item_rate_use
  4234. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  4235. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  4236. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  4237. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  4238. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  4239. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  4240. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  4241. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  4242. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  4243. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  4244. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  4245. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  4246. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  4247. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  4248. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  4249. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  4250. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  4251. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  4252. || prev_config.base_exp_rate != battle_config.base_exp_rate
  4253. || prev_config.job_exp_rate != battle_config.job_exp_rate
  4254. )
  4255. { // Exp or Drop rates changed.
  4256. mob_reload(); //Needed as well so rate changes take effect.
  4257. #ifndef TXT_ONLY
  4258. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4259. #endif
  4260. }
  4261. clif_displaymessage(fd, msg_txt(255));
  4262. return 0;
  4263. }
  4264. /*==========================================
  4265. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  4266. *------------------------------------------*/
  4267. ACMD_FUNC(reloadstatusdb)
  4268. {
  4269. status_readdb();
  4270. clif_displaymessage(fd, msg_txt(256));
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  4275. *------------------------------------------*/
  4276. ACMD_FUNC(reloadpcdb)
  4277. {
  4278. pc_readdb();
  4279. clif_displaymessage(fd, msg_txt(257));
  4280. return 0;
  4281. }
  4282.  
  4283. /*==========================================
  4284. * @reloadmotd - reloads motd.txt
  4285. *------------------------------------------*/
  4286. ACMD_FUNC(reloadmotd)
  4287. {
  4288. pc_read_motd();
  4289. clif_displaymessage(fd, msg_txt(268));
  4290. return 0;
  4291. }
  4292.  
  4293. /*==========================================
  4294. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  4295. *------------------------------------------*/
  4296. ACMD_FUNC(reloadscript)
  4297. {
  4298. nullpo_retr(-1, sd);
  4299. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4300. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4301. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4302.  
  4303. flush_fifos();
  4304. script_reload();
  4305. npc_reload();
  4306.  
  4307. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  4308.  
  4309. return 0;
  4310. }
  4311.  
  4312. /*==========================================
  4313. * @mapinfo [0-3] <map name> by MC_Cameri
  4314. * => Shows information about the map [map name]
  4315. * 0 = no additional information
  4316. * 1 = Show users in that map and their location
  4317. * 2 = Shows NPCs in that map
  4318. * 3 = Shows the shops/chats in that map (not implemented)
  4319. *------------------------------------------*/
  4320. ACMD_FUNC(mapinfo)
  4321. {
  4322. struct map_session_data* pl_sd;
  4323. struct s_mapiterator* iter;
  4324. struct npc_data *nd = NULL;
  4325. struct chat_data *cd = NULL;
  4326. char direction[12];
  4327. int i, m_id, chat_num, list = 0;
  4328. unsigned short m_index;
  4329. char mapname[24];
  4330.  
  4331. nullpo_retr(-1, sd);
  4332.  
  4333. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4334. memset(mapname, '\0', sizeof(mapname));
  4335. memset(direction, '\0', sizeof(direction));
  4336.  
  4337. sscanf(message, "%d %23[^\n]", &list, mapname);
  4338.  
  4339. if (list < 0 || list > 3) {
  4340. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4341. return -1;
  4342. }
  4343.  
  4344. if (mapname[0] == '\0') {
  4345. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4346. m_id = map_mapindex2mapid(sd->mapindex);
  4347. } else {
  4348. m_id = map_mapname2mapid(mapname);
  4349. }
  4350.  
  4351. if (m_id < 0) {
  4352. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4353. return -1;
  4354. }
  4355. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  4356.  
  4357. clif_displaymessage(fd, "------ Map Info ------");
  4358.  
  4359. // count chats (for initial message)
  4360. chat_num = 0;
  4361. iter = mapit_getallusers();
  4362. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4363. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  4364. chat_num++;
  4365. mapit_free(iter);
  4366.  
  4367. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  4368. clif_displaymessage(fd, atcmd_output);
  4369. clif_displaymessage(fd, "------ Map Flags ------");
  4370. if (map[m_id].flag.town)
  4371. clif_displaymessage(fd, "Town Map");
  4372.  
  4373. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  4374. clif_displaymessage(fd, "Autotrade Enabled");
  4375. else
  4376. clif_displaymessage(fd, "Autotrade Disabled");
  4377.  
  4378. if (map[m_id].flag.battleground)
  4379. clif_displaymessage(fd, "Battlegrounds ON");
  4380.  
  4381. strcpy(atcmd_output,"PvP Flags: ");
  4382. if (map[m_id].flag.pvp)
  4383. strcat(atcmd_output, "Pvp ON | ");
  4384. if (map[m_id].flag.pvp_noguild)
  4385. strcat(atcmd_output, "NoGuild | ");
  4386. if (map[m_id].flag.pvp_noparty)
  4387. strcat(atcmd_output, "NoParty | ");
  4388. if (map[m_id].flag.pvp_nightmaredrop)
  4389. strcat(atcmd_output, "NightmareDrop | ");
  4390. if (map[m_id].flag.pvp_nocalcrank)
  4391. strcat(atcmd_output, "NoCalcRank | ");
  4392. clif_displaymessage(fd, atcmd_output);
  4393.  
  4394. if (map[m_id].flag.pvp_event)
  4395. {
  4396. sprintf(atcmd_output,"PVP Event Flag: x1 %d | x2 %d | y1 %d | y2 %d", map[m_id].pvpe_x1, map[m_id].pvpe_x2, map[m_id].pvpe_y1, map[m_id].pvpe_y2);
  4397. clif_displaymessage(fd, atcmd_output);
  4398. }
  4399.  
  4400. strcpy(atcmd_output,"GvG Flags: ");
  4401. if (map[m_id].flag.gvg)
  4402. strcat(atcmd_output, "GvG ON | ");
  4403. if (map[m_id].flag.gvg_dungeon)
  4404. strcat(atcmd_output, "GvG Dungeon | ");
  4405. if (map[m_id].flag.gvg_castle)
  4406. strcat(atcmd_output, "GvG Castle | ");
  4407. if (map[m_id].flag.gvg_noparty)
  4408. strcat(atcmd_output, "NoParty | ");
  4409. if (map[m_id].flag.woe_set)
  4410. {
  4411. char output[64];
  4412. sprintf(output,"WoE Set %d | ", map[m_id].flag.woe_set);
  4413. strcat(atcmd_output, output);
  4414. }
  4415.  
  4416. clif_displaymessage(fd, atcmd_output);
  4417.  
  4418. strcpy(atcmd_output,"Teleport Flags: ");
  4419. if (map[m_id].flag.noteleport)
  4420. strcat(atcmd_output, "NoTeleport | ");
  4421. if (map[m_id].flag.monster_noteleport)
  4422. strcat(atcmd_output, "Monster NoTeleport | ");
  4423. if (map[m_id].flag.nowarp)
  4424. strcat(atcmd_output, "NoWarp | ");
  4425. if (map[m_id].flag.nowarpto)
  4426. strcat(atcmd_output, "NoWarpTo | ");
  4427. if (map[m_id].flag.noreturn)
  4428. strcat(atcmd_output, "NoReturn | ");
  4429. if (map[m_id].flag.nogo)
  4430. strcat(atcmd_output, "NoGo | ");
  4431. if (map[m_id].flag.nomemo)
  4432. strcat(atcmd_output, "NoMemo | ");
  4433. if (map[m_id].flag.blocked)
  4434. strcat(atcmd_output, "Blocked | ");
  4435. clif_displaymessage(fd, atcmd_output);
  4436.  
  4437. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4438. clif_displaymessage(fd, atcmd_output);
  4439.  
  4440. if (map[m_id].flag.nosave) {
  4441. if (!map[m_id].save.map)
  4442. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4443. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4444. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4445. else
  4446. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4447. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4448. clif_displaymessage(fd, atcmd_output);
  4449. }
  4450.  
  4451. strcpy(atcmd_output,"Weather Flags: ");
  4452. if (map[m_id].flag.snow)
  4453. strcat(atcmd_output, "Snow | ");
  4454. if (map[m_id].flag.fog)
  4455. strcat(atcmd_output, "Fog | ");
  4456. if (map[m_id].flag.sakura)
  4457. strcat(atcmd_output, "Sakura | ");
  4458. if (map[m_id].flag.clouds)
  4459. strcat(atcmd_output, "Clouds | ");
  4460. if (map[m_id].flag.clouds2)
  4461. strcat(atcmd_output, "Clouds2 | ");
  4462. if (map[m_id].flag.fireworks)
  4463. strcat(atcmd_output, "Fireworks | ");
  4464. if (map[m_id].flag.leaves)
  4465. strcat(atcmd_output, "Leaves | ");
  4466. if (map[m_id].flag.rain)
  4467. strcat(atcmd_output, "Rain | ");
  4468. if (map[m_id].flag.nightenabled)
  4469. strcat(atcmd_output, "Displays Night | ");
  4470. clif_displaymessage(fd, atcmd_output);
  4471.  
  4472. strcpy(atcmd_output,"Other Flags: ");
  4473. if (map[m_id].flag.nobranch)
  4474. strcat(atcmd_output, "NoBranch | ");
  4475. if (map[m_id].flag.notrade)
  4476. strcat(atcmd_output, "NoTrade | ");
  4477. if (map[m_id].flag.novending)
  4478. strcat(atcmd_output, "NoVending | ");
  4479. if (map[m_id].flag.nodrop)
  4480. strcat(atcmd_output, "NoDrop | ");
  4481. if (map[m_id].flag.noskill)
  4482. strcat(atcmd_output, "NoSkill | ");
  4483. if (map[m_id].flag.noicewall)
  4484. strcat(atcmd_output, "NoIcewall | ");
  4485. if (map[m_id].flag.allowks)
  4486. strcat(atcmd_output, "AllowKS | ");
  4487. if (map[m_id].flag.reset)
  4488. strcat(atcmd_output, "Reset | ");
  4489. clif_displaymessage(fd, atcmd_output);
  4490.  
  4491. strcpy(atcmd_output,"Other Flags: ");
  4492. if (map[m_id].nocommand)
  4493. strcat(atcmd_output, "NoCommand | ");
  4494. if (map[m_id].flag.nobaseexp)
  4495. strcat(atcmd_output, "NoBaseEXP | ");
  4496. if (map[m_id].flag.nojobexp)
  4497. strcat(atcmd_output, "NoJobEXP | ");
  4498. if (map[m_id].flag.nomobloot)
  4499. strcat(atcmd_output, "NoMobLoot | ");
  4500. if (map[m_id].flag.nomvploot)
  4501. strcat(atcmd_output, "NoMVPLoot | ");
  4502. if (map[m_id].flag.partylock)
  4503. strcat(atcmd_output, "PartyLock | ");
  4504. if (map[m_id].flag.guildlock)
  4505. strcat(atcmd_output, "GuildLock | ");
  4506. clif_displaymessage(fd, atcmd_output);
  4507.  
  4508. switch (list) {
  4509. case 0:
  4510. // Do nothing. It's list 0, no additional display.
  4511. break;
  4512. case 1:
  4513. clif_displaymessage(fd, "----- Players in Map -----");
  4514. iter = mapit_getallusers();
  4515. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4516. {
  4517. if (pl_sd->mapindex == m_index) {
  4518. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4519. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4520. clif_displaymessage(fd, atcmd_output);
  4521. }
  4522. }
  4523. mapit_free(iter);
  4524. break;
  4525. case 2:
  4526. clif_displaymessage(fd, "----- NPCs in Map -----");
  4527. for (i = 0; i < map[m_id].npc_num;)
  4528. {
  4529. nd = map[m_id].npc[i];
  4530. switch(nd->ud.dir) {
  4531. case 0: strcpy(direction, "North"); break;
  4532. case 1: strcpy(direction, "North West"); break;
  4533. case 2: strcpy(direction, "West"); break;
  4534. case 3: strcpy(direction, "South West"); break;
  4535. case 4: strcpy(direction, "South"); break;
  4536. case 5: strcpy(direction, "South East"); break;
  4537. case 6: strcpy(direction, "East"); break;
  4538. case 7: strcpy(direction, "North East"); break;
  4539. case 9: strcpy(direction, "North"); break;
  4540. default: strcpy(direction, "Unknown"); break;
  4541. }
  4542. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4543. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4544. clif_displaymessage(fd, atcmd_output);
  4545. }
  4546. break;
  4547. case 3:
  4548. clif_displaymessage(fd, "----- Chats in Map -----");
  4549. iter = mapit_getallusers();
  4550. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4551. {
  4552. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4553. pl_sd->mapindex == m_index &&
  4554. cd->usersd[0] == pl_sd)
  4555. {
  4556. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4557. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4558. clif_displaymessage(fd, atcmd_output);
  4559. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4560. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4561. clif_displaymessage(fd, atcmd_output);
  4562. }
  4563. }
  4564. mapit_free(iter);
  4565. break;
  4566. default: // normally impossible to arrive here
  4567. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4568. return -1;
  4569. break;
  4570. }
  4571.  
  4572. return 0;
  4573. }
  4574.  
  4575. /*==========================================
  4576. *
  4577. *------------------------------------------*/
  4578. ACMD_FUNC(mount_peco)
  4579. {
  4580. nullpo_retr(-1, sd);
  4581.  
  4582. if (!pc_isriding(sd)) { // if actually no peco
  4583. if (!pc_checkskill(sd, KN_RIDING))
  4584. {
  4585. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4586. return -1;
  4587. }
  4588.  
  4589. if (sd->disguise)
  4590. {
  4591. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4592. return -1;
  4593. }
  4594.  
  4595. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4596. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4597. } else { //Dismount
  4598. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4599. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4600. }
  4601.  
  4602. return 0;
  4603. }
  4604.  
  4605. /*==========================================
  4606. *Spy Commands by Syrus22
  4607. *------------------------------------------*/
  4608. ACMD_FUNC(guildspy)
  4609. {
  4610. char guild_name[NAME_LENGTH];
  4611. struct guild *g;
  4612. nullpo_retr(-1, sd);
  4613.  
  4614. memset(guild_name, '\0', sizeof(guild_name));
  4615. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4616.  
  4617. if (!enable_spy)
  4618. {
  4619. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4620. return -1;
  4621. }
  4622. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4623. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4624. return -1;
  4625. }
  4626.  
  4627. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4628. (g = guild_search(atoi(message))) != NULL) {
  4629. if (sd->guildspy == g->guild_id) {
  4630. sd->guildspy = 0;
  4631. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4632. clif_displaymessage(fd, atcmd_output);
  4633. } else {
  4634. sd->guildspy = g->guild_id;
  4635. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4636. clif_displaymessage(fd, atcmd_output);
  4637. }
  4638. } else {
  4639. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4640. return -1;
  4641. }
  4642.  
  4643. return 0;
  4644. }
  4645.  
  4646. /*==========================================
  4647. *
  4648. *------------------------------------------*/
  4649. ACMD_FUNC(partyspy)
  4650. {
  4651. char party_name[NAME_LENGTH];
  4652. struct party_data *p;
  4653. nullpo_retr(-1, sd);
  4654.  
  4655. memset(party_name, '\0', sizeof(party_name));
  4656. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4657.  
  4658. if (!enable_spy)
  4659. {
  4660. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4661. return -1;
  4662. }
  4663.  
  4664. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4665. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4666. return -1;
  4667. }
  4668.  
  4669. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4670. (p = party_search(atoi(message))) != NULL) {
  4671. if (sd->partyspy == p->party.party_id) {
  4672. sd->partyspy = 0;
  4673. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4674. clif_displaymessage(fd, atcmd_output);
  4675. } else {
  4676. sd->partyspy = p->party.party_id;
  4677. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4678. clif_displaymessage(fd, atcmd_output);
  4679. }
  4680. } else {
  4681. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4682. return -1;
  4683. }
  4684.  
  4685. return 0;
  4686. }
  4687.  
  4688. /*==========================================
  4689. * @repairall [Valaris]
  4690. *------------------------------------------*/
  4691. ACMD_FUNC(repairall)
  4692. {
  4693. int count, i;
  4694. nullpo_retr(-1, sd);
  4695.  
  4696. count = 0;
  4697. for (i = 0; i < MAX_INVENTORY; i++) {
  4698. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4699. sd->status.inventory[i].attribute = 0;
  4700. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4701. count++;
  4702. }
  4703. }
  4704.  
  4705. if (count > 0) {
  4706. clif_misceffect(&sd->bl, 3);
  4707. clif_equiplist(sd);
  4708. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4709. } else {
  4710. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4711. return -1;
  4712. }
  4713.  
  4714. return 0;
  4715. }
  4716.  
  4717. /*==========================================
  4718. * @nuke [Valaris]
  4719. *------------------------------------------*/
  4720. ACMD_FUNC(nuke)
  4721. {
  4722. struct map_session_data *pl_sd;
  4723. nullpo_retr(-1, sd);
  4724.  
  4725. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4726.  
  4727. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4728. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4729. return -1;
  4730. }
  4731.  
  4732. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4733. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4734. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4735. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4736. } else {
  4737. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4738. return -1;
  4739. }
  4740. } else {
  4741. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4742. return -1;
  4743. }
  4744.  
  4745. return 0;
  4746. }
  4747.  
  4748. /*==========================================
  4749. * @tonpc
  4750. *------------------------------------------*/
  4751. ACMD_FUNC(tonpc)
  4752. {
  4753. char npcname[NAME_LENGTH+1];
  4754. struct npc_data *nd;
  4755.  
  4756. nullpo_retr(-1, sd);
  4757.  
  4758. memset(npcname, 0, sizeof(npcname));
  4759.  
  4760. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4761. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4762. return -1;
  4763. }
  4764.  
  4765. if ((nd = npc_name2id(npcname)) != NULL) {
  4766. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4767. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4768. else
  4769. return -1;
  4770. } else {
  4771. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4772. return -1;
  4773. }
  4774.  
  4775. return 0;
  4776. }
  4777.  
  4778. /*==========================================
  4779. *
  4780. *------------------------------------------*/
  4781. ACMD_FUNC(shownpc)
  4782. {
  4783. char NPCname[NAME_LENGTH+1];
  4784. nullpo_retr(-1, sd);
  4785.  
  4786. memset(NPCname, '\0', sizeof(NPCname));
  4787.  
  4788. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4789. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4790. return -1;
  4791. }
  4792.  
  4793. if (npc_name2id(NPCname) != NULL) {
  4794. npc_enable(NPCname, 1);
  4795. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4796. } else {
  4797. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4798. return -1;
  4799. }
  4800.  
  4801. return 0;
  4802. }
  4803.  
  4804. /*==========================================
  4805. *
  4806. *------------------------------------------*/
  4807. ACMD_FUNC(hidenpc)
  4808. {
  4809. char NPCname[NAME_LENGTH+1];
  4810. nullpo_retr(-1, sd);
  4811.  
  4812. memset(NPCname, '\0', sizeof(NPCname));
  4813.  
  4814. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4815. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4816. return -1;
  4817. }
  4818.  
  4819. if (npc_name2id(NPCname) == NULL) {
  4820. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4821. return -1;
  4822. }
  4823.  
  4824. npc_enable(NPCname, 0);
  4825. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4826. return 0;
  4827. }
  4828.  
  4829. ACMD_FUNC(loadnpc)
  4830. {
  4831. FILE *fp;
  4832.  
  4833. if (!message || !*message) {
  4834. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4835. return -1;
  4836. }
  4837.  
  4838. // check if script file exists
  4839. if ((fp = fopen(message, "r")) == NULL) {
  4840. clif_displaymessage(fd, msg_txt(261));
  4841. return -1;
  4842. }
  4843. fclose(fp);
  4844.  
  4845. // add to list of script sources and run it
  4846. npc_addsrcfile(message);
  4847. npc_parsesrcfile(message);
  4848. npc_read_event_script();
  4849.  
  4850. clif_displaymessage(fd, msg_txt(262));
  4851.  
  4852. return 0;
  4853. }
  4854.  
  4855. ACMD_FUNC(unloadnpc)
  4856. {
  4857. struct npc_data *nd;
  4858. char NPCname[NAME_LENGTH+1];
  4859. nullpo_retr(-1, sd);
  4860.  
  4861. memset(NPCname, '\0', sizeof(NPCname));
  4862.  
  4863. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4864. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4865. return -1;
  4866. }
  4867.  
  4868. if ((nd = npc_name2id(NPCname)) == NULL) {
  4869. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4870. return -1;
  4871. }
  4872.  
  4873. npc_unload_duplicates(nd);
  4874. npc_unload(nd);
  4875. npc_read_event_script();
  4876. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4877. return 0;
  4878. }
  4879.  
  4880. /*==========================================
  4881. * time in txt for time command (by [Yor])
  4882. *------------------------------------------*/
  4883. char* txt_time(unsigned int duration)
  4884. {
  4885. int days, hours, minutes, seconds;
  4886. char temp[CHAT_SIZE_MAX];
  4887. static char temp1[CHAT_SIZE_MAX];
  4888.  
  4889. memset(temp, '\0', sizeof(temp));
  4890. memset(temp1, '\0', sizeof(temp1));
  4891.  
  4892. days = duration / (60 * 60 * 24);
  4893. duration = duration - (60 * 60 * 24 * days);
  4894. hours = duration / (60 * 60);
  4895. duration = duration - (60 * 60 * hours);
  4896. minutes = duration / 60;
  4897. seconds = duration - (60 * minutes);
  4898.  
  4899. if (days < 2)
  4900. sprintf(temp, msg_txt(219), days); // %d day
  4901. else
  4902. sprintf(temp, msg_txt(220), days); // %d days
  4903. if (hours < 2)
  4904. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4905. else
  4906. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4907. if (minutes < 2)
  4908. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4909. else
  4910. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4911. if (seconds < 2)
  4912. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4913. else
  4914. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4915.  
  4916. return temp1;
  4917. }
  4918.  
  4919. /*==========================================
  4920. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4921. * Calculation management of GM modification (@day/@night GM commands) is done
  4922. *------------------------------------------*/
  4923. ACMD_FUNC(servertime)
  4924. {
  4925. const struct TimerData * timer_data;
  4926. const struct TimerData * timer_data2;
  4927. time_t time_server; // variable for number of seconds (used with time() function)
  4928. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4929. char temp[CHAT_SIZE_MAX];
  4930. nullpo_retr(-1, sd);
  4931.  
  4932. memset(temp, '\0', sizeof(temp));
  4933.  
  4934. time(&time_server); // get time in seconds since 1/1/1970
  4935. datetime = localtime(&time_server); // convert seconds in structure
  4936. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4937. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4938. clif_displaymessage(fd, temp);
  4939.  
  4940. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4941. if (night_flag == 0)
  4942. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4943. else
  4944. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4945. } else if (battle_config.night_duration == 0)
  4946. if (night_flag == 1) { // we start with night
  4947. timer_data = get_timer(day_timer_tid);
  4948. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4949. clif_displaymessage(fd, temp);
  4950. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4951. } else
  4952. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4953. else if (battle_config.day_duration == 0)
  4954. if (night_flag == 0) { // we start with day
  4955. timer_data = get_timer(night_timer_tid);
  4956. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4957. clif_displaymessage(fd, temp);
  4958. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4959. } else
  4960. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4961. else {
  4962. if (night_flag == 0) {
  4963. timer_data = get_timer(night_timer_tid);
  4964. timer_data2 = get_timer(day_timer_tid);
  4965. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4966. clif_displaymessage(fd, temp);
  4967. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4968. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4969. else
  4970. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4971. clif_displaymessage(fd, temp);
  4972. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4973. clif_displaymessage(fd, temp);
  4974. } else {
  4975. timer_data = get_timer(day_timer_tid);
  4976. timer_data2 = get_timer(night_timer_tid);
  4977. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4978. clif_displaymessage(fd, temp);
  4979. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4980. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  4981. else
  4982. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4983. clif_displaymessage(fd, temp);
  4984. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4985. clif_displaymessage(fd, temp);
  4986. }
  4987. }
  4988.  
  4989. return 0;
  4990. }
  4991.  
  4992. //Added by Coltaro
  4993. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  4994. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4995. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4996. {
  4997. const int factor_year = 518400; //12*30*24*60 = 518400
  4998. const int factor_month = 43200; //30*24*60 = 43200
  4999. const int factor_day = 1440; //24*60 = 1440
  5000. const int factor_hour = 60;
  5001.  
  5002. *year = jailtime/factor_year;
  5003. jailtime -= *year*factor_year;
  5004. *month = jailtime/factor_month;
  5005. jailtime -= *month*factor_month;
  5006. *day = jailtime/factor_day;
  5007. jailtime -= *day*factor_day;
  5008. *hour = jailtime/factor_hour;
  5009. jailtime -= *hour*factor_hour;
  5010. *minute = jailtime;
  5011.  
  5012. *year = *year > 0? *year : 0;
  5013. *month = *month > 0? *month : 0;
  5014. *day = *day > 0? *day : 0;
  5015. *hour = *hour > 0? *hour : 0;
  5016. *minute = *minute > 0? *minute : 0;
  5017. return;
  5018. }
  5019.  
  5020. /*==========================================
  5021. * @jail <char_name> by [Yor]
  5022. * Special warp! No check with nowarp and nowarpto flag
  5023. *------------------------------------------*/
  5024. ACMD_FUNC(jail)
  5025. {
  5026. struct map_session_data *pl_sd;
  5027. int x, y;
  5028. unsigned short m_index;
  5029. nullpo_retr(-1, sd);
  5030.  
  5031. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5032.  
  5033. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5034. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5035. return -1;
  5036. }
  5037.  
  5038. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5039. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5040. return -1;
  5041. }
  5042.  
  5043. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5044. { // you can jail only lower or same GM
  5045. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5046. return -1;
  5047. }
  5048.  
  5049. if (pl_sd->sc.data[SC_JAILED])
  5050. {
  5051. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5052. return -1;
  5053. }
  5054.  
  5055. switch(rand() % 2) { //Jail Locations
  5056. case 0:
  5057. m_index = mapindex_name2id(MAP_JAIL);
  5058. x = 24;
  5059. y = 75;
  5060. break;
  5061. default:
  5062. m_index = mapindex_name2id(MAP_JAIL);
  5063. x = 49;
  5064. y = 75;
  5065. break;
  5066. }
  5067.  
  5068. //Duration of INT_MAX to specify infinity.
  5069. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  5070. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5071. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5072. return 0;
  5073. }
  5074.  
  5075. /*==========================================
  5076. * @unjail/@discharge <char_name> by [Yor]
  5077. * Special warp! No check with nowarp and nowarpto flag
  5078. *------------------------------------------*/
  5079. ACMD_FUNC(unjail)
  5080. {
  5081. struct map_session_data *pl_sd;
  5082.  
  5083. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5084.  
  5085. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5086. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5087. return -1;
  5088. }
  5089.  
  5090. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5091. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5092. return -1;
  5093. }
  5094.  
  5095. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5096.  
  5097. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5098. return -1;
  5099. }
  5100.  
  5101. if (!pl_sd->sc.data[SC_JAILED])
  5102. {
  5103. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5104. return -1;
  5105. }
  5106.  
  5107. //Reset jail time to 1 sec.
  5108. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  5109. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  5110. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5111. return 0;
  5112. }
  5113.  
  5114. ACMD_FUNC(jailfor)
  5115. {
  5116. struct map_session_data *pl_sd = NULL;
  5117. int year, month, day, hour, minute, value;
  5118. char * modif_p;
  5119. int jailtime = 0,x,y;
  5120. short m_index = 0;
  5121. nullpo_retr(-1, sd);
  5122.  
  5123. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5124. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5125. return -1;
  5126. }
  5127.  
  5128. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5129.  
  5130. modif_p = atcmd_output;
  5131. year = month = day = hour = minute = 0;
  5132. while (modif_p[0] != '\0') {
  5133. value = atoi(modif_p);
  5134. if (value == 0)
  5135. modif_p++;
  5136. else {
  5137. if (modif_p[0] == '-' || modif_p[0] == '+')
  5138. modif_p++;
  5139. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5140. modif_p++;
  5141. if (modif_p[0] == 'n') {
  5142. minute = value;
  5143. modif_p++;
  5144. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  5145. minute = value;
  5146. modif_p = modif_p + 2;
  5147. } else if (modif_p[0] == 'h') {
  5148. hour = value;
  5149. modif_p++;
  5150. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5151. day = value;
  5152. modif_p++;
  5153. } else if (modif_p[0] == 'm') {
  5154. month = value;
  5155. modif_p++;
  5156. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5157. year = value;
  5158. modif_p++;
  5159. } else if (modif_p[0] != '\0') {
  5160. modif_p++;
  5161. }
  5162. }
  5163. }
  5164.  
  5165. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5166. clif_displaymessage(fd, "Invalid time for jail command.");
  5167. return -1;
  5168. }
  5169.  
  5170. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5171. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5172. return -1;
  5173. }
  5174.  
  5175. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5176. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5177. return -1;
  5178. }
  5179.  
  5180. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5181.  
  5182. if(jailtime==0) {
  5183. clif_displaymessage(fd, "Invalid time for jail command.");
  5184. return -1;
  5185. }
  5186.  
  5187. //Added by Coltaro
  5188. if(pl_sd->sc.data[SC_JAILED] &&
  5189. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  5190. { //Update the player's jail time
  5191. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  5192. if (jailtime <= 0) {
  5193. jailtime = 0;
  5194. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5195. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5196. } else {
  5197. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5198. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  5199. clif_displaymessage(pl_sd->fd, atcmd_output);
  5200. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  5201. clif_displaymessage(fd, atcmd_output);
  5202. }
  5203. } else if (jailtime < 0) {
  5204. clif_displaymessage(fd, "Invalid time for jail command.");
  5205. return -1;
  5206. }
  5207.  
  5208. //Jail locations, add more as you wish.
  5209. switch(rand()%2)
  5210. {
  5211. case 1: //Jail #1
  5212. m_index = mapindex_name2id(MAP_JAIL);
  5213. x = 49; y = 75;
  5214. break;
  5215. default: //Default Jail
  5216. m_index = mapindex_name2id(MAP_JAIL);
  5217. x = 24; y = 75;
  5218. break;
  5219. }
  5220.  
  5221. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  5222. return 0;
  5223. }
  5224.  
  5225.  
  5226. //By Coltaro
  5227. ACMD_FUNC(jailtime)
  5228. {
  5229. int year, month, day, hour, minute;
  5230.  
  5231. nullpo_retr(-1, sd);
  5232.  
  5233. if (!sd->sc.data[SC_JAILED]) {
  5234. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5235. return -1;
  5236. }
  5237.  
  5238. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  5239. clif_displaymessage(fd, "You have been jailed indefinitely.");
  5240. return 0;
  5241. }
  5242.  
  5243. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5244. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5245. return -1;
  5246. }
  5247.  
  5248. //Get remaining jail time
  5249. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  5250. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  5251.  
  5252. clif_displaymessage(fd, atcmd_output);
  5253.  
  5254. return 0;
  5255. }
  5256.  
  5257. /*==========================================
  5258. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5259. *------------------------------------------*/
  5260. ACMD_FUNC(disguise)
  5261. {
  5262. int id = 0;
  5263. nullpo_retr(-1, sd);
  5264.  
  5265. if (!message || !*message) {
  5266. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5267. return -1;
  5268. }
  5269.  
  5270. if ((id = atoi(message)) > 0)
  5271. { //Acquired an ID
  5272. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5273. id = 0; //Invalid id for either mobs or npcs.
  5274. } else { //Acquired a Name
  5275. if ((id = mobdb_searchname(message)) == 0)
  5276. {
  5277. struct npc_data* nd = npc_name2id(message);
  5278. if (nd != NULL)
  5279. id = nd->class_;
  5280. }
  5281. }
  5282.  
  5283. if (id == 0)
  5284. {
  5285. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  5286. return -1;
  5287. }
  5288.  
  5289. if(pc_isriding(sd))
  5290. {
  5291. //FIXME: wrong message [ultramage]
  5292. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  5293. return -1;
  5294. }
  5295.  
  5296. pc_disguise(sd, id);
  5297. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5298.  
  5299. return 0;
  5300. }
  5301.  
  5302. /*==========================================
  5303. * DisguiseAll
  5304. *------------------------------------------*/
  5305. ACMD_FUNC(disguiseall)
  5306. {
  5307. int mob_id=0;
  5308. struct map_session_data *pl_sd;
  5309. struct s_mapiterator* iter;
  5310. nullpo_retr(-1, sd);
  5311.  
  5312. if (!message || !*message) {
  5313. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  5314. return -1;
  5315. }
  5316.  
  5317. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5318. mob_id = atoi(message);
  5319.  
  5320. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  5321. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  5322. return -1;
  5323. }
  5324.  
  5325. iter = mapit_getallusers();
  5326. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  5327. {
  5328. if( !pc_isriding(pl_sd) )
  5329. pc_disguise(pl_sd, mob_id);
  5330. }
  5331. mapit_free(iter);
  5332.  
  5333. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5334. return 0;
  5335. }
  5336.  
  5337. /*==========================================
  5338. * DisguiseGuild
  5339. *------------------------------------------*/
  5340. ACMD_FUNC(disguiseguild)
  5341. {
  5342. struct map_session_data *pl_sd;
  5343. int id = 0, i;
  5344. char guild_name[NAME_LENGTH], name[NAME_LENGTH];
  5345. struct guild *g;
  5346.  
  5347. memset(guild_name, '\0', sizeof(guild_name));
  5348. memset(name, '\0', sizeof(name));
  5349.  
  5350. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", name, guild_name) < 2 )
  5351. {
  5352. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @disguiseguild <mob_name/id>,<guild_name/id>).");
  5353. return -1;
  5354. }
  5355.  
  5356. if( (id = atoi(name)) > 0 )
  5357. {
  5358. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  5359. id = 0;
  5360. }
  5361. else
  5362. {
  5363. if( (id = mobdb_searchname(name)) == 0 )
  5364. {
  5365. struct npc_data* nd = npc_name2id(name);
  5366. if( nd != NULL )
  5367. id = nd->class_;
  5368. }
  5369. }
  5370.  
  5371. if( id == 0 )
  5372. {
  5373. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  5374. return -1;
  5375. }
  5376.  
  5377. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(guild_name))) == NULL )
  5378. {
  5379. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5380. return -1;
  5381. }
  5382.  
  5383. for( i = 0; i < g->max_member; i++ )
  5384. {
  5385. if( (pl_sd = g->member[i].sd ) == NULL )
  5386. continue;
  5387.  
  5388. if( pc_isriding(pl_sd) )
  5389. continue;
  5390.  
  5391. pc_disguise(pl_sd, id);
  5392. }
  5393.  
  5394. return 0;
  5395. }
  5396.  
  5397. /*==========================================
  5398. * @undisguise by [Yor]
  5399. *------------------------------------------*/
  5400. ACMD_FUNC(undisguise)
  5401. {
  5402. nullpo_retr(-1, sd);
  5403. if (sd->disguise) {
  5404. pc_disguise(sd, 0);
  5405. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5406. } else {
  5407. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5408. return -1;
  5409. }
  5410.  
  5411. return 0;
  5412. }
  5413.  
  5414. /*==========================================
  5415. * UndisguiseAll
  5416. *------------------------------------------*/
  5417. ACMD_FUNC(undisguiseall)
  5418. {
  5419. struct map_session_data *pl_sd;
  5420. struct s_mapiterator* iter;
  5421. nullpo_retr(-1, sd);
  5422.  
  5423. iter = mapit_getallusers();
  5424. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  5425. if( pl_sd->disguise )
  5426. pc_disguise(pl_sd, 0);
  5427. mapit_free(iter);
  5428.  
  5429. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5430.  
  5431. return 0;
  5432. }
  5433.  
  5434. /*==========================================
  5435. * @exp by [Skotlex]
  5436. *------------------------------------------*/
  5437. ACMD_FUNC(exp)
  5438. {
  5439. char output[CHAT_SIZE_MAX];
  5440. double nextb, nextj;
  5441. nullpo_retr(-1, sd);
  5442. memset(output, '\0', sizeof(output));
  5443.  
  5444. nextb = pc_nextbaseexp(sd);
  5445. if (nextb)
  5446. nextb = sd->status.base_exp*100.0/nextb;
  5447.  
  5448. nextj = pc_nextjobexp(sd);
  5449. if (nextj)
  5450. nextj = sd->status.job_exp*100.0/nextj;
  5451.  
  5452. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5453. clif_displaymessage(fd, output);
  5454. return 0;
  5455. }
  5456.  
  5457.  
  5458. /*==========================================
  5459. * @broadcast by [Valaris]
  5460. *------------------------------------------*/
  5461. ACMD_FUNC(broadcast)
  5462. {
  5463. nullpo_retr(-1, sd);
  5464.  
  5465. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5466.  
  5467. if (!message || !*message) {
  5468. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5469. return -1;
  5470. }
  5471.  
  5472. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5473. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  5474.  
  5475. return 0;
  5476. }
  5477.  
  5478. /*==========================================
  5479. * @localbroadcast by [Valaris]
  5480. *------------------------------------------*/
  5481. ACMD_FUNC(localbroadcast)
  5482. {
  5483. nullpo_retr(-1, sd);
  5484.  
  5485. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5486.  
  5487. if (!message || !*message) {
  5488. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5489. return -1;
  5490. }
  5491.  
  5492. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5493.  
  5494. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  5495.  
  5496. return 0;
  5497. }
  5498.  
  5499. /*==========================================
  5500. * @email <actual@email> <new@email> by [Yor]
  5501. *------------------------------------------*/
  5502. ACMD_FUNC(email)
  5503. {
  5504. char actual_email[100];
  5505. char new_email[100];
  5506. nullpo_retr(-1, sd);
  5507.  
  5508. memset(actual_email, '\0', sizeof(actual_email));
  5509. memset(new_email, '\0', sizeof(new_email));
  5510.  
  5511. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5512. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5513. return -1;
  5514. }
  5515.  
  5516. if (e_mail_check(actual_email) == 0) {
  5517. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give [email protected].
  5518. return -1;
  5519. } else if (e_mail_check(new_email) == 0) {
  5520. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5521. return -1;
  5522. } else if (strcmpi(new_email, "[email protected]") == 0) {
  5523. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5524. return -1;
  5525. } else if (strcmpi(actual_email, new_email) == 0) {
  5526. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5527. return -1;
  5528. }
  5529.  
  5530. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5531. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5532. return 0;
  5533. }
  5534.  
  5535. /*==========================================
  5536. *@effect
  5537. *------------------------------------------*/
  5538. ACMD_FUNC(effect)
  5539. {
  5540. int type = 0, flag = 0;
  5541. nullpo_retr(-1, sd);
  5542.  
  5543. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  5544. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  5545. return -1;
  5546. }
  5547.  
  5548. clif_specialeffect(&sd->bl, type, (send_target)flag);
  5549. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5550. return 0;
  5551. }
  5552.  
  5553. /*==========================================
  5554. * @killer by MouseJstr
  5555. * enable killing players even when not in pvp
  5556. *------------------------------------------*/
  5557. ACMD_FUNC(killer)
  5558. {
  5559. nullpo_retr(-1, sd);
  5560. sd->state.killer = !sd->state.killer;
  5561.  
  5562. if(sd->state.killer)
  5563. clif_displaymessage(fd, msg_txt(241));
  5564. else {
  5565. clif_displaymessage(fd, msg_txt(287));
  5566. pc_stop_attack(sd);
  5567. }
  5568. return 0;
  5569. }
  5570.  
  5571. /*==========================================
  5572. * @killable by MouseJstr
  5573. * enable other people killing you
  5574. *------------------------------------------*/
  5575. ACMD_FUNC(killable)
  5576. {
  5577. nullpo_retr(-1, sd);
  5578. sd->state.killable = !sd->state.killable;
  5579.  
  5580. if(sd->state.killable)
  5581. clif_displaymessage(fd, msg_txt(242));
  5582. else {
  5583. clif_displaymessage(fd, msg_txt(288));
  5584. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  5585. }
  5586. return 0;
  5587. }
  5588.  
  5589. /*==========================================
  5590. * @skillon by MouseJstr
  5591. * turn skills on for the map
  5592. *------------------------------------------*/
  5593. ACMD_FUNC(skillon)
  5594. {
  5595. nullpo_retr(-1, sd);
  5596. map[sd->bl.m].flag.noskill = 0;
  5597. clif_displaymessage(fd, msg_txt(244));
  5598. return 0;
  5599. }
  5600.  
  5601. /*==========================================
  5602. * @skilloff by MouseJstr
  5603. * Turn skills off on the map
  5604. *------------------------------------------*/
  5605. ACMD_FUNC(skilloff)
  5606. {
  5607. nullpo_retr(-1, sd);
  5608. map[sd->bl.m].flag.noskill = 1;
  5609. clif_displaymessage(fd, msg_txt(243));
  5610. return 0;
  5611. }
  5612.  
  5613. /*==========================================
  5614. * @npcmove by MouseJstr
  5615. * move a npc
  5616. *------------------------------------------*/
  5617. ACMD_FUNC(npcmove)
  5618. {
  5619. int x = 0, y = 0, m;
  5620. struct npc_data *nd = 0;
  5621. nullpo_retr(-1, sd);
  5622. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  5623.  
  5624. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  5625. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  5626. return -1;
  5627. }
  5628.  
  5629. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  5630. {
  5631. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5632. return -1;
  5633. }
  5634.  
  5635. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  5636. {
  5637. clif_displaymessage(fd, "NPC is not on this map.");
  5638. return -1; //Not on a map.
  5639. }
  5640.  
  5641. x = cap_value(x, 0, map[m].xs-1);
  5642. y = cap_value(y, 0, map[m].ys-1);
  5643. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5644. map_moveblock(&nd->bl, x, y, gettick());
  5645. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5646. clif_displaymessage(fd, "NPC moved.");
  5647.  
  5648. return 0;
  5649. }
  5650.  
  5651. /*==========================================
  5652. * @addwarp by MouseJstr
  5653. * Create a new static warp point.
  5654. *------------------------------------------*/
  5655. ACMD_FUNC(addwarp)
  5656. {
  5657. char mapname[32];
  5658. int x,y;
  5659. unsigned short m;
  5660. struct npc_data* nd;
  5661.  
  5662. nullpo_retr(-1, sd);
  5663.  
  5664. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  5665. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  5666. return -1;
  5667. }
  5668.  
  5669. m = mapindex_name2id(mapname);
  5670. if( m == 0 )
  5671. {
  5672. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  5673. clif_displaymessage(fd, atcmd_output);
  5674. return -1;
  5675. }
  5676.  
  5677. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5678. if( nd == NULL )
  5679. return -1;
  5680.  
  5681. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  5682. clif_displaymessage(fd, atcmd_output);
  5683. return 0;
  5684. }
  5685.  
  5686. /*==========================================
  5687. * @follow by [MouseJstr]
  5688. * Follow a player .. staying no more then 5 spaces away
  5689. *------------------------------------------*/
  5690. ACMD_FUNC(follow)
  5691. {
  5692. struct map_session_data *pl_sd = NULL;
  5693. nullpo_retr(-1, sd);
  5694.  
  5695. if (!message || !*message) {
  5696. if (sd->followtarget == -1)
  5697. return -1;
  5698.  
  5699. pc_stop_following (sd);
  5700. clif_displaymessage(fd, "Follow mode OFF.");
  5701. return 0;
  5702. }
  5703.  
  5704. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5705. {
  5706. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5707. return -1;
  5708. }
  5709.  
  5710. if (sd->followtarget == pl_sd->bl.id) {
  5711. pc_stop_following (sd);
  5712. clif_displaymessage(fd, "Follow mode OFF.");
  5713. } else {
  5714. pc_follow(sd, pl_sd->bl.id);
  5715. clif_displaymessage(fd, "Follow mode ON.");
  5716. }
  5717.  
  5718. return 0;
  5719. }
  5720.  
  5721.  
  5722. /*==========================================
  5723. * @dropall by [MouseJstr]
  5724. * Drop all your possession on the ground
  5725. *------------------------------------------*/
  5726. ACMD_FUNC(dropall)
  5727. {
  5728. int i;
  5729. nullpo_retr(-1, sd);
  5730. for (i = 0; i < MAX_INVENTORY; i++) {
  5731. if (sd->status.inventory[i].amount) {
  5732. if(sd->status.inventory[i].equip != 0)
  5733. pc_unequipitem(sd, i, 3);
  5734. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  5735. }
  5736. }
  5737. return 0;
  5738. }
  5739.  
  5740. /*==========================================
  5741. * @storeall by [MouseJstr]
  5742. * Put everything into storage
  5743. *------------------------------------------*/
  5744. ACMD_FUNC(storeall)
  5745. {
  5746. int i;
  5747. nullpo_retr(-1, sd);
  5748.  
  5749. if (sd->state.storage_flag != 1)
  5750. { //Open storage.
  5751. if( storage_storageopen(sd) == 1 ) {
  5752. clif_displaymessage(fd, "You can't open the storage currently.");
  5753. return -1;
  5754. }
  5755. }
  5756.  
  5757. for (i = 0; i < MAX_INVENTORY; i++) {
  5758. if (sd->status.inventory[i].amount) {
  5759. if(sd->status.inventory[i].equip != 0)
  5760. pc_unequipitem(sd, i, 3);
  5761. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  5762. }
  5763. }
  5764. storage_storageclose(sd);
  5765.  
  5766. clif_displaymessage(fd, "It is done");
  5767. return 0;
  5768. }
  5769.  
  5770. /*==========================================
  5771. * @skillid by [MouseJstr]
  5772. * lookup a skill by name
  5773. *------------------------------------------*/
  5774. ACMD_FUNC(skillid)
  5775. {
  5776. int skillen, idx;
  5777. nullpo_retr(-1, sd);
  5778.  
  5779. if (!message || !*message)
  5780. {
  5781. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5782. return -1;
  5783. }
  5784.  
  5785. skillen = strlen(message);
  5786.  
  5787. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5788. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5789. {
  5790. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5791. clif_displaymessage(fd, atcmd_output);
  5792. }
  5793. }
  5794.  
  5795. return 0;
  5796. }
  5797. /*==========================================
  5798. * @blockskill
  5799. * Block/UnBlock Skill Usage
  5800. *------------------------------------------*/
  5801. ACMD_FUNC(blockskill)
  5802. {
  5803. int idx = atoi(message);
  5804. if( (idx = skill_get_index(idx)) > 0 )
  5805. {
  5806. skill_db[idx].blocked = !skill_db[idx].blocked;
  5807. if( skill_db[idx].blocked )
  5808. sprintf(atcmd_output, "Blocked usage of Skill %d: %s", idx, skill_db[idx].desc);
  5809. else
  5810. sprintf(atcmd_output, "Allowed usage of Skill %d: %s", idx, skill_db[idx].desc);
  5811.  
  5812. clif_displaymessage(fd, atcmd_output);
  5813. return 0;
  5814. }
  5815. else
  5816. {
  5817. clif_displaymessage(fd, "Skill not found...");
  5818. return -1;
  5819. }
  5820. }
  5821.  
  5822. /*==========================================
  5823. * @useskill by [MouseJstr]
  5824. * A way of using skills without having to find them in the skills menu
  5825. *------------------------------------------*/
  5826. ACMD_FUNC(useskill)
  5827. {
  5828. struct map_session_data *pl_sd = NULL;
  5829. struct block_list *bl;
  5830. int skillnum;
  5831. int skilllv;
  5832. char target[100];
  5833. nullpo_retr(-1, sd);
  5834.  
  5835. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5836. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5837. return -1;
  5838. }
  5839.  
  5840. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5841. {
  5842. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5843. return -1;
  5844. }
  5845.  
  5846. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5847. {
  5848. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5849. return -1;
  5850. }
  5851.  
  5852. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5853. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5854. bl = &sd->hd->bl;
  5855. else
  5856. bl = &sd->bl;
  5857.  
  5858. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5859. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5860. else
  5861. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5862.  
  5863. return 0;
  5864. }
  5865.  
  5866. /*==========================================
  5867. * @displayskill by [Skotlex]
  5868. * Debug command to locate new skill IDs. It sends the
  5869. * three possible skill-effect packets to the area.
  5870. *------------------------------------------*/
  5871. ACMD_FUNC(displayskill)
  5872. {
  5873. struct status_data * status;
  5874. unsigned int tick;
  5875. int skillnum;
  5876. int skilllv = 1;
  5877. nullpo_retr(-1, sd);
  5878.  
  5879. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5880. {
  5881. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5882. return -1;
  5883. }
  5884. status = status_get_status_data(&sd->bl);
  5885. tick = gettick();
  5886. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5887. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5888. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5889. return 0;
  5890. }
  5891.  
  5892. /*==========================================
  5893. * @skilltree by [MouseJstr]
  5894. * prints the skill tree for a player required to get to a skill
  5895. *------------------------------------------*/
  5896. ACMD_FUNC(skilltree)
  5897. {
  5898. struct map_session_data *pl_sd = NULL;
  5899. int skillnum;
  5900. int meets, j, c=0;
  5901. char target[NAME_LENGTH];
  5902. struct skill_tree_entry *ent;
  5903. nullpo_retr(-1, sd);
  5904.  
  5905. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5906. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5907. return -1;
  5908. }
  5909.  
  5910. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5911. {
  5912. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5913. return -1;
  5914. }
  5915.  
  5916. c = pc_calc_skilltree_normalize_job(pl_sd);
  5917. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5918.  
  5919. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, NV_BASIC));
  5920. clif_displaymessage(fd, atcmd_output);
  5921.  
  5922. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5923. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5924. {
  5925. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5926. clif_displaymessage(fd, atcmd_output);
  5927. return 0;
  5928. }
  5929.  
  5930. ent = &skill_tree[c][j];
  5931.  
  5932. meets = 1;
  5933. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5934. {
  5935. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5936. {
  5937. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5938. clif_displaymessage(fd, atcmd_output);
  5939. meets = 0;
  5940. }
  5941. }
  5942. if (meets == 1) {
  5943. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5944. clif_displaymessage(fd, atcmd_output);
  5945. }
  5946.  
  5947. return 0;
  5948. }
  5949.  
  5950. // Hand a ring with partners name on it to this char
  5951. void getring (struct map_session_data* sd)
  5952. {
  5953. int flag, item_id;
  5954. struct item item_tmp;
  5955. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5956.  
  5957. memset(&item_tmp, 0, sizeof(item_tmp));
  5958. item_tmp.nameid = item_id;
  5959. item_tmp.identify = 1;
  5960. item_tmp.card[0] = 255;
  5961. item_tmp.card[2] = sd->status.partner_id;
  5962. item_tmp.card[3] = sd->status.partner_id >> 16;
  5963.  
  5964. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5965. clif_additem(sd,0,0,flag);
  5966. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,sd->status.guild_id,0);
  5967. }
  5968. }
  5969.  
  5970. /*==========================================
  5971. * @marry by [MouseJstr], fixed by Lupus
  5972. * Marry two players
  5973. *------------------------------------------*/
  5974. ACMD_FUNC(marry)
  5975. {
  5976. struct map_session_data *pl_sd1 = NULL;
  5977. struct map_session_data *pl_sd2 = NULL;
  5978. char player1[128], player2[128]; //Length used for return error msgs
  5979.  
  5980. nullpo_retr(-1, sd);
  5981.  
  5982. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5983. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5984. return -1;
  5985. }
  5986.  
  5987. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5988. sprintf(player2, "Cannot find player '%s' online", player1);
  5989. clif_displaymessage(fd, player2);
  5990. return -1;
  5991. }
  5992.  
  5993. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5994. sprintf(player1, "Cannot find player '%s' online", player2);
  5995. clif_displaymessage(fd, player1);
  5996. return -1;
  5997. }
  5998.  
  5999. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6000. clif_displaymessage(fd, "They are married.. wish them well");
  6001. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6002. // Auto-give named rings (Aru)
  6003. getring (pl_sd1);
  6004. getring (pl_sd2);
  6005. return 0;
  6006. }
  6007.  
  6008. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  6009. return -1;
  6010. }
  6011.  
  6012. /*==========================================
  6013. * @divorce by [MouseJstr], fixed by [Lupus]
  6014. * divorce two players
  6015. *------------------------------------------*/
  6016. ACMD_FUNC(divorce)
  6017. {
  6018. struct map_session_data *pl_sd = NULL;
  6019.  
  6020. nullpo_retr(-1, sd);
  6021.  
  6022. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6023. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6024. return -1;
  6025. }
  6026.  
  6027. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  6028. {
  6029. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6030. return -1;
  6031. }
  6032.  
  6033. if (pc_divorce(pl_sd) != 0) {
  6034. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6035. clif_displaymessage(fd, atcmd_output);
  6036. return -1;
  6037. }
  6038.  
  6039. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6040. clif_displaymessage(fd, atcmd_output);
  6041. return 0;
  6042. }
  6043.  
  6044. /*==========================================
  6045. * @changelook by [Celest]
  6046. *------------------------------------------*/
  6047. ACMD_FUNC(changelook)
  6048. {
  6049. int i, j = 0, k = 0;
  6050. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6051.  
  6052. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6053. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6054. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6055. return -1;
  6056. } else if (i == 2) {
  6057. if (j < 1) j = 1;
  6058. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6059. j = pos[j - 1];
  6060. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6061. k = j; // swap
  6062. j = LOOK_HEAD_TOP;
  6063. }
  6064.  
  6065. clif_changelook(&sd->bl,j,k);
  6066.  
  6067. return 0;
  6068. }
  6069.  
  6070. /*==========================================
  6071. * @autotrade by durf [Lupus] [Paradox924X]
  6072. * Turns on/off Autotrade for a specific player
  6073. *------------------------------------------*/
  6074. ACMD_FUNC(autotrade)
  6075. {
  6076. nullpo_retr(-1, sd);
  6077.  
  6078. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  6079. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  6080. return -1;
  6081. }
  6082.  
  6083. if( pc_isdead(sd) ) {
  6084. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  6085. return -1;
  6086. }
  6087.  
  6088. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  6089. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  6090. return -1;
  6091. }
  6092.  
  6093. sd->state.autotrade = 1;
  6094. if( battle_config.at_timeout )
  6095. {
  6096. int timeout = atoi(message);
  6097. int limit = pc_isPremium(sd) ? battle_config.at_timeout * 5 : battle_config.at_timeout;
  6098. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,limit) : limit) * 60000, 0);
  6099. }
  6100. clif_authfail_fd(fd, 15);
  6101.  
  6102. return 0;
  6103. }
  6104.  
  6105. /*==========================================
  6106. * @changegm by durf (changed by Lupus)
  6107. * Changes Master of your Guild to a specified guild member
  6108. *------------------------------------------*/
  6109. ACMD_FUNC(changegm)
  6110. {
  6111. struct guild *g;
  6112. struct map_session_data *pl_sd;
  6113. nullpo_retr(-1, sd);
  6114.  
  6115. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6116. {
  6117. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6118. return -1;
  6119. }
  6120.  
  6121. if( map[sd->bl.m].flag.guildlock )
  6122. {
  6123. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  6124. return -1;
  6125. }
  6126.  
  6127. if( !message[0] )
  6128. {
  6129. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6130. return -1;
  6131. }
  6132.  
  6133. if( agit_flag ) // No dejar cambiar de GM en WOE [Tab]
  6134. {
  6135. clif_displaymessage(fd, "You cannot ChangeGM when War of Emperium is active.");
  6136. return -1;
  6137. }
  6138.  
  6139. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6140. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6141. return -1;
  6142. }
  6143.  
  6144. if( !battle_config.super_woe_enable && battle_config.at_changegm_cost && sd->status.zeny < battle_config.at_changegm_cost )
  6145. {
  6146. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6147.  
  6148. sprintf(atcmd_output, "You don't have enough zeny to transfer GM. Cost %d zeny.", battle_config.at_changegm_cost);
  6149. clif_displaymessage(fd, atcmd_output);
  6150. return -1;
  6151. }
  6152.  
  6153. guild_gm_change(sd->status.guild_id, pl_sd);
  6154. return 0;
  6155. }
  6156.  
  6157. /*==========================================
  6158. * @changeleader by Skotlex
  6159. * Changes the leader of a party.
  6160. *------------------------------------------*/
  6161. ACMD_FUNC(changeleader)
  6162. {
  6163. nullpo_retr(-1, sd);
  6164.  
  6165. if( !message[0] )
  6166. {
  6167. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6168. return -1;
  6169. }
  6170.  
  6171. if (party_changeleader(sd, map_nick2sd((char *) message)))
  6172. return 0;
  6173. return -1;
  6174. }
  6175.  
  6176. /*==========================================
  6177. * @partyoption by Skotlex
  6178. * Used to change the item share setting of a party.
  6179. *------------------------------------------*/
  6180. ACMD_FUNC(partyoption)
  6181. {
  6182. struct party_data *p;
  6183. int mi, option;
  6184. char w1[16], w2[16];
  6185. nullpo_retr(-1, sd);
  6186.  
  6187. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6188. {
  6189. clif_displaymessage(fd, msg_txt(282));
  6190. return -1;
  6191. }
  6192.  
  6193. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  6194. if (mi == MAX_PARTY)
  6195. return -1; //Shouldn't happen
  6196.  
  6197. if (!p->party.member[mi].leader)
  6198. {
  6199. clif_displaymessage(fd, msg_txt(282));
  6200. return -1;
  6201. }
  6202.  
  6203. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  6204. {
  6205. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  6206. return -1;
  6207. }
  6208.  
  6209. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  6210.  
  6211. //Change item share type.
  6212. if (option != p->party.item)
  6213. party_changeoption(sd, p->party.exp, option);
  6214. else
  6215. clif_displaymessage(fd, msg_txt(286));
  6216.  
  6217. return 0;
  6218. }
  6219.  
  6220. /*==========================================
  6221. * @autoloot by Zephyrus
  6222. *------------------------------------------*/
  6223. ACMD_FUNC(autoloot)
  6224. {
  6225. int p = 0;
  6226. char subcmd[100], data[100];
  6227. memset(subcmd, '\0', sizeof(subcmd));
  6228. memset(data, '\0', sizeof(data));
  6229.  
  6230. if( !message || !*message )
  6231. { // Normal Autoloot usage
  6232. if( sd->aloot.rate )
  6233. {
  6234. sd->aloot.rate = 0;
  6235. clif_displaymessage(fd, msg_txt(877));
  6236. }
  6237. else
  6238. {
  6239. sd->aloot.rate = 10000;
  6240. clif_displaymessage(fd, msg_txt(878));
  6241. }
  6242.  
  6243. clif_displaymessage(fd, msg_txt(879));
  6244. return 0;
  6245. }
  6246.  
  6247. if( (p = sscanf(message, "%99s %99[^\n]", subcmd, data)) < 1 )
  6248. {
  6249. clif_displaymessage(fd, msg_txt(879));
  6250. return -1;
  6251. }
  6252.  
  6253. if( !strcmp(subcmd, "rate") )
  6254. { // Set autoloot rate value
  6255. int rate;
  6256. if( p < 2 )
  6257. {
  6258. clif_displaymessage(fd, msg_txt(880));
  6259. return -1;
  6260. }
  6261.  
  6262. rate = (int)(atof(data) * 100);
  6263. sd->aloot.rate = cap_value(rate, 0, 10000);
  6264.  
  6265. if( sd->aloot.rate )
  6266. {
  6267. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(881),((double)sd->aloot.rate)/100.);
  6268. clif_displaymessage(fd, atcmd_output);
  6269. }
  6270. else
  6271. clif_displaymessage(fd, msg_txt(877));
  6272. }
  6273. else if( !strcmp(subcmd, "clear") )
  6274. {
  6275. memset(&sd->aloot, 0, sizeof(sd->aloot));
  6276. clif_displaymessage(fd, msg_txt(882));
  6277. }
  6278. else if( !strcmp(subcmd, "info") )
  6279. {
  6280. int i, c = 0;
  6281. struct item_data *it = NULL;
  6282.  
  6283. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(881),((double)sd->aloot.rate)/100.);
  6284. clif_displaymessage(fd, atcmd_output);
  6285. for( i = 0; i < MAX_AUTOLOOTID; i++ )
  6286. {
  6287. if( sd->aloot.nameid[i] == 0 || (it = itemdb_exists(sd->aloot.nameid[i])) == NULL )
  6288. continue;
  6289.  
  6290. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(883), it->jname, it->nameid);
  6291. clif_displaymessage(fd, atcmd_output);
  6292. c++;
  6293. }
  6294.  
  6295. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(884), c, MAX_AUTOLOOTID);
  6296. clif_displaymessage(fd, atcmd_output);
  6297. }
  6298. else if( !strcmp(subcmd, "item") )
  6299. {
  6300. int i, j;
  6301. struct item_data *it = NULL;
  6302.  
  6303. if( p < 2 )
  6304. {
  6305. clif_displaymessage(fd, msg_txt(885));
  6306. return -1;
  6307. }
  6308.  
  6309. ARR_FIND(0, MAX_AUTOLOOTID, i, sd->aloot.nameid[i] == 0);
  6310. if( i == MAX_AUTOLOOTID )
  6311. {
  6312. clif_displaymessage(fd, msg_txt(886));
  6313. return -1;
  6314. }
  6315.  
  6316. if( (it = itemdb_exists(atoi(data))) == NULL )
  6317. it = itemdb_searchname(data);
  6318.  
  6319. if( !it )
  6320. {
  6321. clif_displaymessage(fd, msg_txt(885));
  6322. return -1;
  6323. }
  6324.  
  6325. ARR_FIND(0, MAX_AUTOLOOTID, j, sd->aloot.nameid[i] == it->nameid);
  6326. if( j < MAX_AUTOLOOTID )
  6327. {
  6328. clif_displaymessage(fd, msg_txt(887));
  6329. return -1;
  6330. }
  6331.  
  6332. sd->aloot.nameid[i] = it->nameid;
  6333. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(883), it->jname, it->nameid);
  6334. clif_displaymessage(fd, atcmd_output);
  6335. }
  6336. else if( !strcmp(subcmd, "help") )
  6337. {
  6338. clif_displaymessage(fd, msg_txt(888));
  6339. clif_displaymessage(fd, msg_txt(889));
  6340. clif_displaymessage(fd, msg_txt(890));
  6341. clif_displaymessage(fd, msg_txt(891));
  6342. }
  6343. else
  6344. {
  6345. clif_displaymessage(fd, msg_txt(879));
  6346. return -1;
  6347. }
  6348.  
  6349. return 0;
  6350. }
  6351. /*==========================================
  6352. * @ddrop
  6353. * Turns on/off Drop information display
  6354. *------------------------------------------*/
  6355. ACMD_FUNC(displaydrop)
  6356. {
  6357. int rate;
  6358. double drate;
  6359. nullpo_retr(-1, sd);
  6360.  
  6361. if( !message || !*message )
  6362. {
  6363. if (sd->state.displaydrop)
  6364. rate = 0;
  6365. else
  6366. rate = 10000;
  6367. }
  6368. else
  6369. {
  6370. drate = atof(message);
  6371. rate = (int)(drate*100);
  6372. }
  6373.  
  6374. rate = cap_value(rate,0,10000);
  6375. sd->state.displaydrop = rate;
  6376.  
  6377. if( sd->state.displaydrop )
  6378. {
  6379. snprintf(atcmd_output, sizeof atcmd_output, "Displaying information about dropped items with %0.02f%% drop rate and below.",((double)sd->state.displaydrop)/100.);
  6380. clif_displaymessage(fd, atcmd_output);
  6381. }
  6382. else
  6383. clif_displaymessage(fd, "Information about dropped items is no longer displayed.");
  6384.  
  6385. return 0;
  6386. }
  6387.  
  6388. /*==========================================
  6389. * It is made to rain.
  6390. *------------------------------------------*/
  6391. ACMD_FUNC(rain)
  6392. {
  6393. nullpo_retr(-1, sd);
  6394. if (map[sd->bl.m].flag.rain) {
  6395. map[sd->bl.m].flag.rain=0;
  6396. clif_weather(sd->bl.m);
  6397. clif_displaymessage(fd, "The rain has stopped.");
  6398. } else {
  6399. map[sd->bl.m].flag.rain=1;
  6400. clif_weather(sd->bl.m);
  6401. clif_displaymessage(fd, "It is made to rain.");
  6402. }
  6403. return 0;
  6404. }
  6405.  
  6406. /*==========================================
  6407. * It is made to snow.
  6408. *------------------------------------------*/
  6409. ACMD_FUNC(snow)
  6410. {
  6411. nullpo_retr(-1, sd);
  6412. if (map[sd->bl.m].flag.snow) {
  6413. map[sd->bl.m].flag.snow=0;
  6414. clif_weather(sd->bl.m);
  6415. clif_displaymessage(fd, "Snow has stopped falling.");
  6416. } else {
  6417. map[sd->bl.m].flag.snow=1;
  6418. clif_weather(sd->bl.m);
  6419. clif_displaymessage(fd, "It is made to snow.");
  6420. }
  6421.  
  6422. return 0;
  6423. }
  6424.  
  6425. /*==========================================
  6426. * Cherry tree snowstorm is made to fall. (Sakura)
  6427. *------------------------------------------*/
  6428. ACMD_FUNC(sakura)
  6429. {
  6430. nullpo_retr(-1, sd);
  6431. if (map[sd->bl.m].flag.sakura) {
  6432. map[sd->bl.m].flag.sakura=0;
  6433. clif_weather(sd->bl.m);
  6434. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6435. } else {
  6436. map[sd->bl.m].flag.sakura=1;
  6437. clif_weather(sd->bl.m);
  6438. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6439. }
  6440. return 0;
  6441. }
  6442.  
  6443. /*==========================================
  6444. * Clouds appear.
  6445. *------------------------------------------*/
  6446. ACMD_FUNC(clouds)
  6447. {
  6448. nullpo_retr(-1, sd);
  6449. if (map[sd->bl.m].flag.clouds) {
  6450. map[sd->bl.m].flag.clouds=0;
  6451. clif_weather(sd->bl.m);
  6452. clif_displaymessage(fd, "The clouds has disappear.");
  6453. } else {
  6454. map[sd->bl.m].flag.clouds=1;
  6455. clif_weather(sd->bl.m);
  6456. clif_displaymessage(fd, "Clouds appear.");
  6457. }
  6458.  
  6459. return 0;
  6460. }
  6461.  
  6462. /*==========================================
  6463. * Different type of clouds using effect 516
  6464. *------------------------------------------*/
  6465. ACMD_FUNC(clouds2)
  6466. {
  6467. nullpo_retr(-1, sd);
  6468. if (map[sd->bl.m].flag.clouds2) {
  6469. map[sd->bl.m].flag.clouds2=0;
  6470. clif_weather(sd->bl.m);
  6471. clif_displaymessage(fd, "The alternative clouds disappear.");
  6472. } else {
  6473. map[sd->bl.m].flag.clouds2=1;
  6474. clif_weather(sd->bl.m);
  6475. clif_displaymessage(fd, "Alternative clouds appear.");
  6476. }
  6477.  
  6478. return 0;
  6479. }
  6480.  
  6481. /*==========================================
  6482. * Fog hangs over.
  6483. *------------------------------------------*/
  6484. ACMD_FUNC(fog)
  6485. {
  6486. nullpo_retr(-1, sd);
  6487. if (map[sd->bl.m].flag.fog) {
  6488. map[sd->bl.m].flag.fog=0;
  6489. clif_weather(sd->bl.m);
  6490. clif_displaymessage(fd, "The fog has gone.");
  6491. } else {
  6492. map[sd->bl.m].flag.fog=1;
  6493. clif_weather(sd->bl.m);
  6494. clif_displaymessage(fd, "Fog hangs over.");
  6495. }
  6496. return 0;
  6497. }
  6498.  
  6499. /*==========================================
  6500. * Fallen leaves fall.
  6501. *------------------------------------------*/
  6502. ACMD_FUNC(leaves)
  6503. {
  6504. nullpo_retr(-1, sd);
  6505. if (map[sd->bl.m].flag.leaves) {
  6506. map[sd->bl.m].flag.leaves=0;
  6507. clif_weather(sd->bl.m);
  6508. clif_displaymessage(fd, "Leaves no longer fall.");
  6509. } else {
  6510. map[sd->bl.m].flag.leaves=1;
  6511. clif_weather(sd->bl.m);
  6512. clif_displaymessage(fd, "Fallen leaves fall.");
  6513. }
  6514.  
  6515. return 0;
  6516. }
  6517.  
  6518. /*==========================================
  6519. * Fireworks appear.
  6520. *------------------------------------------*/
  6521. ACMD_FUNC(fireworks)
  6522. {
  6523. nullpo_retr(-1, sd);
  6524. if (map[sd->bl.m].flag.fireworks) {
  6525. map[sd->bl.m].flag.fireworks=0;
  6526. clif_weather(sd->bl.m);
  6527. clif_displaymessage(fd, "Fireworks are ended.");
  6528. } else {
  6529. map[sd->bl.m].flag.fireworks=1;
  6530. clif_weather(sd->bl.m);
  6531. clif_displaymessage(fd, "Fireworks are launched.");
  6532. }
  6533.  
  6534. return 0;
  6535. }
  6536.  
  6537. /*==========================================
  6538. * Clearing Weather Effects by Dexity
  6539. *------------------------------------------*/
  6540. ACMD_FUNC(clearweather)
  6541. {
  6542. nullpo_retr(-1, sd);
  6543. map[sd->bl.m].flag.rain=0;
  6544. map[sd->bl.m].flag.snow=0;
  6545. map[sd->bl.m].flag.sakura=0;
  6546. map[sd->bl.m].flag.clouds=0;
  6547. map[sd->bl.m].flag.clouds2=0;
  6548. map[sd->bl.m].flag.fog=0;
  6549. map[sd->bl.m].flag.fireworks=0;
  6550. map[sd->bl.m].flag.leaves=0;
  6551. clif_weather(sd->bl.m);
  6552. clif_displaymessage(fd, msg_txt(291));
  6553.  
  6554. return 0;
  6555. }
  6556.  
  6557. /*===============================================================
  6558. * Sound Command - plays a sound for everyone around! [Codemaster]
  6559. *---------------------------------------------------------------*/
  6560. ACMD_FUNC(sound)
  6561. {
  6562. char sound_file[100];
  6563.  
  6564. memset(sound_file, '\0', sizeof(sound_file));
  6565.  
  6566. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6567. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6568. return -1;
  6569. }
  6570.  
  6571. if(strstr(sound_file, ".wav") == NULL)
  6572. strcat(sound_file, ".wav");
  6573.  
  6574. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  6575.  
  6576. return 0;
  6577. }
  6578.  
  6579. /*==========================================
  6580. * MOB Search
  6581. *------------------------------------------*/
  6582. ACMD_FUNC(mobsearch)
  6583. {
  6584. char mob_name[100];
  6585. int mob_id;
  6586. int number = 0;
  6587. struct s_mapiterator* it;
  6588.  
  6589. nullpo_retr(-1, sd);
  6590.  
  6591. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6592. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  6593. return -1;
  6594. }
  6595.  
  6596. if ((mob_id = atoi(mob_name)) == 0)
  6597. mob_id = mobdb_searchname(mob_name);
  6598. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6599. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6600. clif_displaymessage(fd, atcmd_output);
  6601. return -1;
  6602. }
  6603. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6604. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6605. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6606.  
  6607. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  6608. clif_displaymessage(fd, atcmd_output);
  6609.  
  6610. it = mapit_geteachmob();
  6611. for(;;)
  6612. {
  6613. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6614. if( md == NULL )
  6615. break;// no more mobs
  6616.  
  6617. if( md->bl.m != sd->bl.m )
  6618. continue;
  6619. if( mob_id != -1 && md->class_ != mob_id )
  6620. continue;
  6621.  
  6622. ++number;
  6623. if( md->spawn_timer == INVALID_TIMER )
  6624. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6625. else
  6626. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6627. clif_displaymessage(fd, atcmd_output);
  6628. }
  6629. mapit_free(it);
  6630.  
  6631. return 0;
  6632. }
  6633.  
  6634. /*==========================================
  6635. * @cleanmap - cleans items on the ground
  6636. *------------------------------------------*/
  6637. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  6638. {
  6639. nullpo_ret(bl);
  6640. map_clearflooritem(bl->id);
  6641.  
  6642. return 0;
  6643. }
  6644.  
  6645. ACMD_FUNC(cleanmap)
  6646. {
  6647. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  6648. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  6649. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  6650. BL_ITEM);
  6651. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6652. return 0;
  6653. }
  6654.  
  6655. /*==========================================
  6656. * make a NPC/PET talk
  6657. * @npctalkc [SnakeDrak]
  6658. *------------------------------------------*/
  6659. ACMD_FUNC(npctalk)
  6660. {
  6661. char name[NAME_LENGTH],mes[100],temp[100];
  6662. struct npc_data *nd;
  6663. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6664. unsigned long color=0;
  6665.  
  6666. if (sd->sc.count && //no "chatting" while muted.
  6667. (sd->sc.data[SC_BERSERK] ||
  6668. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6669. return -1;
  6670.  
  6671. if(!ifcolor) {
  6672. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  6673. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  6674. return -1;
  6675. }
  6676. }
  6677. else {
  6678. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6679. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  6680. return -1;
  6681. }
  6682. }
  6683.  
  6684. if (!(nd = npc_name2id(name))) {
  6685. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  6686. return -1;
  6687. }
  6688.  
  6689. strtok(name, "#"); // discard extra name identifier if present
  6690. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6691.  
  6692. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  6693. else clif_message(&nd->bl, temp);
  6694.  
  6695. return 0;
  6696. }
  6697.  
  6698. ACMD_FUNC(pettalk)
  6699. {
  6700. char mes[100],temp[100];
  6701. struct pet_data *pd;
  6702.  
  6703. nullpo_retr(-1, sd);
  6704.  
  6705. if(!sd->status.pet_id || !(pd=sd->pd))
  6706. {
  6707. clif_displaymessage(fd, msg_txt(184));
  6708. return -1;
  6709. }
  6710.  
  6711. if (sd->sc.count && //no "chatting" while muted.
  6712. (sd->sc.data[SC_BERSERK] ||
  6713. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6714. return -1;
  6715.  
  6716. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6717. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  6718. return -1;
  6719. }
  6720.  
  6721. if (message[0] == '/')
  6722. {// pet emotion processing
  6723. const char* emo[] = {
  6724. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6725. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6726. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6727. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  6728. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  6729. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  6730. };
  6731. int i;
  6732. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6733. if( i < ARRAYLENGTH(emo) )
  6734. {
  6735. clif_emotion(&pd->bl, i);
  6736. return 0;
  6737. }
  6738. }
  6739.  
  6740. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6741. clif_message(&pd->bl, temp);
  6742.  
  6743. return 0;
  6744. }
  6745.  
  6746. /// @users - displays the number of players present on each map (and percentage)
  6747. /// #users displays on the target user instead of self
  6748. ACMD_FUNC(users)
  6749. {
  6750. char buf[CHAT_SIZE_MAX];
  6751. int i;
  6752. int users[MAX_MAPINDEX];
  6753. int users_all;
  6754. struct s_mapiterator* iter;
  6755.  
  6756. memset(users, 0, sizeof(users));
  6757. users_all = 0;
  6758.  
  6759. // count users on each map
  6760. iter = mapit_getallusers();
  6761. for(;;)
  6762. {
  6763. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  6764. if( sd2 == NULL )
  6765. break;// no more users
  6766.  
  6767. if( sd2->mapindex >= MAX_MAPINDEX )
  6768. continue;// invalid mapindex
  6769.  
  6770. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6771. if( users_all < INT_MAX ) ++users_all;
  6772. }
  6773. mapit_free(iter);
  6774.  
  6775. // display results for each map
  6776. for( i = 0; i < MAX_MAPINDEX; ++i )
  6777. {
  6778. if( users[i] == 0 )
  6779. continue;// empty
  6780.  
  6781. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6782. clif_displaymessage(sd->fd, buf);
  6783. }
  6784.  
  6785. // display overall count
  6786. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6787. clif_displaymessage(sd->fd, buf);
  6788.  
  6789. return 0;
  6790. }
  6791.  
  6792. /*==========================================
  6793. *
  6794. *------------------------------------------*/
  6795. ACMD_FUNC(reset)
  6796. {
  6797. pc_resetstate(sd);
  6798. pc_resetskill(sd,1);
  6799. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  6800. clif_displaymessage(fd, atcmd_output);
  6801. return 0;
  6802. }
  6803.  
  6804. /*==========================================
  6805. *
  6806. *------------------------------------------*/
  6807. ACMD_FUNC(summon)
  6808. {
  6809. char name[NAME_LENGTH];
  6810. int mob_id = 0;
  6811. int duration = 0;
  6812. struct mob_data *md;
  6813. unsigned int tick=gettick();
  6814.  
  6815. nullpo_retr(-1, sd);
  6816.  
  6817. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  6818. {
  6819. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  6820. return -1;
  6821. }
  6822.  
  6823. if (duration < 1)
  6824. duration =1;
  6825. else if (duration > 60)
  6826. duration =60;
  6827.  
  6828. if ((mob_id = atoi(name)) == 0)
  6829. mob_id = mobdb_searchname(name);
  6830. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6831. {
  6832. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6833. return -1;
  6834. }
  6835.  
  6836. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  6837.  
  6838. if(!md)
  6839. return -1;
  6840.  
  6841. md->master_id=sd->bl.id;
  6842. md->special_state.ai=1;
  6843. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6844. clif_specialeffect(&md->bl,344,AREA);
  6845. mob_spawn(md);
  6846. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6847. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6848. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  6849.  
  6850. return 0;
  6851. }
  6852.  
  6853. /*==========================================
  6854. * @adjcmdlvl by [MouseJstr]
  6855. *
  6856. * Temp adjust the GM level required to use a GM command
  6857. * Useful during beta testing to allow players to use GM commands for short periods of time
  6858. *------------------------------------------*/
  6859. ACMD_FUNC(adjcmdlvl)
  6860. {
  6861. int newlev, newremotelev;
  6862. char name[100];
  6863. AtCommandInfo* cmd;
  6864.  
  6865. nullpo_retr(-1, sd);
  6866.  
  6867. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  6868. {
  6869. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  6870. return -1;
  6871. }
  6872.  
  6873. cmd = get_atcommandinfo_byname(name);
  6874. if (cmd == NULL)
  6875. {
  6876. clif_displaymessage(fd, "@command not found.");
  6877. return -1;
  6878. }
  6879. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  6880. {
  6881. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  6882. return -1;
  6883. }
  6884. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  6885. {
  6886. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  6887. return -1;
  6888. }
  6889. else
  6890. {
  6891. cmd->level = newlev;
  6892. cmd->level2 = newremotelev;
  6893. clif_displaymessage(fd, "@command level changed.");
  6894. return 0;
  6895. }
  6896. }
  6897.  
  6898. /*==========================================
  6899. * @adjgmlvl by [MouseJstr]
  6900. * Create a temp GM
  6901. * Useful during beta testing to allow players to use GM commands for short periods of time
  6902. *------------------------------------------*/
  6903. ACMD_FUNC(adjgmlvl)
  6904. {
  6905. int newlev;
  6906. char user[NAME_LENGTH];
  6907. struct map_session_data *pl_sd;
  6908. nullpo_retr(-1, sd);
  6909.  
  6910. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  6911. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  6912. return -1;
  6913. }
  6914.  
  6915. if ( (pl_sd = map_nick2sd(user)) == NULL )
  6916. {
  6917. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6918. return -1;
  6919. }
  6920.  
  6921. pl_sd->gmlevel = newlev;
  6922.  
  6923. return 0;
  6924. }
  6925.  
  6926. /*==========================================
  6927. * @trade by [MouseJstr]
  6928. * Open a trade window with a remote player
  6929. *------------------------------------------*/
  6930. ACMD_FUNC(trade)
  6931. {
  6932. struct map_session_data *pl_sd = NULL;
  6933. nullpo_retr(-1, sd);
  6934.  
  6935. if (!message || !*message) {
  6936. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  6937. return -1;
  6938. }
  6939.  
  6940. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6941. {
  6942. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6943. return -1;
  6944. }
  6945.  
  6946. trade_traderequest(sd, pl_sd);
  6947. return 0;
  6948. }
  6949.  
  6950. /*==========================================
  6951. * @setbattleflag by [MouseJstr]
  6952. * set a battle_config flag without having to reboot
  6953. *------------------------------------------*/
  6954. ACMD_FUNC(setbattleflag)
  6955. {
  6956. char flag[128], value[128];
  6957. nullpo_retr(-1, sd);
  6958.  
  6959. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  6960. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  6961. return -1;
  6962. }
  6963.  
  6964. if (battle_set_value(flag, value) == 0)
  6965. {
  6966. clif_displaymessage(fd, "unknown battle_config flag");
  6967. return -1;
  6968. }
  6969.  
  6970. clif_displaymessage(fd, "battle_config set as requested");
  6971.  
  6972. return 0;
  6973. }
  6974.  
  6975. /*==========================================
  6976. * @unmute [Valaris]
  6977. *------------------------------------------*/
  6978. ACMD_FUNC(unmute)
  6979. {
  6980. struct map_session_data *pl_sd = NULL;
  6981. nullpo_retr(-1, sd);
  6982.  
  6983. if (!message || !*message) {
  6984. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  6985. return -1;
  6986. }
  6987.  
  6988. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6989. {
  6990. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6991. return -1;
  6992. }
  6993.  
  6994. if(!pl_sd->sc.data[SC_NOCHAT]) {
  6995. clif_displaymessage(sd->fd,"Player is not muted");
  6996. return -1;
  6997. }
  6998.  
  6999. pl_sd->status.manner = 0;
  7000. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  7001. clif_displaymessage(sd->fd,"Player unmuted");
  7002.  
  7003. return 0;
  7004. }
  7005.  
  7006. /*==========================================
  7007. * @uptime by MC Cameri
  7008. *------------------------------------------*/
  7009. ACMD_FUNC(uptime)
  7010. {
  7011. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7012. minute = 60, days = 0, hours = 0, minutes = 0;
  7013. nullpo_retr(-1, sd);
  7014.  
  7015. seconds = get_uptime();
  7016. days = seconds/day;
  7017. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7018. hours = seconds/hour;
  7019. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7020. minutes = seconds/minute;
  7021. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7022.  
  7023. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7024. clif_displaymessage(fd, atcmd_output);
  7025.  
  7026. return 0;
  7027. }
  7028.  
  7029. /*==========================================
  7030. * @changesex <sex>
  7031. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  7032. *------------------------------------------*/
  7033. ACMD_FUNC(changesex)
  7034. {
  7035. nullpo_retr(-1, sd);
  7036. chrif_changesex(sd);
  7037. return 0;
  7038. }
  7039.  
  7040. /*================================================
  7041. * @mute - Mutes a player for a set amount of time
  7042. *------------------------------------------------*/
  7043. ACMD_FUNC(mute)
  7044. {
  7045. struct map_session_data *pl_sd = NULL;
  7046. int manner;
  7047. nullpo_retr(-1, sd);
  7048.  
  7049. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7050. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7051. return -1;
  7052. }
  7053.  
  7054. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  7055. {
  7056. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7057. return -1;
  7058. }
  7059.  
  7060. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  7061. {
  7062. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7063. return -1;
  7064. }
  7065.  
  7066. clif_manner_message(sd, 0);
  7067. clif_manner_message(pl_sd, 5);
  7068.  
  7069. if( pl_sd->status.manner < manner ) {
  7070. pl_sd->status.manner -= manner;
  7071. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7072. } else {
  7073. pl_sd->status.manner = 0;
  7074. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  7075. }
  7076.  
  7077. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  7078.  
  7079. return 0;
  7080. }
  7081.  
  7082. /*==========================================
  7083. * @refresh (like @jumpto <<yourself>>)
  7084. *------------------------------------------*/
  7085. ACMD_FUNC(refresh)
  7086. {
  7087. nullpo_retr(-1, sd);
  7088. clif_refresh(sd);
  7089. return 0;
  7090. }
  7091.  
  7092. ACMD_FUNC(autorefresh)
  7093. {
  7094. int time; // Default Min Value.
  7095. nullpo_retr(-1,sd);
  7096.  
  7097. if( !message || !*message )
  7098. clif_displaymessage(fd,"Please, enter a value between 30 to 300 seconds or off to disable it. Usage @autorefresh <seconds/off>");
  7099. else if( !strcmpi(message,"off") )
  7100. {
  7101. if( sd->sc.data[SC_AUTOREFRESH] )
  7102. {
  7103. status_change_end(&sd->bl,SC_AUTOREFRESH,INVALID_TIMER);
  7104. clif_displaymessage(fd,"-- AutoRefresh disabled --");
  7105. return 0;
  7106. }
  7107.  
  7108. clif_displaymessage(fd,"AutoRefresh is not Enable.");
  7109. }
  7110. else if( (time = atoi(message)) < 30 || time > 300 )
  7111. clif_displaymessage(fd,"Please, enter a value between 30 to 300 seconds");
  7112. else
  7113. {
  7114. if( sd->sc.data[SC_AUTOREFRESH] )
  7115. sprintf(atcmd_output,"Adjusting AutoRefresh to execute each %d seconds.",time);
  7116. else
  7117. sprintf(atcmd_output,"Starting AutoRefresh to execute each %d seconds.",time);
  7118.  
  7119. clif_displaymessage(fd,atcmd_output);
  7120. sc_start(&sd->bl,SC_AUTOREFRESH,100,time,INVALID_TIMER);
  7121.  
  7122. return 0;
  7123. }
  7124.  
  7125. return -1;
  7126. }
  7127.  
  7128. /*==========================================
  7129. * @identify
  7130. * => GM's magnifier.
  7131. *------------------------------------------*/
  7132. ACMD_FUNC(identify)
  7133. {
  7134. int i,num;
  7135.  
  7136. nullpo_retr(-1, sd);
  7137.  
  7138. for(i=num=0;i<MAX_INVENTORY;i++){
  7139. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7140. num++;
  7141. }
  7142. }
  7143. if (num > 0) {
  7144. clif_item_identify_list(sd);
  7145. } else {
  7146. clif_displaymessage(fd,"There are no items to appraise.");
  7147. }
  7148. return 0;
  7149. }
  7150.  
  7151. /*==========================================
  7152. * @gmotd (Global MOTD)
  7153. * by davidsiaw :P
  7154. *------------------------------------------*/
  7155. ACMD_FUNC(gmotd)
  7156. {
  7157. char buf[CHAT_SIZE_MAX];
  7158. size_t len;
  7159. FILE* fp;
  7160.  
  7161. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  7162. {
  7163. while( fgets(buf, sizeof(buf), fp) )
  7164. {
  7165. if( buf[0] == '/' && buf[1] == '/' )
  7166. {
  7167. continue;
  7168. }
  7169.  
  7170. len = strlen(buf);
  7171.  
  7172. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  7173. {// strip trailing EOL characters
  7174. len--;
  7175. }
  7176.  
  7177. if( len )
  7178. {
  7179. buf[len] = 0;
  7180.  
  7181. intif_broadcast(buf, len+1, 0);
  7182. }
  7183. }
  7184. fclose(fp);
  7185. }
  7186. return 0;
  7187. }
  7188.  
  7189. ACMD_FUNC(misceffect)
  7190. {
  7191. int effect = 0;
  7192. nullpo_retr(-1, sd);
  7193. if (!message || !*message)
  7194. return -1;
  7195. if (sscanf(message, "%d", &effect) < 1)
  7196. return -1;
  7197. clif_misceffect(&sd->bl,effect);
  7198.  
  7199. return 0;
  7200. }
  7201.  
  7202. /*==========================================
  7203. * MAIL SYSTEM
  7204. *------------------------------------------*/
  7205. ACMD_FUNC(mail)
  7206. {
  7207. nullpo_ret(sd);
  7208. #ifndef TXT_ONLY
  7209. mail_openmail(sd);
  7210. #endif
  7211. return 0;
  7212. }
  7213.  
  7214. /*==========================================
  7215. * Show Monster DB Info v 1.0
  7216. * originally by [Lupus] eAthena
  7217. *------------------------------------------*/
  7218. ACMD_FUNC(mobinfo)
  7219. {
  7220. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  7221. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  7222. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  7223.  
  7224. unsigned int mmodei[15] = { MD_CANMOVE, MD_LOOTER, MD_AGGRESSIVE, MD_ASSIST, MD_CASTSENSOR_IDLE, MD_BOSS, MD_PLANT, MD_CANATTACK, MD_DETECTOR, MD_CASTSENSOR_CHASE, MD_CHANGECHASE, MD_ANGRY, MD_CHANGETARGET_MELEE, MD_CHANGETARGET_CHASE, MD_TARGETWEAK };
  7225. unsigned char mmode[15][20] = {"Can Move", "Looter", "Aggresive", "Assist", "Cast Sensor Idle", "Boss", "Plant", "Can Attack", "Detector", "Cast Sensor Chase", "Change Chase", "Angry", "Change Target Melee", "Change Target Chase", "Target Weak"};
  7226.  
  7227. char atcmd_output2[CHAT_SIZE_MAX];
  7228. struct item_data *item_data;
  7229. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7230. int count;
  7231. int i, j, k;
  7232.  
  7233. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7234. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  7235.  
  7236. if (!message || !*message) {
  7237. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  7238. return -1;
  7239. }
  7240.  
  7241. // If monster identifier/name argument is a name
  7242. if ((i = mobdb_checkid(atoi(message))))
  7243. {
  7244. mob_array[0] = mob_db(i);
  7245. count = 1;
  7246. } else
  7247. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7248.  
  7249. if (!count) {
  7250. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7251. return -1;
  7252. }
  7253.  
  7254. if (count > MAX_SEARCH) {
  7255. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7256. clif_displaymessage(fd, atcmd_output);
  7257. count = MAX_SEARCH;
  7258. }
  7259. for (k = 0; k < count; k++) {
  7260. mob = mob_array[k];
  7261.  
  7262. // stats
  7263. if (mob->mexp)
  7264. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7265. else
  7266. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7267. clif_displaymessage(fd, atcmd_output);
  7268. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  7269. clif_displaymessage(fd, atcmd_output);
  7270. sprintf(atcmd_output, " DEF:%d-%d MDEF:%d-%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  7271. mob->status.def, mob->status.def2, mob->status.mdef, mob->status.mdef2, mob->status.str, mob->status.agi,
  7272. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  7273. clif_displaymessage(fd, atcmd_output);
  7274.  
  7275. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  7276. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  7277. mob->range2 , mob->range3, msize[mob->status.size],
  7278. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  7279. clif_displaymessage(fd, atcmd_output);
  7280. // Extra Settings
  7281. if( mob->ffa )
  7282. clif_displaymessage(fd, "- Free For All Monster");
  7283. if( mob->hunting )
  7284. clif_displaymessage(fd, "- Hunting Mission Enable Monster");
  7285. // modes
  7286. clif_displaymessage(fd, " Modes:");
  7287. strcpy(atcmd_output, " ");
  7288. j = 0;
  7289. for( i = 0; i < 15; i++ )
  7290. {
  7291. if( mob->status.mode&mmodei[i] )
  7292. {
  7293. sprintf(atcmd_output2, " - %s", mmode[i]);
  7294. strcat(atcmd_output, atcmd_output2);
  7295. if( ++j % 3 == 0 )
  7296. {
  7297. clif_displaymessage(fd, atcmd_output);
  7298. strcpy(atcmd_output, " ");
  7299. }
  7300. }
  7301. }
  7302. if( j % 3 != 0 ) clif_displaymessage(fd, atcmd_output);
  7303. // drops
  7304. clif_displaymessage(fd, " Drops:");
  7305. strcpy(atcmd_output, " ");
  7306. j = 0;
  7307. for (i = 0; i < MAX_MOB_DROP; i++) {
  7308. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  7309. continue;
  7310. if (item_data->slot)
  7311. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  7312. else
  7313. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  7314. strcat(atcmd_output, atcmd_output2);
  7315. if (++j % 3 == 0) {
  7316. clif_displaymessage(fd, atcmd_output);
  7317. strcpy(atcmd_output, " ");
  7318. }
  7319. }
  7320. if (j == 0)
  7321. clif_displaymessage(fd, "This monster has no drops.");
  7322. else if (j % 3 != 0)
  7323. clif_displaymessage(fd, atcmd_output);
  7324. // mvp
  7325. if (mob->mexp) {
  7326. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  7327. clif_displaymessage(fd, atcmd_output);
  7328. strcpy(atcmd_output, " MVP Items:");
  7329. j = 0;
  7330. for (i = 0; i < 3; i++) {
  7331. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  7332. continue;
  7333. if (mob->mvpitem[i].p > 0) {
  7334. j++;
  7335. if (j == 1)
  7336. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  7337. else
  7338. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  7339. strcat(atcmd_output, atcmd_output2);
  7340. }
  7341. }
  7342. if (j == 0)
  7343. clif_displaymessage(fd, "This monster has no MVP prizes.");
  7344. else
  7345. clif_displaymessage(fd, atcmd_output);
  7346. }
  7347. }
  7348. return 0;
  7349. }
  7350.  
  7351. /*=========================================
  7352. * @showmobs by KarLaeda
  7353. * => For 15 sec displays the mobs on minimap
  7354. *------------------------------------------*/
  7355. ACMD_FUNC(showmobs)
  7356. {
  7357. char mob_name[100];
  7358. int mob_id;
  7359. int number = 0;
  7360. struct s_mapiterator* it;
  7361.  
  7362. nullpo_retr(-1, sd);
  7363.  
  7364. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  7365. return -1;
  7366.  
  7367. if((mob_id = atoi(mob_name)) == 0)
  7368. mob_id = mobdb_searchname(mob_name);
  7369. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7370. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7371. clif_displaymessage(fd, atcmd_output);
  7372. return 0;
  7373. }
  7374. // Uncomment the following line to show mini-bosses & MVP.
  7375. //#define SHOW_MVP
  7376. #ifndef SHOW_MVP
  7377. if(mob_db(mob_id)->status.mode&MD_BOSS){
  7378. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  7379. clif_displaymessage(fd, atcmd_output);
  7380. return 0;
  7381. }
  7382. #endif
  7383. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7384. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7385. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7386.  
  7387. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7388. mob_name, mapindex_id2name(sd->mapindex));
  7389. clif_displaymessage(fd, atcmd_output);
  7390.  
  7391. it = mapit_geteachmob();
  7392. for(;;)
  7393. {
  7394. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  7395. if( md == NULL )
  7396. break;// no more mobs
  7397.  
  7398. if( md->bl.m != sd->bl.m )
  7399. continue;
  7400. if( mob_id != -1 && md->class_ != mob_id )
  7401. continue;
  7402. if( md->special_state.ai || md->master_id )
  7403. continue; // hide slaves and player summoned mobs
  7404. if( md->spawn_timer != INVALID_TIMER )
  7405. continue; // hide mobs waiting for respawn
  7406.  
  7407. ++number;
  7408. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  7409. }
  7410. mapit_free(it);
  7411.  
  7412. return 0;
  7413. }
  7414.  
  7415. /*==========================================
  7416. * homunculus level up [orn]
  7417. *------------------------------------------*/
  7418. ACMD_FUNC(homlevel)
  7419. {
  7420. TBL_HOM * hd;
  7421. int level = 0, i = 0;
  7422.  
  7423. nullpo_retr(-1, sd);
  7424.  
  7425. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  7426. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  7427. return -1;
  7428. }
  7429.  
  7430. if ( !merc_is_hom_active(sd->hd) ) {
  7431. clif_displaymessage(fd, "You do not have a homunculus.");
  7432. return -1;
  7433. }
  7434.  
  7435. hd = sd->hd;
  7436.  
  7437. for (i = 1; i <= level && hd->exp_next; i++){
  7438. hd->homunculus.exp += hd->exp_next;
  7439. merc_hom_levelup(hd);
  7440. }
  7441. status_calc_homunculus(hd,0);
  7442. status_percent_heal(&hd->bl, 100, 100);
  7443. clif_specialeffect(&hd->bl,568,AREA);
  7444. return 0;
  7445. }
  7446.  
  7447. /*==========================================
  7448. * homunculus evolution H [orn]
  7449. *------------------------------------------*/
  7450. ACMD_FUNC(homevolution)
  7451. {
  7452. nullpo_retr(-1, sd);
  7453.  
  7454. if ( !merc_is_hom_active(sd->hd) ) {
  7455. clif_displaymessage(fd, "You do not have a homunculus.");
  7456. return -1;
  7457. }
  7458.  
  7459. if ( !merc_hom_evolution(sd->hd) ) {
  7460. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  7461. return -1;
  7462. }
  7463.  
  7464. return 0;
  7465. }
  7466.  
  7467. /*==========================================
  7468. * call choosen homunculus [orn]
  7469. *------------------------------------------*/
  7470. ACMD_FUNC(makehomun)
  7471. {
  7472. int homunid;
  7473. nullpo_retr(-1, sd);
  7474.  
  7475. if ( sd->status.hom_id ) {
  7476. clif_displaymessage(fd, msg_txt(450));
  7477. return -1;
  7478. }
  7479.  
  7480. if (!message || !*message) {
  7481. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  7482. return -1;
  7483. }
  7484.  
  7485. homunid = atoi(message);
  7486. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  7487. {
  7488. clif_displaymessage(fd, "Invalid Homunculus id.");
  7489. return -1;
  7490. }
  7491.  
  7492. merc_create_homunculus_request(sd,homunid);
  7493. return 0;
  7494. }
  7495.  
  7496. /*==========================================
  7497. * modify homunculus intimacy [orn]
  7498. *------------------------------------------*/
  7499. ACMD_FUNC(homfriendly)
  7500. {
  7501. int friendly = 0;
  7502.  
  7503. nullpo_retr(-1, sd);
  7504.  
  7505. if ( !merc_is_hom_active(sd->hd) ) {
  7506. clif_displaymessage(fd, "You do not have a homunculus.");
  7507. return -1;
  7508. }
  7509.  
  7510. if (!message || !*message) {
  7511. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  7512. return -1;
  7513. }
  7514.  
  7515. friendly = atoi(message);
  7516. friendly = cap_value(friendly, 0, 1000);
  7517.  
  7518. sd->hd->homunculus.intimacy = friendly * 100 ;
  7519. clif_send_homdata(sd,SP_INTIMATE,friendly);
  7520. return 0;
  7521. }
  7522.  
  7523. /*==========================================
  7524. * modify homunculus hunger [orn]
  7525. *------------------------------------------*/
  7526. ACMD_FUNC(homhungry)
  7527. {
  7528. int hungry = 0;
  7529.  
  7530. nullpo_retr(-1, sd);
  7531.  
  7532. if ( !merc_is_hom_active(sd->hd) ) {
  7533. clif_displaymessage(fd, "You do not have a homunculus.");
  7534. return -1;
  7535. }
  7536.  
  7537. if (!message || !*message) {
  7538. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  7539. return -1;
  7540. }
  7541.  
  7542. hungry = atoi(message);
  7543. hungry = cap_value(hungry, 0, 100);
  7544.  
  7545. sd->hd->homunculus.hunger = hungry;
  7546. clif_send_homdata(sd,SP_HUNGRY,hungry);
  7547. return 0;
  7548. }
  7549.  
  7550. /*==========================================
  7551. * make the homunculus speak [orn]
  7552. *------------------------------------------*/
  7553. ACMD_FUNC(homtalk)
  7554. {
  7555. char mes[100],temp[100];
  7556.  
  7557. nullpo_retr(-1, sd);
  7558.  
  7559. if (sd->sc.count && //no "chatting" while muted.
  7560. (sd->sc.data[SC_BERSERK] ||
  7561. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  7562. return -1;
  7563.  
  7564. if ( !merc_is_hom_active(sd->hd) ) {
  7565. clif_displaymessage(fd, "You do not have a homunculus.");
  7566. return -1;
  7567. }
  7568.  
  7569. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  7570. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  7571. return -1;
  7572. }
  7573.  
  7574. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  7575. clif_message(&sd->hd->bl, temp);
  7576.  
  7577. return 0;
  7578. }
  7579.  
  7580. /*==========================================
  7581. * Show homunculus stats
  7582. *------------------------------------------*/
  7583. ACMD_FUNC(hominfo)
  7584. {
  7585. struct homun_data *hd;
  7586. struct status_data *status;
  7587. nullpo_retr(-1, sd);
  7588.  
  7589. if ( !merc_is_hom_active(sd->hd) ) {
  7590. clif_displaymessage(fd, "You do not have a homunculus.");
  7591. return -1;
  7592. }
  7593.  
  7594. hd = sd->hd;
  7595. status = status_get_status_data(&hd->bl);
  7596. clif_displaymessage(fd, "Homunculus stats :");
  7597.  
  7598. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  7599. status->hp, status->max_hp, status->sp, status->max_sp);
  7600. clif_displaymessage(fd, atcmd_output);
  7601.  
  7602. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  7603. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  7604. clif_displaymessage(fd, atcmd_output);
  7605.  
  7606. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  7607. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  7608. clif_displaymessage(fd, atcmd_output);
  7609.  
  7610. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7611. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  7612. status->str, status->agi, status->vit,
  7613. status->int_, status->dex, status->luk);
  7614. clif_displaymessage(fd, atcmd_output);
  7615.  
  7616. return 0;
  7617. }
  7618.  
  7619. ACMD_FUNC(homstats)
  7620. {
  7621. struct homun_data *hd;
  7622. struct s_homunculus_db *db;
  7623. struct s_homunculus *hom;
  7624. int lv, min, max, evo;
  7625.  
  7626. nullpo_retr(-1, sd);
  7627.  
  7628. if ( !merc_is_hom_active(sd->hd) ) {
  7629. clif_displaymessage(fd, "You do not have a homunculus.");
  7630. return -1;
  7631. }
  7632.  
  7633. hd = sd->hd;
  7634.  
  7635. hom = &hd->homunculus;
  7636. db = hd->homunculusDB;
  7637. lv = hom->level;
  7638.  
  7639. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7640. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  7641. clif_displaymessage(fd, atcmd_output);
  7642. lv--; //Since the first increase is at level 2.
  7643.  
  7644. evo = (hom->class_ == db->evo_class);
  7645. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7646. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7647. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  7648. clif_displaymessage(fd, atcmd_output);
  7649.  
  7650. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7651. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7652. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  7653. clif_displaymessage(fd, atcmd_output);
  7654.  
  7655. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7656. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7657. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  7658. clif_displaymessage(fd, atcmd_output);
  7659.  
  7660. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7661. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7662. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  7663. clif_displaymessage(fd, atcmd_output);
  7664.  
  7665. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7666. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7667. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  7668. clif_displaymessage(fd, atcmd_output);
  7669.  
  7670. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7671. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7672. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  7673. clif_displaymessage(fd, atcmd_output);
  7674.  
  7675. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7676. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7677. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  7678. clif_displaymessage(fd, atcmd_output);
  7679.  
  7680. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7681. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7682. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  7683. clif_displaymessage(fd, atcmd_output);
  7684.  
  7685. return 0;
  7686. }
  7687.  
  7688. ACMD_FUNC(homshuffle)
  7689. {
  7690. nullpo_retr(-1, sd);
  7691.  
  7692. if(!sd->hd)
  7693. return -1; // nothing to do
  7694.  
  7695. if(!merc_hom_shuffle(sd->hd))
  7696. return -1;
  7697.  
  7698. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  7699. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7700. return 0;
  7701. }
  7702.  
  7703. /*==========================================
  7704. * Show Items DB Info v 1.0
  7705. * originally by [Lupus] eAthena
  7706. *------------------------------------------*/
  7707. ACMD_FUNC(iteminfo)
  7708. {
  7709. struct item_data *item_data, *item_array[MAX_SEARCH];
  7710. int i, count = 1;
  7711.  
  7712. if (!message || !*message) {
  7713. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  7714. return -1;
  7715. }
  7716. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7717. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7718.  
  7719. if (!count) {
  7720. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7721. return -1;
  7722. }
  7723.  
  7724. if (count > MAX_SEARCH) {
  7725. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7726. clif_displaymessage(fd, atcmd_output);
  7727. count = MAX_SEARCH;
  7728. }
  7729. for (i = 0; i < count; i++) {
  7730. item_data = item_array[i];
  7731. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s | Ancient: %s",
  7732. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  7733. itemdb_typename(item_data->type),
  7734. (item_data->script==NULL)? "None" : "With script",
  7735. item_data->ancient ? "Yes" : "No"
  7736. );
  7737. clif_displaymessage(fd, atcmd_output);
  7738.  
  7739. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  7740. clif_displaymessage(fd, atcmd_output);
  7741.  
  7742. if (item_data->maxchance == -1)
  7743. strcpy(atcmd_output, " - Available in the shops only.");
  7744. else if (item_data->maxchance)
  7745. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  7746. else
  7747. strcpy(atcmd_output, " - Monsters don't drop this item.");
  7748. clif_displaymessage(fd, atcmd_output);
  7749.  
  7750. }
  7751. return 0;
  7752. }
  7753.  
  7754. /*==========================================
  7755. * Show who drops the item.
  7756. *------------------------------------------*/
  7757. ACMD_FUNC(whodrops)
  7758. {
  7759. struct item_data *item_data, *item_array[MAX_SEARCH];
  7760. int i,j, count = 1;
  7761.  
  7762. if (!message || !*message) {
  7763. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  7764. return -1;
  7765. }
  7766. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7767. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7768.  
  7769. if (!count) {
  7770. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7771. return -1;
  7772. }
  7773.  
  7774. if (count > MAX_SEARCH) {
  7775. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7776. clif_displaymessage(fd, atcmd_output);
  7777. count = MAX_SEARCH;
  7778. }
  7779. for (i = 0; i < count; i++) {
  7780. item_data = item_array[i];
  7781. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  7782. clif_displaymessage(fd, atcmd_output);
  7783.  
  7784. if (item_data->mob[0].chance == 0) {
  7785. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  7786. clif_displaymessage(fd, atcmd_output);
  7787. } else {
  7788. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  7789. clif_displaymessage(fd, atcmd_output);
  7790.  
  7791. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  7792. {
  7793. sprintf(atcmd_output, "- %s (%02.02f%%) %02.02f%% Base -", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100., item_data->mob[j].bchance/100.);
  7794. clif_displaymessage(fd, atcmd_output);
  7795. }
  7796. }
  7797. }
  7798. return 0;
  7799. }
  7800.  
  7801. ACMD_FUNC(whereis)
  7802. {
  7803. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7804. int count;
  7805. int i, j, k;
  7806.  
  7807. if (!message || !*message) {
  7808. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  7809. return -1;
  7810. }
  7811.  
  7812. // If monster identifier/name argument is a name
  7813. if ((i = mobdb_checkid(atoi(message))))
  7814. {
  7815. mob_array[0] = mob_db(i);
  7816. count = 1;
  7817. } else
  7818. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7819.  
  7820. if (!count) {
  7821. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7822. return -1;
  7823. }
  7824.  
  7825. if (count > MAX_SEARCH) {
  7826. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7827. clif_displaymessage(fd, atcmd_output);
  7828. count = MAX_SEARCH;
  7829. }
  7830. for (k = 0; k < count; k++) {
  7831. mob = mob_array[k];
  7832. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  7833. clif_displaymessage(fd, atcmd_output);
  7834.  
  7835. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  7836. {
  7837. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  7838. if (j < 0) continue;
  7839. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  7840. clif_displaymessage(fd, atcmd_output);
  7841. }
  7842. if (i == 0)
  7843. clif_displaymessage(fd, "This monster does not spawn normally.");
  7844. }
  7845.  
  7846. return 0;
  7847. }
  7848.  
  7849. /*==========================================
  7850. * @adopt by [Veider]
  7851. * adopt a novice
  7852. *------------------------------------------*/
  7853. ACMD_FUNC(adopt)
  7854. {
  7855. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  7856. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  7857. char output[CHAT_SIZE_MAX];
  7858.  
  7859. nullpo_retr(-1, sd);
  7860.  
  7861. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  7862. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  7863. return -1;
  7864. }
  7865.  
  7866. if (battle_config.etc_log)
  7867. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  7868.  
  7869. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  7870. sprintf(output, "Cannot find player %s online", player1);
  7871. clif_displaymessage(fd, output);
  7872. return -1;
  7873. }
  7874.  
  7875. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  7876. sprintf(output, "Cannot find player %s online", player2);
  7877. clif_displaymessage(fd, output);
  7878. return -1;
  7879. }
  7880.  
  7881. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  7882. sprintf(output, "Cannot find player %s online", player3);
  7883. clif_displaymessage(fd, output);
  7884. return -1;
  7885. }
  7886.  
  7887. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  7888. return -1;
  7889. }
  7890.  
  7891. clif_displaymessage(fd, "They are family... wish them luck");
  7892. return 0;
  7893. }
  7894.  
  7895. ACMD_FUNC(version)
  7896. {
  7897. const char * revision;
  7898.  
  7899. if ((revision = get_svn_revision()) != 0) {
  7900. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  7901. clif_displaymessage(fd,atcmd_output);
  7902. } else
  7903. clif_displaymessage(fd,"Cannot determine SVN revision");
  7904.  
  7905. return 0;
  7906. }
  7907.  
  7908. /*==========================================
  7909. * @mutearea by MouseJstr
  7910. *------------------------------------------*/
  7911. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7912. {
  7913.  
  7914. int time, id;
  7915. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  7916. if (pl_sd == NULL)
  7917. return 0;
  7918.  
  7919. id = va_arg(ap, int);
  7920. time = va_arg(ap, int);
  7921.  
  7922. if (id != bl->id && !pc_isGM(pl_sd)) {
  7923. pl_sd->status.manner -= time;
  7924. if (pl_sd->status.manner < 0)
  7925. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7926. else
  7927. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  7928. }
  7929. return 0;
  7930. }
  7931.  
  7932. ACMD_FUNC(mutearea)
  7933. {
  7934. int time;
  7935. nullpo_ret(sd);
  7936.  
  7937. if (!message || !*message) {
  7938. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  7939. return -1;
  7940. }
  7941.  
  7942. time = atoi(message);
  7943.  
  7944. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  7945. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7946. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7947.  
  7948. return 0;
  7949. }
  7950.  
  7951.  
  7952. ACMD_FUNC(rates)
  7953. {
  7954. char buf[CHAT_SIZE_MAX];
  7955.  
  7956. nullpo_ret(sd);
  7957. memset(buf, '\0', sizeof(buf));
  7958.  
  7959. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  7960. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  7961. clif_displaymessage(fd, buf);
  7962. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  7963. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  7964. clif_displaymessage(fd, buf);
  7965. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  7966. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  7967. clif_displaymessage(fd, buf);
  7968. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  7969. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  7970. clif_displaymessage(fd, buf);
  7971.  
  7972. return 0;
  7973. }
  7974.  
  7975. /*==========================================
  7976. * @me by lordalfa
  7977. * => Displays the OUTPUT string on top of the Visible players Heads.
  7978. *------------------------------------------*/
  7979. ACMD_FUNC(me)
  7980. {
  7981. char tempmes[CHAT_SIZE_MAX];
  7982. nullpo_retr(-1, sd);
  7983.  
  7984. memset(tempmes, '\0', sizeof(tempmes));
  7985. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7986.  
  7987. if (sd->sc.count && //no "chatting" while muted.
  7988. (sd->sc.data[SC_BERSERK] ||
  7989. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  7990. return -1;
  7991.  
  7992. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  7993. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  7994. return -1;
  7995. }
  7996.  
  7997. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  7998. clif_disp_overhead(sd, atcmd_output);
  7999.  
  8000. return 0;
  8001.  
  8002. }
  8003.  
  8004. /*==========================================
  8005. * @size
  8006. * => Resize your character sprite. [Valaris]
  8007. *------------------------------------------*/
  8008. ACMD_FUNC(size)
  8009. {
  8010. int size=0;
  8011.  
  8012. nullpo_retr(-1, sd);
  8013.  
  8014. size = atoi(message);
  8015. if(sd->state.size) {
  8016. sd->state.size=0;
  8017. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  8018. }
  8019.  
  8020. if(size==1) {
  8021. sd->state.size=1;
  8022. clif_specialeffect(&sd->bl,420,AREA);
  8023. } else if(size==2) {
  8024. sd->state.size=2;
  8025. clif_specialeffect(&sd->bl,422,AREA);
  8026. }
  8027.  
  8028. return 0;
  8029. }
  8030.  
  8031. ACMD_FUNC(sizeall)
  8032. {
  8033. int size;
  8034. struct map_session_data *pl_sd;
  8035. struct s_mapiterator* iter;
  8036.  
  8037. size = atoi(message);
  8038. size = cap_value(size,0,2);
  8039.  
  8040. global_size = size;
  8041. iter = mapit_getallusers();
  8042. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  8043. {
  8044. if( pl_sd->state.size != size )
  8045. {
  8046. if( pl_sd->state.size )
  8047. {
  8048. pl_sd->state.size = 0;
  8049. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  8050. }
  8051.  
  8052. pl_sd->state.size = size;
  8053. if( size == 1 )
  8054. clif_specialeffect(&pl_sd->bl,420,AREA);
  8055. else if( size == 2 )
  8056. clif_specialeffect(&pl_sd->bl,422,AREA);
  8057. }
  8058. }
  8059. mapit_free(iter);
  8060. clif_displaymessage(fd, "Default Server character size set...");
  8061.  
  8062. return 0;
  8063. }
  8064.  
  8065. /*==========================================
  8066. * @monsterignore
  8067. * => Makes monsters ignore you. [Valaris]
  8068. *------------------------------------------*/
  8069. ACMD_FUNC(monsterignore)
  8070. {
  8071. nullpo_retr(-1, sd);
  8072.  
  8073. if (!sd->state.monster_ignore) {
  8074. sd->state.monster_ignore = 1;
  8075. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  8076. } else {
  8077. sd->state.monster_ignore = 0;
  8078. clif_displaymessage(sd->fd, "Returned to normal state.");
  8079. }
  8080.  
  8081. return 0;
  8082. }
  8083. /*==========================================
  8084. * @fakename
  8085. * => Gives your character a fake name. [Valaris]
  8086. *------------------------------------------*/
  8087. ACMD_FUNC(fakename)
  8088. {
  8089. nullpo_retr(-1, sd);
  8090.  
  8091. if( !message || !*message )
  8092. {
  8093. if( sd->fakename[0] )
  8094. {
  8095. sd->fakename[0] = '\0';
  8096. clif_charnameack(0, &sd->bl);
  8097. clif_displaymessage(sd->fd, "Returned to real name.");
  8098. return 0;
  8099. }
  8100.  
  8101. clif_displaymessage(sd->fd, "You must enter a name.");
  8102. return -1;
  8103. }
  8104.  
  8105. if( strlen(message) < 2 )
  8106. {
  8107. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  8108. return -1;
  8109. }
  8110.  
  8111. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  8112. clif_charnameack(0, &sd->bl);
  8113. clif_displaymessage(sd->fd, "Fake name enabled.");
  8114.  
  8115. return 0;
  8116. }
  8117.  
  8118. /*==========================================
  8119. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  8120. * => Shows information about the map flags [map name]
  8121. * Also set flags
  8122. *------------------------------------------*/
  8123. ACMD_FUNC(mapflag)
  8124. {
  8125. // WIP
  8126. return 0;
  8127. }
  8128.  
  8129. /*===================================
  8130. * Remove some messages
  8131. *-----------------------------------*/
  8132. ACMD_FUNC(showexp)
  8133. {
  8134. if (sd->state.showexp) {
  8135. sd->state.showexp = 0;
  8136. clif_displaymessage(fd, "Gained exp will not be shown.");
  8137. return 0;
  8138. }
  8139.  
  8140. sd->state.showexp = 1;
  8141. clif_displaymessage(fd, "Gained exp is now shown");
  8142. return 0;
  8143. }
  8144.  
  8145. ACMD_FUNC(showzeny)
  8146. {
  8147. if (sd->state.showzeny) {
  8148. sd->state.showzeny = 0;
  8149. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8150. return 0;
  8151. }
  8152.  
  8153. sd->state.showzeny = 1;
  8154. clif_displaymessage(fd, "Gained zeny is now shown");
  8155. return 0;
  8156. }
  8157.  
  8158. ACMD_FUNC(showdelay)
  8159. {
  8160. if (sd->state.showdelay) {
  8161. sd->state.showdelay = 0;
  8162. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8163. return 0;
  8164. }
  8165.  
  8166. sd->state.showdelay = 1;
  8167. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8168. return 0;
  8169. }
  8170.  
  8171. ACMD_FUNC(showcast)
  8172. {
  8173. sd->state.showcast = 1;
  8174. clif_displaymessage(fd, "Skill casting time will be show the next time.");
  8175.  
  8176. return 0;
  8177. }
  8178.  
  8179. ACMD_FUNC(showcastdelay)
  8180. {
  8181. sd->state.showcastdelay = 1;
  8182. clif_displaymessage(fd, "Skill delay time will be show the next time.");
  8183.  
  8184. return 0;
  8185. }
  8186.  
  8187. /*==========================================
  8188. * Activar o desactivar modo Resident Evil. [Tab]
  8189. *------------------------------------------*/
  8190. ACMD_FUNC(residente)
  8191. {
  8192. int Rtype = 0;
  8193.  
  8194. nullpo_retr(-1, sd);
  8195.  
  8196. if (!message || !*message) {
  8197. if (map[sd->bl.m].flag.residentevil > 0)
  8198. map[sd->bl.m].flag.residentevil = 0;
  8199. else
  8200. map[sd->bl.m].flag.residentevil = 1; // Default is 1
  8201. } else {
  8202. if (sscanf(message,"%d", &Rtype) < 1) {
  8203. clif_displaymessage(fd, "Use @undeadmode <Type>. 0=OFF, 1=ON (Noexp Nodrop), 2=ON (Exp and Drop)");
  8204. return -1;
  8205. }
  8206.  
  8207. if (Rtype < 0) Rtype = 0; else if (Rtype > 2) Rtype = 2;
  8208.  
  8209. switch (Rtype) {
  8210. case 0:
  8211. map[sd->bl.m].flag.residentevil = 0;
  8212. break;
  8213. case 1:
  8214. map[sd->bl.m].flag.residentevil = 1;
  8215. break;
  8216. case 2:
  8217. map[sd->bl.m].flag.residentevil = 2;
  8218. break;
  8219. }
  8220. }
  8221.  
  8222. switch (map[sd->bl.m].flag.residentevil) {
  8223. case 0:
  8224. clif_displaymessage(fd, "INFO GM: Undead Mode OFF.");
  8225. break;
  8226. case 1:
  8227. clif_displaymessage(fd, "INFO GM: Undead Mode ON (No Exp no Drop).");
  8228. break;
  8229. case 2:
  8230. clif_displaymessage(fd, "INFO GM: Undead Mode ON (Exp and Drop).");
  8231. break;
  8232. }
  8233.  
  8234. return 0;
  8235. }
  8236.  
  8237. /*==========================================
  8238. * Activar o desactivar modo contador muertos. [Tab]
  8239. *------------------------------------------*/
  8240. ACMD_FUNC(contadormuertes)
  8241. {
  8242. int cnt_var0 = 0, cnt_var1 = 0;
  8243. char mensaje[1024];
  8244. nullpo_retr(-1, sd);
  8245.  
  8246. if( !message || !*message || sscanf(message, "%d %d", &cnt_var0, &cnt_var1) < 1 || cnt_var0 < 0 || cnt_var1 < 0 )
  8247. { //Defensa de Midgard XXX / YYY Ejercitos Invasores
  8248. if( map[sd->bl.m].flag.diecounter )
  8249. {
  8250. sprintf (mensaje, "[ Players %d / %d Monsters ]", map[sd->bl.m].pjmuertos, map[sd->bl.m].mobmuertos);
  8251. clif_broadcast(&sd->bl, mensaje, strlen(mensaje) + 1, 0, ALL_SAMEMAP);
  8252. }
  8253. else
  8254. {
  8255. clif_displaymessage(fd, "Kill Counter System (Players vs Mobs)");
  8256. clif_displaymessage(fd, "Usage @mapdeadcounter <Players Lives> <Mobs Lives>");
  8257. clif_displaymessage(fd, "Use only @mapdeadcounter to boradcast current status.");
  8258. clif_displaymessage(fd, "Max Lives limited to 20.000.");
  8259. }
  8260. return -1;
  8261. }
  8262.  
  8263. cnt_var0 = cap_value(cnt_var0, 1, 20000);
  8264. cnt_var1 = cap_value(cnt_var1, 1, 20000);
  8265.  
  8266. if( map[sd->bl.m].flag.diecounter && (cnt_var0 < 1 || cnt_var1 < 1) )
  8267. {
  8268. clif_displaymessage(fd, "Kill Counter System disable.");
  8269. map[sd->bl.m].flag.diecounter = 0;
  8270. map[sd->bl.m].pjmuertos = 0;
  8271. map[sd->bl.m].mobmuertos = 0;
  8272. }
  8273. else
  8274. {
  8275. clif_displaymessage(fd, "Kill Counter System Enable.");
  8276. map[sd->bl.m].flag.diecounter = 1;
  8277. map[sd->bl.m].pjmuertos = cnt_var0;
  8278. map[sd->bl.m].mobmuertos = cnt_var1;
  8279. }
  8280.  
  8281. return 0;
  8282. }
  8283.  
  8284. /*==========================================
  8285. * Activar o desactivar penalty en mapa. [Tab]
  8286. *------------------------------------------*/
  8287. ACMD_FUNC(exppenalty)
  8288. {
  8289. nullpo_retr(-1, sd);
  8290.  
  8291. if (map[sd->bl.m].flag.noexppenalty) {
  8292. clif_displaymessage(fd, "Exp penalty enabled on the current Map.");
  8293. map[sd->bl.m].flag.noexppenalty = 0;
  8294. } else {
  8295. clif_displaymessage(fd, "Exp penalty disabled on the current Map.");
  8296. map[sd->bl.m].flag.noexppenalty = 1;
  8297. }
  8298.  
  8299. return 0;
  8300. }
  8301.  
  8302. /*==========================================
  8303. * Comando para configurar bonus a gusto [Tab]
  8304. *------------------------------------------*/
  8305. ACMD_FUNC(maspowerr)
  8306. {
  8307. int masp_var0 = 0, masp_var1 = 0, masp_var2 = 0, masp_var3 = 0, masp_var4 = 0, masp_var5 = 0, masp_var6 = 0;
  8308. nullpo_retr(-1, sd);
  8309.  
  8310. if (!message || !*message || sscanf(message, "%d %d %d %d %d %d %d", &masp_var0, &masp_var1, &masp_var2, &masp_var3, &masp_var4, &masp_var5, &masp_var6) < 1 || masp_var0 < 0 || masp_var1 < 0 || masp_var2 < 0 || masp_var3 < 0 || masp_var4 < 0 || masp_var5 < 0 || masp_var6 < 0) {
  8311. clif_displaymessage(fd, "- Usage @power <Enable ? 0 = no 1 = yes> <str> <agi> <vit> <int> <dex> <luk>");
  8312. clif_displaymessage(fd, "- Max value for Stats is 3000.");
  8313. return -1;
  8314. }
  8315. if (masp_var0) { // Si es para activar... entonces...
  8316. sd->gm_power = 1;
  8317. clif_displaymessage(fd, "- Game Master Power Enable -");
  8318.  
  8319. sd->gm_stats[0] = cap_value(masp_var1, 0, 3000);
  8320. sd->gm_stats[1] = cap_value(masp_var2, 0, 3000);
  8321. sd->gm_stats[2] = cap_value(masp_var3, 0, 3000);
  8322. sd->gm_stats[3] = cap_value(masp_var4, 0, 3000);
  8323. sd->gm_stats[4] = cap_value(masp_var5, 0, 3000);
  8324. sd->gm_stats[5] = cap_value(masp_var6, 0, 3000);
  8325. } else { // Si es para cualquier otro caso... entonces...
  8326. sd->gm_power = 0;
  8327. clif_displaymessage(fd, "- Game Master Power Disable -");
  8328. }
  8329. status_calc_pc(sd,0); // Recalcula status
  8330.  
  8331. return 0;
  8332. }
  8333.  
  8334. /*==========================================
  8335. * Comando para Corazón de Ciudad [Zephyrus]
  8336. *------------------------------------------
  8337. */
  8338. void cityheart_sub(int id, const int master_id)
  8339. {
  8340. struct mob_data *md = BL_CAST(BL_MOB,map_id2bl(id));
  8341.  
  8342. if (md) {
  8343. md->master_id = master_id;
  8344. clif_misceffect(&md->bl,344);
  8345. }
  8346.  
  8347. return;
  8348. }
  8349.  
  8350. ACMD_FUNC(cityheart)
  8351. {
  8352. int allied = 0, hpmas = 0, master_id = 0;
  8353. char name[NAME_LENGTH];
  8354. struct mob_data *md;
  8355.  
  8356. nullpo_retr(-1, sd);
  8357.  
  8358. if (sscanf(message, "%d %d %23[^\n]", &allied, &hpmas, name) < 2) {
  8359. clif_displaymessage(fd, "Usage @cityheart <allied to players ? 0 : 1> <Max HP> <Name>");
  8360. return -1;
  8361. }
  8362.  
  8363. hpmas = cap_value(hpmas,1,10000000);
  8364. allied = cap_value(allied,0,1);
  8365.  
  8366. // Creación del Corazón
  8367. md = (struct mob_data *)map_id2bl(mob_once_spawn_especial(sd, "this", sd->bl.x, sd->bl.y, name, MOBID_EMPERIUM, 1, "", hpmas, 0, allied, false, 0, 1, true, false, true, 0, 0, 0, false, 0, 0));
  8368. if (md) {
  8369. clif_misceffect(&md->bl,344);
  8370. master_id = md->bl.id;
  8371. } else {
  8372. clif_displaymessage(fd, "Cannot create the City Heart. Please check your position.");
  8373. return -1;
  8374. }
  8375.  
  8376. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x, sd->bl.y + 5, "North Guardian", 1674, 1, "", hpmas, 2, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8377. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x, sd->bl.y - 5, "South Guardian", 1674, 1, "", hpmas, 2, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8378. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x + 5, sd->bl.y, "East Guardian", 1674, 1, "", hpmas, 2, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8379. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x - 5, sd->bl.y, "West Guardian", 1674, 1, "", hpmas, 2, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8380.  
  8381. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x + 5, sd->bl.y + 5, "Stone", 1674, 1, "", hpmas, 1, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8382. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x + 5, sd->bl.y - 5, "Stone", 1674, 1, "", hpmas, 1, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8383. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x - 5, sd->bl.y + 5, "Stone", 1674, 1, "", hpmas, 1, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8384. cityheart_sub(mob_once_spawn_especial(sd, "this", sd->bl.x - 5, sd->bl.y - 5, "Stone", 1674, 1, "", hpmas, 1, allied, false, 0, 0, false, false, true, 0, 0, 0, false, 0, 0), master_id);
  8385.  
  8386. return 0;
  8387. }
  8388.  
  8389. /*==========================================
  8390. * Special Mob Summons
  8391. *------------------------------------------*/
  8392. ACMD_FUNC(mobdemolition)
  8393. {
  8394. int amount = 0, type = 0, power = 0, ratio = 0;
  8395.  
  8396. nullpo_retr(-1, sd);
  8397.  
  8398. if (!message || !*message || (sscanf(message, "%d %d %d %d", &type, &amount, &ratio, &power) < 4)) {
  8399. // Modo de Uso
  8400. clif_displaymessage(fd, "Usage @mobdemolition <Damage who? 0 = all 1 = only mobs> <Amount> <Area> <Power>");
  8401. return -1;
  8402. }
  8403.  
  8404. amount = cap_value(amount,1,20);
  8405. ratio = cap_value(ratio,1,20);
  8406. power = cap_value(power,1,1000000);
  8407.  
  8408. mob_demolition (sd->bl.m, sd->bl.x, sd->bl.y, (short)ratio, type, amount, power);
  8409. return 0;
  8410. }
  8411.  
  8412. ACMD_FUNC(mobevent)
  8413. {
  8414. char name[NAME_LENGTH];
  8415. int mob_id = 0, range, x = 0, y = 0;
  8416. int number = 1, tamano = 0, hpmas = 0, slaves = 0, spawntipo = 0, showkill = 0, mostrarhp = 0, pasawarps = 0, aliado = 0, hprateannounce = 0, noexpnodrop = 1, item_drop = 0, item_amount = 0;
  8417. int count, i, k;
  8418. short mx, my;
  8419. struct mob_data *md;
  8420.  
  8421. nullpo_retr(-1, sd);
  8422.  
  8423. if( !message || !*message || (sscanf(message, "%23s %d %d %d %d %d %d %d %d %d %d %d %d %d", name, &number, &hpmas, &tamano, &aliado, &spawntipo, &slaves, &pasawarps, &mostrarhp, &hprateannounce, &showkill, &noexpnodrop, &item_drop, &item_amount) < 1) )
  8424. { // Modo de Uso
  8425. clif_displaymessage(fd, "================================================================================");
  8426. clif_displaymessage(fd, "@mobevent <name/id> <amount> <HP> ...");
  8427. clif_displaymessage(fd, "... <size> 0 normal | 1 small | 2 big");
  8428. clif_displaymessage(fd, "... <type> | 0 : Normal Mob aggresive status.");
  8429. clif_displaymessage(fd, ".......... | 1 : PC Allied / Enemy vs Mob Type 0 and 2.");
  8430. clif_displaymessage(fd, ".......... | 2 : PC and MOB Type 1 Enemy (Aggresive).");
  8431. clif_displaymessage(fd, ".......... | 3 : Ignores PC and PC cannot attack it / Aggresive vs MOD type 1.");
  8432. clif_displaymessage(fd, "... <spawn position> 0 random | 1 your current pos");
  8433. clif_displaymessage(fd, "... <Slaves?> 0 Allow to summon it if the mob can | 1 no slaves allowed");
  8434. clif_displaymessage(fd, "... <warps> 0 cannot use warps | 1 can use map warps | 2 and warp skill too");
  8435. clif_displaymessage(fd, "... <showHP?> 0 Normal | 1 HpMeter Bar | 2 Current/MaxHP | 3 Percent");
  8436. clif_displaymessage(fd, "... <HPrateAnnounce?> 0 off | 1 each 10% less or more HP a map announce appears");
  8437. clif_displaymessage(fd, "... <AnnounceKiller?> 0 off | 1 Map announce of the killer of the mob");
  8438. clif_displaymessage(fd, "... <NoExpnoDrop?> 0 off | 1 on (No exp and job awards)");
  8439. clif_displaymessage(fd, "... <Item ID> Item to be droped when killed (Use -1 to do Item rain event)");
  8440. clif_displaymessage(fd, "... <Item Amount> Amount of previous Item to be droped when killed");
  8441. clif_displaymessage(fd, "================================================================================");
  8442. return -1;
  8443. }
  8444.  
  8445. if( (mob_id = atoi(name)) == 0 )
  8446. mob_id = mobdb_searchname(name);
  8447.  
  8448. if( mob_id == 0 || mobdb_checkid(mob_id) == 0 )
  8449. {
  8450. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8451. return -1;
  8452. }
  8453.  
  8454. if( battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit )
  8455. number = battle_config.atc_spawn_quantity_limit;
  8456.  
  8457. hpmas = cap_value(hpmas, 0, 10000000);
  8458. tamano = cap_value(tamano, 0, 2);
  8459. aliado = cap_value(aliado, 0, 3);
  8460. spawntipo = cap_value(spawntipo, 0, 1);
  8461. slaves = cap_value(slaves, 0, 1);
  8462. pasawarps = cap_value(pasawarps, 0, 2);
  8463.  
  8464. mostrarhp = cap_value(mostrarhp, 0, 3);
  8465. hprateannounce = cap_value(hprateannounce, 0, 1);
  8466. showkill = cap_value(showkill, 0, 1);
  8467. noexpnodrop = cap_value(noexpnodrop, 0, 1);
  8468.  
  8469. // Aditional Drop Event
  8470. if( item_drop > 0 )
  8471. {
  8472. if( !itemdb_exists(item_drop) )
  8473. {
  8474. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  8475. return -1;
  8476. }
  8477. else
  8478. item_amount = cap_value(item_amount, 1, 200);
  8479. }
  8480. else
  8481. item_amount = 0;
  8482.  
  8483.  
  8484. count = 0;
  8485. range = (int)sqrt((float)number) +2;
  8486. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  8487. if( spawntipo )
  8488. {
  8489. mx = sd->bl.x;
  8490. my = sd->bl.y;
  8491. }
  8492.  
  8493. for( i = 0; i < number; i++ )
  8494. {
  8495. if( !spawntipo )
  8496. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  8497.  
  8498. k = mob_once_spawn_especial(sd, "this", mx, my, "--ja--", mob_id, 1, "",
  8499. hpmas, tamano, aliado, slaves, pasawarps, mostrarhp, hprateannounce, showkill, noexpnodrop, 0, item_drop, item_amount, false, 0, 0);
  8500.  
  8501. if( (md = (struct mob_data *)map_id2bl(k)) )
  8502. count ++;
  8503. }
  8504.  
  8505. if( count != 0 )
  8506. if( number == count )
  8507. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  8508. else
  8509. {
  8510. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  8511. clif_displaymessage(fd, atcmd_output);
  8512. }
  8513. else
  8514. {
  8515. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8516. return -1;
  8517. }
  8518.  
  8519. return 0;
  8520. }
  8521.  
  8522. #ifndef TXT_ONLY
  8523.  
  8524. /*==========================================
  8525. * Personajes usando IP [Zephyrus]
  8526. *------------------------------------------*/
  8527. ACMD_FUNC(whoip)
  8528. {
  8529. StringBuf buf;
  8530. int ip1 = 0, ip2 = 0, ip3 = 0, ip4 = 0;
  8531. char last_ip[20];
  8532.  
  8533. memset(last_ip, '\0', sizeof(last_ip));
  8534.  
  8535. if (!message || !*message || sscanf(message, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) < 4) {
  8536. clif_displaymessage(fd, "Please enter the IP Address. Usage @whoip <ip1>.<ip2>.<ip3>.<ip4>");
  8537. return -1;
  8538. }
  8539.  
  8540. if (ip1 < 0 || ip1 > 255) ip1 = 0;
  8541. if (ip2 < 0 || ip2 > 255) ip2 = 0;
  8542. if (ip3 < 0 || ip3 > 255) ip3 = 0;
  8543. if (ip4 < 0 || ip4 > 255) ip4 = 0;
  8544.  
  8545. sprintf(last_ip, "%d.%d.%d.%d", ip1, ip2, ip3, ip4);
  8546.  
  8547. StringBuf_Init(&buf);
  8548. StringBuf_Printf(&buf, "SELECT `char`.`char_id`, `login`.`member_id` FROM `char` LEFT JOIN `login` ON `login`.`account_id` = `char`.`account_id` WHERE `login`.`last_ip` = '%s' AND `char`.`online` = '1'", last_ip);
  8549.  
  8550. if( SQL_ERROR == Sql_Query(mmysql_handle, StringBuf_Value(&buf)) )
  8551. {
  8552. Sql_ShowDebug(mmysql_handle);
  8553. ShowWarning("Atcommand_whoip: MySQL Querry Error.\n");
  8554. }
  8555. else if ( Sql_NumRows(mmysql_handle) == 0 )
  8556. {
  8557. clif_displaymessage(fd, "No results found in the given IP Address.");
  8558. }
  8559. else
  8560. {
  8561. while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  8562. {
  8563. char* data;
  8564. int char_id, member_id;
  8565. struct map_session_data* pl_sd;
  8566.  
  8567. Sql_GetData(mmysql_handle, 0, &data, NULL); char_id = atoi(data);
  8568. Sql_GetData(mmysql_handle, 1, &data, NULL); member_id = atoi(data);
  8569.  
  8570. if( (pl_sd = map_charid2sd(char_id)) != NULL )
  8571. {
  8572. sprintf(atcmd_output, "Char : %s Map: %s (CHR: %d | ACC: %d | MEMBER: %d)", pl_sd->status.name, map[pl_sd->bl.m].name, pl_sd->status.char_id, pl_sd->status.account_id, member_id);
  8573. clif_displaymessage(fd, atcmd_output);
  8574. }
  8575. }
  8576. }
  8577.  
  8578. StringBuf_Destroy(&buf);
  8579. Sql_FreeResult(mmysql_handle);
  8580.  
  8581. return 0;
  8582. }
  8583.  
  8584. /*==========================================
  8585. * Reporte de Cuentas de una IP [Zephyrus]
  8586. *------------------------------------------*/
  8587. ACMD_FUNC(ipinfo)
  8588. {
  8589. StringBuf buf;
  8590. int ip1 = 0, ip2 = 0, ip3 = 0, ip4 = 0;
  8591. char last_ip[20];
  8592.  
  8593. memset(last_ip, '\0', sizeof(last_ip));
  8594.  
  8595. if( !message || !*message || sscanf(message, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) < 4 )
  8596. {
  8597. clif_displaymessage(fd, "Please enter the IP Address. Usage @ipinfo <ip1>.<ip2>.<ip3>.<ip4>");
  8598. return -1;
  8599. }
  8600.  
  8601. if (ip1 < 0 || ip1 > 255) ip1 = 0;
  8602. if (ip2 < 0 || ip2 > 255) ip2 = 0;
  8603. if (ip3 < 0 || ip3 > 255) ip3 = 0;
  8604. if (ip4 < 0 || ip4 > 255) ip4 = 0;
  8605.  
  8606. sprintf(last_ip, "%d.%d.%d.%d", ip1, ip2, ip3, ip4);
  8607.  
  8608. StringBuf_Init(&buf);
  8609. StringBuf_Printf(&buf, "SELECT `account_id`, `member_id`, `userid`, `lastlogin`, `email` FROM `login` WHERE `last_ip` = '%s'", last_ip);
  8610.  
  8611. if( SQL_ERROR == Sql_Query(mmysql_handle, StringBuf_Value(&buf)) )
  8612. {
  8613. Sql_ShowDebug(mmysql_handle);
  8614. ShowWarning("Atcommand_ipinfo: MySQL Query Error.\n");
  8615. }
  8616. else if ( Sql_NumRows(mmysql_handle) == 0 )
  8617. {
  8618. clif_displaymessage(fd, "No results found in the given IP Address.");
  8619. }
  8620. else
  8621. {
  8622. while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  8623. {
  8624. char* data;
  8625. int account_id, member_id;
  8626. char userid[NAME_LENGTH], lastlogin[24], email[40];
  8627.  
  8628. Sql_GetData(mmysql_handle, 0, &data, NULL); account_id = atoi(data);
  8629. Sql_GetData(mmysql_handle, 1, &data, NULL); member_id = atoi(data);
  8630. Sql_GetData(mmysql_handle, 2, &data, NULL); safestrncpy(userid, data, sizeof(userid));
  8631. Sql_GetData(mmysql_handle, 3, &data, NULL); safestrncpy(lastlogin, data, sizeof(lastlogin));
  8632. Sql_GetData(mmysql_handle, 4, &data, NULL); safestrncpy(email, data, sizeof(email));
  8633.  
  8634. sprintf(atcmd_output, "Account : %s (%d) | ID : %d | Email: %s | %s", userid, member_id, account_id, email, lastlogin);
  8635. clif_displaymessage(fd, atcmd_output);
  8636. }
  8637. }
  8638.  
  8639. StringBuf_Destroy(&buf);
  8640. Sql_FreeResult(mmysql_handle);
  8641.  
  8642. return 0;
  8643. }
  8644.  
  8645. /*==========================================
  8646. * Consulta de personajes en una misma cuenta [Zephyrus]
  8647. *------------------------------------------*/
  8648. ACMD_FUNC(charlist)
  8649. {
  8650. struct map_session_data *pl_sd;
  8651. char name[NAME_LENGTH], esc_name[NAME_LENGTH*2+1];
  8652. char *data;
  8653. int account_id = 0;
  8654.  
  8655. nullpo_retr(-1, sd);
  8656. memset(name, '\0', sizeof(name));
  8657.  
  8658. if( !message || !*message || sscanf(message, "%23[^\n]", name) < 1 )
  8659. {
  8660. clif_displaymessage(fd, "Please, input a character name. Usage @charlist <char name>).");
  8661. return -1;
  8662. }
  8663.  
  8664. if ((pl_sd = map_nick2sd(name)) != NULL)
  8665. account_id = pl_sd->status.account_id;
  8666. else
  8667. {
  8668. Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
  8669. if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `account_id` FROM `char` WHERE `name` = '%s'", esc_name) )
  8670. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8671.  
  8672. if ( Sql_NumRows(mmysql_handle) == 0 )
  8673. clif_displaymessage(fd, "Character name don't exists in the Database.");
  8674. else
  8675. {
  8676. Sql_NextRow(mmysql_handle);
  8677. Sql_GetData(mmysql_handle, 0, &data, NULL); account_id = atoi(data);
  8678. }
  8679.  
  8680. Sql_FreeResult(mmysql_handle);
  8681. }
  8682.  
  8683. if( account_id )
  8684. {
  8685. if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `name`, `class`, `base_level`, `char_num`, `online` FROM `char` WHERE `account_id` = '%d' ORDER BY `char_num`", account_id) )
  8686. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8687. else
  8688. {
  8689. sprintf(atcmd_output, "-- Characters founds in the same Account ID %d --", account_id);
  8690. clif_displaymessage(fd, atcmd_output);
  8691. while ( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  8692. {
  8693. int class_;
  8694. short base_level, char_num, online;
  8695.  
  8696. Sql_GetData(mmysql_handle, 0, &data, NULL); safestrncpy(name, data, sizeof(name));
  8697. Sql_GetData(mmysql_handle, 1, &data, NULL); class_ = atoi(data);
  8698. Sql_GetData(mmysql_handle, 2, &data, NULL); base_level = atoi(data);
  8699. Sql_GetData(mmysql_handle, 3, &data, NULL); char_num = atoi(data);
  8700. Sql_GetData(mmysql_handle, 4, &data, NULL); online = atoi(data);
  8701.  
  8702. sprintf(atcmd_output, "[%d] %s | Class : %s | Base Level : %d | Online : %d.", char_num, name, job_name(class_), base_level, online);
  8703. clif_displaymessage(fd, atcmd_output);
  8704. }
  8705. }
  8706.  
  8707. Sql_FreeResult(mmysql_handle);
  8708. }
  8709.  
  8710. return 0;
  8711. }
  8712.  
  8713. /*==========================================
  8714. * Información de una cuenta [Account ID]
  8715. *------------------------------------------*/
  8716. void account_info(const int fd, struct map_session_data *sd, int account_id)
  8717. {
  8718. int member_id = 0;
  8719. char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20];
  8720. short level = -1;
  8721. char *data;
  8722.  
  8723. if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `level`, `member_id` FROM `login` WHERE `account_id` = '%d'", account_id) )
  8724. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8725. else if( Sql_NumRows(mmysql_handle) == 0 )
  8726. clif_displaymessage(fd, "Account not found.");
  8727. else
  8728. {
  8729. Sql_NextRow(mmysql_handle);
  8730. Sql_GetData(mmysql_handle, 0, &data, NULL); safestrncpy(userid, data, sizeof(userid));
  8731. Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(user_pass, data, sizeof(user_pass));
  8732. Sql_GetData(mmysql_handle, 2, &data, NULL); safestrncpy(email, data, sizeof(email));
  8733. Sql_GetData(mmysql_handle, 3, &data, NULL); safestrncpy(last_ip, data, sizeof(last_ip));
  8734. Sql_GetData(mmysql_handle, 4, &data, NULL); level = atoi(data);
  8735. Sql_GetData(mmysql_handle, 5, &data, NULL); member_id = atoi(data);
  8736. }
  8737.  
  8738. Sql_FreeResult(mmysql_handle);
  8739.  
  8740. if( level == -1 )
  8741. return;
  8742.  
  8743. if( level >= pc_isGM(sd) )
  8744. {
  8745. clif_displaymessage(fd, "You cannot get account information of your same or higher level.");
  8746. return;
  8747. }
  8748.  
  8749. sprintf(atcmd_output, "-- Account %d Report --", account_id);
  8750. clif_displaymessage(fd, atcmd_output);
  8751. sprintf(atcmd_output, "User : %s | Member ID : %d", userid, member_id);
  8752. clif_displaymessage(fd, atcmd_output);
  8753.  
  8754. if( pc_isGM(sd) > 1 )
  8755. {
  8756. sprintf(atcmd_output, "Password : %s.", user_pass);
  8757. clif_displaymessage(fd, atcmd_output);
  8758. }
  8759.  
  8760. sprintf(atcmd_output, "Email : %s.", email);
  8761. clif_displaymessage(fd, atcmd_output);
  8762. sprintf(atcmd_output, "Last IP : %s.", last_ip);
  8763. clif_displaymessage(fd, atcmd_output);
  8764.  
  8765. clif_displaymessage(fd, "-- Character's Details --");
  8766.  
  8767. if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `online` FROM `char` WHERE `account_id` = '%d' ORDER BY `char_num`", account_id) )
  8768. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8769. else if( Sql_NumRows(mmysql_handle) == 0 )
  8770. clif_displaymessage(fd, "No characters founds in the account.");
  8771. else
  8772. {
  8773. while ( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  8774. {
  8775. int char_id, class_;
  8776. short char_num, base_level, online;
  8777. char name[NAME_LENGTH];
  8778.  
  8779. Sql_GetData(mmysql_handle, 0, &data, NULL); char_id = atoi(data);
  8780. Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
  8781. Sql_GetData(mmysql_handle, 2, &data, NULL); char_num = atoi(data);
  8782. Sql_GetData(mmysql_handle, 3, &data, NULL); class_ = atoi(data);
  8783. Sql_GetData(mmysql_handle, 4, &data, NULL); base_level = atoi(data);
  8784. Sql_GetData(mmysql_handle, 5, &data, NULL); online = atoi(data);
  8785.  
  8786. sprintf(atcmd_output, "[%d] %s (%d) | %s Base Level %d | Online: %d", char_num, name, char_id, job_name(class_), base_level, online);
  8787. clif_displaymessage(fd, atcmd_output);
  8788. }
  8789. }
  8790.  
  8791. Sql_FreeResult(mmysql_handle);
  8792.  
  8793. clif_displaymessage(fd, "-- Storage Password --");
  8794.  
  8795. if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `value` FROM `global_reg_value` WHERE `account_id` = '%d' AND `str` = '#kafra_code' AND `value` <> '0'", account_id) )
  8796. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8797. else if( Sql_NumRows(mmysql_handle) == 0 )
  8798. clif_displaymessage(fd, "No Storage Password.");
  8799. else
  8800. {
  8801. int value;
  8802. Sql_NextRow(mmysql_handle);
  8803. Sql_GetData(mmysql_handle, 0, &data, NULL); value = atoi(data);
  8804.  
  8805. sprintf(atcmd_output, "...> %d <...", value - account_id - 1337);
  8806. clif_displaymessage(fd, atcmd_output);
  8807. }
  8808.  
  8809. Sql_FreeResult(mmysql_handle);
  8810.  
  8811. return;
  8812. }
  8813.  
  8814. ACMD_FUNC(accountinfo)
  8815. {
  8816. int account_id = 0;
  8817.  
  8818. nullpo_retr(-1, sd);
  8819.  
  8820. if( !message || !*message )
  8821. {
  8822. clif_displaymessage(fd, "Please enter the Account ID. Usage @accountinfo <account_id>.");
  8823. return -1;
  8824. }
  8825.  
  8826. account_id = atoi(message);
  8827.  
  8828. if( account_id < START_ACCOUNT_NUM )
  8829. {
  8830. clif_displaymessage(fd, "Invalid account ID.");
  8831. return -1;
  8832. }
  8833.  
  8834. account_info(fd, sd, account_id);
  8835.  
  8836. return 0;
  8837. }
  8838.  
  8839. ACMD_FUNC(logininfo)
  8840. {
  8841. char userid[NAME_LENGTH], esc_userid[NAME_LENGTH*2+1];
  8842. int account_id = 0;
  8843.  
  8844. nullpo_retr(-1, sd);
  8845.  
  8846. if( !message || !*message )
  8847. {
  8848. clif_displaymessage(fd, "Please enter the account's Username. Usage @logininfo <userid>.");
  8849. return -1;
  8850. }
  8851.  
  8852. safestrncpy(userid, message, sizeof(userid));
  8853.  
  8854. Sql_EscapeStringLen(mmysql_handle, esc_userid, userid, strnlen(userid, NAME_LENGTH));
  8855. if ( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `account_id` FROM `login` WHERE `userid` = BINARY '%s'", esc_userid) )
  8856. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8857. else if ( Sql_NumRows(mmysql_handle) == 0 )
  8858. clif_displaymessage(fd, "Account not found.");
  8859. else
  8860. {
  8861. char *data;
  8862.  
  8863. Sql_NextRow(mmysql_handle);
  8864. Sql_GetData(mmysql_handle, 0, &data, NULL);
  8865. account_id = atoi(data);
  8866. }
  8867.  
  8868. Sql_FreeResult(mmysql_handle);
  8869.  
  8870. if (!account_id)
  8871. return 0;
  8872.  
  8873. if (account_id < START_ACCOUNT_NUM)
  8874. clif_displaymessage(fd, "Invalid Account ID.");
  8875. else
  8876. account_info(fd, sd, account_id);
  8877.  
  8878. return 0;
  8879. }
  8880.  
  8881. /*==========================================
  8882. * Información de Membresías
  8883. *------------------------------------------*/
  8884. ACMD_FUNC(memberinfo)
  8885. {
  8886. int member_id = 0, i;
  8887. char esc_email[81], email[40], mpass[40];
  8888. bool is_gm = false;
  8889. short mlevel = 0;
  8890. char *data;
  8891.  
  8892. nullpo_retr(-1,sd);
  8893.  
  8894. if( !message || !*message )
  8895. {
  8896. clif_displaymessage(fd, "Enter the Member ID or Email. Usage: @memberinfo <member_id/email>.");
  8897. return -1;
  8898. }
  8899.  
  8900. if( (member_id = atoi(message)) > 0 )
  8901. i = Sql_Query(mmysql_handle, "SELECT `member_id`, `email`, `mpass`, `mlevel` FROM `members` WHERE `member_id` = '%d'", member_id);
  8902. else
  8903. { // Search by Email
  8904. Sql_EscapeStringLen(mmysql_handle, esc_email, message, strnlen(message, 40));
  8905. i = Sql_Query(mmysql_handle, "SELECT `member_id`, `email`, `mpass`, `mlevel` FROM `members` WHERE `email` LIKE '%s'", esc_email);
  8906. }
  8907.  
  8908. if( i == SQL_ERROR )
  8909. {
  8910. clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
  8911. member_id = 0;
  8912. }
  8913. else if( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  8914. {
  8915. Sql_GetData(mmysql_handle, 0, &data, NULL); member_id = atoi(data);
  8916. Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(email, data, sizeof(email));
  8917. Sql_GetData(mmysql_handle, 2, &data, NULL); safestrncpy(mpass, data, sizeof(mpass));
  8918. Sql_GetData(mmysql_handle, 3, &data, NULL); mlevel = atoi(data);
  8919. }
  8920. else
  8921. {
  8922. clif_displaymessage(fd, "No Member information found.");
  8923. member_id = 0;
  8924. }
  8925.  
  8926. Sql_FreeResult(mmysql_handle);
  8927. if( member_id == 0 )
  8928. return -1;
  8929.  
  8930. if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `account_id`, `userid`, `level`, `user_pass`, `last_ip` FROM `login` WHERE `member_id` = '%d'", member_id) )
  8931. clif_displaymessage(fd, "MySQL Query Error. Please report to a Developer.");
  8932. else if ( Sql_NumRows(mmysql_handle) == 0 )
  8933. clif_displaymessage(fd, "No accounts founds in this membership.");
  8934. else
  8935. {
  8936. while ( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  8937. {
  8938. int account_id; short level;
  8939. char userid[NAME_LENGTH], user_pass[NAME_LENGTH], last_ip[20];
  8940. char *data;
  8941.  
  8942. Sql_GetData(mmysql_handle, 0, &data, NULL); account_id = atoi(data);
  8943. Sql_GetData(mmysql_handle, 1, &data, NULL); safestrncpy(userid, data, sizeof(userid));
  8944. Sql_GetData(mmysql_handle, 2, &data, NULL); level = atoi(data);
  8945. Sql_GetData(mmysql_handle, 3, &data, NULL); safestrncpy(user_pass, data, sizeof(user_pass));
  8946. Sql_GetData(mmysql_handle, 4, &data, NULL); safestrncpy(last_ip, data, sizeof(last_ip));
  8947.  
  8948. if( level >= pc_isGM(sd) )
  8949. {
  8950. is_gm = true;
  8951. clif_displaymessage(fd, "-- GM Account with highest Level --");
  8952. }
  8953. else
  8954. {
  8955. sprintf(atcmd_output, "[%d] %s | Password: %s | Last IP: %s", account_id, userid, user_pass, last_ip);
  8956. clif_displaymessage(fd, atcmd_output);
  8957. }
  8958. }
  8959. }
  8960. Sql_FreeResult(mmysql_handle);
  8961.  
  8962. if( !is_gm )
  8963. {
  8964. if( mlevel > 0 )
  8965. clif_displaymessage(fd, "-- Special Membership. Cannot access more information --");
  8966. else
  8967. {
  8968. sprintf(atcmd_output, "Member ID [%d] Email %s Password %s", member_id, email, mpass);
  8969. clif_displaymessage(fd, atcmd_output);
  8970. }
  8971. }
  8972. else
  8973. clif_displaymessage(fd, "-- This Membership belong to another GM. Cannot access more information --");
  8974.  
  8975. return 0;
  8976. }
  8977.  
  8978. /*==========================================
  8979. * Account Transfer2Membership
  8980. *------------------------------------------*/
  8981. ACMD_FUNC(moveaccount)
  8982. {
  8983. int account_id = 0, member_id = 0, level = 0;
  8984. char email[40], userid[NAME_LENGTH];
  8985. char *data;
  8986. nullpo_retr(-1,sd);
  8987.  
  8988. if( !message || !*message || sscanf(message, "%d %d", &account_id, &member_id) < 2 )
  8989. {
  8990. clif_displaymessage(fd, "Please enter Account ID and destination Member ID. @moveaccount <account id> <member id>");
  8991. return -1;
  8992. }
  8993.  
  8994. // Searching for Member Information
  8995. if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `email` FROM `members` WHERE `member_id` = '%d'", member_id) )
  8996. {
  8997. clif_displaymessage(fd, "Query Error... Please notify a Developer.");
  8998. member_id = 0;
  8999. }
  9000. else if( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  9001. {
  9002. Sql_GetData(mmysql_handle, 0, &data, NULL);
  9003. safestrncpy(email, data, sizeof(email));
  9004. }
  9005. else
  9006. {
  9007. clif_displaymessage(fd, "Member ID don't exists.");
  9008. member_id = 0;
  9009. }
  9010.  
  9011. Sql_FreeResult(mmysql_handle);
  9012.  
  9013. // Searching for Login Information
  9014. if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT `userid`, `level` FROM `login` WHERE `account_id` = '%d'", account_id) )
  9015. {
  9016. clif_displaymessage(fd, "Query Error... Please notify a Developer.");
  9017. account_id = 0;
  9018. }
  9019. else if( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
  9020. {
  9021. Sql_GetData(mmysql_handle, 0, &data, NULL); safestrncpy(userid, data, sizeof(userid));
  9022. Sql_GetData(mmysql_handle, 1, &data, NULL); level = atoi(data);
  9023. }
  9024. else
  9025. {
  9026. clif_displaymessage(fd, "Account ID don't exists.");
  9027. account_id = 0;
  9028. }
  9029.  
  9030. Sql_FreeResult(mmysql_handle);
  9031.  
  9032. // Account Update
  9033. if( member_id && account_id )
  9034. {
  9035. if( level >= pc_isGM(sd) )
  9036. clif_displaymessage(fd, "You cannot move Game Master account highest than yours.");
  9037. else
  9038. {
  9039. char esc_email[81];
  9040. Sql_EscapeStringLen(mmysql_handle, esc_email, email, strnlen(email, 40));
  9041. if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `login` SET `member_id` = '%d', `email` = '%s' WHERE `account_id` = '%d'", member_id, esc_email, account_id) )
  9042. clif_displaymessage(fd, "Account Transfer Error. Please notify a Developer.");
  9043. else
  9044. {
  9045. struct map_session_data *pl_sd;
  9046. clif_displaymessage(fd, "Account Transfer Completed.");
  9047. if( (pl_sd = map_id2sd(account_id)) != NULL )
  9048. { // Notify Player
  9049. sprintf(atcmd_output, "Your account have been transfered to another membership. New Email %s.", email);
  9050. clif_displaymessage(pl_sd->fd, atcmd_output);
  9051. }
  9052. }
  9053. }
  9054. }
  9055.  
  9056. return 0;
  9057. }
  9058.  
  9059. #endif
  9060.  
  9061. /*==========================================
  9062. * Comando para buscar un vendedor de X item [Zephyrus]
  9063. *------------------------------------------*/
  9064. ACMD_FUNC(whosell)
  9065. {
  9066. struct map_session_data *pl_sd, *b_sd[MAX_SEARCH];
  9067. struct s_mapiterator* iter;
  9068.  
  9069. struct item_data *item_array[MAX_SEARCH];
  9070. int total[MAX_SEARCH], amount[MAX_SEARCH];
  9071. unsigned int MinPrice[MAX_SEARCH], MaxPrice[MAX_SEARCH];
  9072. char output[256];
  9073. int i, j, count = 1;
  9074.  
  9075. if( !message || !*message )
  9076. {
  9077. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whosell <item name or ID>).");
  9078. return -1;
  9079. }
  9080.  
  9081. if( (item_array[0] = itemdb_exists(atoi(message))) == NULL )
  9082. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  9083.  
  9084. if( count < 1 )
  9085. { // No items found
  9086. clif_displaymessage(fd, msg_txt(19));
  9087. return -1;
  9088. }
  9089.  
  9090. if( count > MAX_SEARCH ) count = MAX_SEARCH;
  9091.  
  9092. // Preparing Search Recorders
  9093. for( i = 0; i < MAX_SEARCH; i++ )
  9094. {
  9095. total[i] = amount[i] = MaxPrice[i] = 0;
  9096. MinPrice[i] = battle_config.vending_max_value + 1;
  9097. b_sd[i] = NULL;
  9098. }
  9099.  
  9100. iter = mapit_getallusers();
  9101. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  9102. {
  9103. if( !pl_sd->vender_id ) continue;
  9104. for( i = 0; i < pl_sd->vend_num; i++ )
  9105. { // Searching in the Vending List
  9106. for( j = 0; j < count; j++ )
  9107. { // Compares with each search result
  9108. if( pl_sd->status.cart[pl_sd->vending[i].index].nameid != item_array[j]->nameid )
  9109. continue;
  9110.  
  9111. amount[j] += pl_sd->vending[i].amount;
  9112. total[j]++;
  9113.  
  9114. if( pl_sd->vending[i].value < MinPrice[j] )
  9115. { // Best Price
  9116. MinPrice[j] = pl_sd->vending[i].value;
  9117. b_sd[j] = pl_sd;
  9118. }
  9119. if( pl_sd->vending[i].value > MaxPrice[j] )
  9120. MaxPrice[j] = pl_sd->vending[i].value;
  9121. }
  9122. }
  9123. }
  9124. mapit_free(iter);
  9125.  
  9126. for( i = 0; i < count; i++ )
  9127. {
  9128. if( total[i] > 0 && b_sd[i] != NULL )
  9129. {
  9130. sprintf(output, "[%d] El mejor precio de '%s' es %u por '%s' en %s <%d,%d>. Max %u. Encontrado en %d shops, %d en venta.", item_array[i]->nameid, item_array[i]->jname, MinPrice[i], b_sd[i]->status.name, map[b_sd[i]->bl.m].name, b_sd[i]->bl.x, b_sd[i]->bl.y, MaxPrice[i], total[i], amount[i]);
  9131. if( sd->bl.m == b_sd[i]->bl.m )
  9132. clif_viewpoint(sd, 1, 1, b_sd[i]->bl.x, b_sd[i]->bl.y, i, 0xFFFFFF);
  9133. }
  9134. else
  9135. sprintf(output, "[%d] '%s' no está en tiendas...", item_array[i]->nameid, item_array[i]->jname);
  9136.  
  9137. clif_displaymessage(sd->fd, output);
  9138. }
  9139.  
  9140. return 0;
  9141. }
  9142.  
  9143. /*==========================================
  9144. * Creación de items en el suelo, en un Area.
  9145. *------------------------------------------*/
  9146. ACMD_FUNC(flooritem)
  9147. {
  9148. char item_name[100];
  9149. int number = 0, count;
  9150. struct item_data *item_data;
  9151. nullpo_retr(-1, sd);
  9152.  
  9153. memset(item_name, '\0', sizeof(item_name));
  9154.  
  9155. if( !message || !*message || (
  9156. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  9157. sscanf(message, "%99s %d", item_name, &number) < 1
  9158. )) {
  9159. clif_displaymessage(fd, "Usage: @flooritem <itemname/itemid> [quantity]");
  9160. return -1;
  9161. }
  9162.  
  9163. if( number <= 0 )
  9164. number = 1;
  9165.  
  9166. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  9167. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  9168. {
  9169. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  9170. return -1;
  9171. }
  9172.  
  9173. count = map_addflooritem_area(&sd->bl, 0, 0, 0, item_data->nameid, number);
  9174.  
  9175. if( count != 0 )
  9176. if( number == count )
  9177. clif_displaymessage(fd, "All items created.");
  9178. else
  9179. {
  9180. sprintf(atcmd_output, "%d item(s) created.", count);
  9181. clif_displaymessage(fd, atcmd_output);
  9182. }
  9183. else {
  9184. clif_displaymessage(fd, "No items created!!.");
  9185. return -1;
  9186. }
  9187.  
  9188. return 0;
  9189. }
  9190.  
  9191. /*==========================================
  9192. * Duel organizing functions [LuzZza]
  9193. *
  9194. * @duel [limit|nick] - create a duel
  9195. * @invite <nick> - invite player
  9196. * @accept - accept invitation
  9197. * @reject - reject invitation
  9198. * @leave - leave duel
  9199. *------------------------------------------*/
  9200. ACMD_FUNC(invite)
  9201. {
  9202. unsigned int did = sd->duel_group;
  9203. struct map_session_data *target_sd = map_nick2sd((char *)message);
  9204.  
  9205. if(did <= 0) {
  9206. // "Duel: @invite without @duel."
  9207. clif_displaymessage(fd, msg_txt(350));
  9208. return 0;
  9209. }
  9210.  
  9211. if(duel_list[did].max_players_limit > 0 &&
  9212. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  9213.  
  9214. // "Duel: Limit of players is reached."
  9215. clif_displaymessage(fd, msg_txt(351));
  9216. return 0;
  9217. }
  9218.  
  9219. if(target_sd == NULL) {
  9220. // "Duel: Player not found."
  9221. clif_displaymessage(fd, msg_txt(352));
  9222. return 0;
  9223. }
  9224.  
  9225. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9226. // "Duel: Player already in duel."
  9227. clif_displaymessage(fd, msg_txt(353));
  9228. return 0;
  9229. }
  9230.  
  9231. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  9232. {
  9233. sprintf(atcmd_output, msg_txt(364), message);
  9234. clif_displaymessage(fd, atcmd_output);
  9235. return 0;
  9236. }
  9237.  
  9238. duel_invite(did, sd, target_sd);
  9239. // "Duel: Invitation has been sent."
  9240. clif_displaymessage(fd, msg_txt(354));
  9241. return 0;
  9242. }
  9243.  
  9244. ACMD_FUNC(duel)
  9245. {
  9246. char output[CHAT_SIZE_MAX];
  9247. unsigned int maxpl=0, newduel;
  9248. struct map_session_data *target_sd;
  9249.  
  9250. if(sd->duel_group > 0) {
  9251. duel_showinfo(sd->duel_group, sd);
  9252. return 0;
  9253. }
  9254.  
  9255. if(sd->duel_invite > 0) {
  9256. // "Duel: @duel without @reject."
  9257. clif_displaymessage(fd, msg_txt(355));
  9258. return 0;
  9259. }
  9260.  
  9261. if(sd->state.pvpmode) {
  9262. clif_displaymessage(fd, "You cannot Duel on PVP Mode.");
  9263. return 0;
  9264. }
  9265.  
  9266. if(sd->status.guild_id && guild_isatwar(sd->status.guild_id)) {
  9267. clif_displaymessage(fd, "You cannot Duel if your guild is at War.");
  9268. return 0;
  9269. }
  9270.  
  9271. if(!duel_checktime(sd)) {
  9272. // "Duel: You can take part in duel only one time per %d minutes."
  9273. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9274. clif_displaymessage(fd, output);
  9275. return 0;
  9276. }
  9277.  
  9278. if( message[0] ) {
  9279. if(sscanf(message, "%d", &maxpl) >= 1) {
  9280. if(maxpl < 2 || maxpl > 65535) {
  9281. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  9282. return 0;
  9283. }
  9284. duel_create(sd, maxpl);
  9285. } else {
  9286. target_sd = map_nick2sd((char *)message);
  9287. if(target_sd != NULL) {
  9288. if((newduel = duel_create(sd, 2)) != -1) {
  9289. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9290. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  9291. return 0;
  9292. }
  9293. duel_invite(newduel, sd, target_sd);
  9294. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  9295. }
  9296. } else {
  9297. // "Duel: Player not found."
  9298. clif_displaymessage(fd, msg_txt(352));
  9299. return 0;
  9300. }
  9301. }
  9302. } else
  9303. duel_create(sd, 0);
  9304.  
  9305. return 0;
  9306. }
  9307.  
  9308.  
  9309. ACMD_FUNC(leave)
  9310. {
  9311. if(sd->duel_group <= 0) {
  9312. // "Duel: @leave without @duel."
  9313. clif_displaymessage(fd, msg_txt(358));
  9314. return 0;
  9315. }
  9316.  
  9317. duel_leave(sd->duel_group, sd);
  9318. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  9319. return 0;
  9320. }
  9321.  
  9322. ACMD_FUNC(accept)
  9323. {
  9324. char output[CHAT_SIZE_MAX];
  9325.  
  9326. if(sd->state.pvpmode) {
  9327. clif_displaymessage(fd, "You cannot Duel on PVP Mode.");
  9328. return 0;
  9329. }
  9330.  
  9331. if(sd->status.guild_id && guild_isatwar(sd->status.guild_id)) {
  9332. clif_displaymessage(fd, "You cannot Duel if your guild is at War.");
  9333. return 0;
  9334. }
  9335.  
  9336. if(!duel_checktime(sd)) {
  9337. // "Duel: You can take part in duel only one time per %d minutes."
  9338. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9339. clif_displaymessage(fd, output);
  9340. return 0;
  9341. }
  9342.  
  9343. if(sd->duel_invite <= 0) {
  9344. // "Duel: @accept without invititation."
  9345. clif_displaymessage(fd, msg_txt(360));
  9346. return 0;
  9347. }
  9348.  
  9349. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  9350. {
  9351. // "Duel: Limit of players is reached."
  9352. clif_displaymessage(fd, msg_txt(351));
  9353. return 0;
  9354. }
  9355.  
  9356. duel_accept(sd->duel_invite, sd);
  9357. // "Duel: Invitation has been accepted."
  9358. clif_displaymessage(fd, msg_txt(361));
  9359. return 0;
  9360. }
  9361.  
  9362. ACMD_FUNC(reject)
  9363. {
  9364. if(sd->duel_invite <= 0) {
  9365. // "Duel: @reject without invititation."
  9366. clif_displaymessage(fd, msg_txt(362));
  9367. return 0;
  9368. }
  9369.  
  9370. duel_reject(sd->duel_invite, sd);
  9371. // "Duel: Invitation has been rejected."
  9372. clif_displaymessage(fd, msg_txt(363));
  9373. return 0;
  9374. }
  9375.  
  9376. /*===================================
  9377. * Cash Points
  9378. *-----------------------------------*/
  9379. ACMD_FUNC(cash)
  9380. {
  9381. int value;
  9382. nullpo_retr(-1, sd);
  9383.  
  9384. if( !message || !*message || (value = atoi(message)) == 0 ) {
  9385. clif_displaymessage(fd, "Please, enter an amount.");
  9386. return -1;
  9387. }
  9388.  
  9389. if( !strcmpi(command+1,"cash") )
  9390. {
  9391. if( value > 0 )
  9392. pc_getcash(sd, value, 0);
  9393. else
  9394. pc_paycash(sd, -value, 0);
  9395. }
  9396. else
  9397. { // @points
  9398. if( value > 0 )
  9399. pc_getcash(sd, 0, value);
  9400. else
  9401. pc_paycash(sd, -value, -value);
  9402. }
  9403.  
  9404. return 0;
  9405. }
  9406.  
  9407. ACMD_FUNC(gcash)
  9408. {
  9409. int value = 0;
  9410. char user[NAME_LENGTH];
  9411. struct map_session_data *pl_sd;
  9412. nullpo_retr(-1,sd);
  9413.  
  9414. if( !message || !*message || sscanf(message, "%d %23[^\r\n]", &value, user) != 2 )
  9415. {
  9416. clif_displaymessage(fd, "Usage: @gcash <amount> <user>.");
  9417. return -1;
  9418. }
  9419.  
  9420. if( (pl_sd = map_nick2sd(user)) == NULL )
  9421. {
  9422. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  9423. return -1;
  9424. }
  9425.  
  9426. if( !pc_can_give_items(pc_isGM(sd)) )
  9427. {
  9428. clif_displaymessage(fd, "Your GM level don't allow you to give cash.");
  9429. return -1;
  9430. }
  9431.  
  9432. if( value <= 0 || sd->cashPoints < value )
  9433. {
  9434. sprintf(atcmd_output, "Invalid value. You have currently %d cash points.", sd->cashPoints);
  9435. clif_displaymessage(fd, atcmd_output);
  9436. return -1;
  9437. }
  9438.  
  9439. if( sd->state.secure_items )
  9440. {
  9441. clif_displaymessage(sd->fd, "You can't transfer Cash. Blocked with @security");
  9442. return 1;
  9443. }
  9444.  
  9445. sprintf(atcmd_output, "'%s' has transfered %d Cash Points to you.", sd->status.name, value);
  9446. clif_disp_onlyself(pl_sd, atcmd_output, strlen(atcmd_output));
  9447. sprintf(atcmd_output, "You have transfered %d Cash Points to '%s'.", value, pl_sd->status.name);
  9448. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9449.  
  9450. pc_paycash(sd, value, 0);
  9451. pc_getcash(pl_sd, value, 0);
  9452.  
  9453. return 0;
  9454. }
  9455.  
  9456. ACMD_FUNC(gpoints)
  9457. {
  9458. int value = 0;
  9459. char user[NAME_LENGTH];
  9460. struct map_session_data *pl_sd;
  9461. nullpo_retr(-1,sd);
  9462.  
  9463. if( !message || !*message || sscanf(message, "%d %23[^\r\n]", &value, user) != 2 )
  9464. {
  9465. clif_displaymessage(fd, "Usage: @gpoints <amount> <user>.");
  9466. return -1;
  9467. }
  9468.  
  9469. if( (pl_sd = map_nick2sd(user)) == NULL )
  9470. {
  9471. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  9472. return -1;
  9473. }
  9474.  
  9475. if( !pc_can_give_items(pc_isGM(sd)) )
  9476. {
  9477. clif_displaymessage(fd, "Your GM level don't allow you to give free cash.");
  9478. return -1;
  9479. }
  9480.  
  9481. if( value <= 0 || sd->kafraPoints < value )
  9482. {
  9483. sprintf(atcmd_output, "Invalid value. You have currently %d kafra points.", sd->kafraPoints);
  9484. clif_displaymessage(fd, atcmd_output);
  9485. return -1;
  9486. }
  9487.  
  9488. if( sd->state.secure_items )
  9489. {
  9490. clif_displaymessage(sd->fd, "You can't transfer Points. Blocked with @security");
  9491. return 1;
  9492. }
  9493.  
  9494. sprintf(atcmd_output, "'%s' has transfered %d Kafra Points to you.", sd->status.name, value);
  9495. clif_disp_onlyself(pl_sd, atcmd_output, strlen(atcmd_output));
  9496. sprintf(atcmd_output, "You have transfered %d Kafra Points to '%s'.", value, pl_sd->status.name);
  9497. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9498.  
  9499. pc_paycash(sd, value, value);
  9500. pc_getcash(pl_sd, 0, value);
  9501.  
  9502. return 0;
  9503. }
  9504.  
  9505. /*===================================
  9506. * Away message (@away, @aw) [LuzZza]
  9507. *-----------------------------------*/
  9508. ACMD_FUNC(away)
  9509. {
  9510. if(strlen(message) > 0) {
  9511. if(strlen(message) > 128)
  9512. return -1;
  9513. strcpy(sd->away_message, message);
  9514. //"Away automessage has been activated."
  9515. clif_displaymessage(fd, msg_txt(546));
  9516. } else {
  9517. if(strlen(sd->away_message) > 0) {
  9518. sd->away_message[0] = 0;
  9519. //"Away automessage has been disabled."
  9520. clif_displaymessage(fd, msg_txt(547));
  9521. return 0;
  9522. }
  9523. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  9524. clif_displaymessage(fd, msg_txt(548));
  9525. }
  9526. return 0;
  9527. }
  9528.  
  9529. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  9530. ACMD_FUNC(clone)
  9531. {
  9532. int x=0,y=0,flag=0,master=0,i=0;
  9533. struct map_session_data *pl_sd=NULL;
  9534.  
  9535. if (!message || !*message) {
  9536. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  9537. return 0;
  9538. }
  9539.  
  9540. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  9541. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  9542. return 0;
  9543. }
  9544.  
  9545. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  9546. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  9547. return 0;
  9548. }
  9549.  
  9550. if (strcmpi(command+1, "clone") == 0)
  9551. flag = 1;
  9552. else if (strcmpi(command+1, "slaveclone") == 0) {
  9553. flag = 2;
  9554. master = sd->bl.id;
  9555. if (battle_config.atc_slave_clone_limit
  9556. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  9557. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  9558. return 0;
  9559. }
  9560. }
  9561.  
  9562. do {
  9563. x = sd->bl.x + (rand() % 10 - 5);
  9564. y = sd->bl.y + (rand() % 10 - 5);
  9565. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  9566.  
  9567. if (i >= 10) {
  9568. x = sd->bl.x;
  9569. y = sd->bl.y;
  9570. }
  9571.  
  9572. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  9573. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  9574. return 0;
  9575. }
  9576. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  9577. return 0;
  9578. }
  9579.  
  9580. /*===================================
  9581. * Chat Channels [Zephyrus]
  9582. *-----------------------------------*/
  9583. ACMD_FUNC(create)
  9584. {
  9585. char room_name[NAME_LENGTH], room_pass[NAME_LENGTH];
  9586. memset(room_name, '\0', sizeof(room_name));
  9587. memset(room_pass, '\0', sizeof(room_pass));
  9588.  
  9589. if( !battle_config.channel_system_enable )
  9590. {
  9591. clif_displaymessage(fd, "Chat Channel System disabled.");
  9592. return -1;
  9593. }
  9594.  
  9595. if( !message || !*message || sscanf(message, "%23s %23[^\n]", room_name, room_pass) < 1 )
  9596. {
  9597. clif_displaymessage(fd, "Usage: @create <#channel_name> <optional_password>");
  9598. return -1;
  9599. }
  9600.  
  9601. if( !channel_create(sd, room_name, trim(room_pass), CHN_USER, 38, 0) )
  9602. return -1;
  9603.  
  9604. return 0;
  9605. }
  9606.  
  9607. ACMD_FUNC(join)
  9608. {
  9609. char room_name[NAME_LENGTH], room_pass[NAME_LENGTH];
  9610. memset(room_name, '\0', sizeof(room_name));
  9611. memset(room_pass, '\0', sizeof(room_pass));
  9612.  
  9613. if( !battle_config.channel_system_enable )
  9614. {
  9615. clif_displaymessage(fd, "Chat Channel System disabled.");
  9616. return -1;
  9617. }
  9618.  
  9619. if( !message || !*message )
  9620. { // Checks if the user has been invited to another channel
  9621. if( sd->channel_invite_timer != INVALID_TIMER )
  9622. {
  9623. channel_invite_accept(sd);
  9624. return 0;
  9625. }
  9626. else
  9627. {
  9628. clif_displaymessage(fd, "Usage: @join <#channel_name> <optional_password>");
  9629. return -1;
  9630. }
  9631. }
  9632.  
  9633. if( sscanf(message, "%23s %23[^\n]", room_name, room_pass) < 1 )
  9634. {
  9635. clif_displaymessage(fd, "Usage: @join <#channel_name> <optional_password>");
  9636. return -1;
  9637. }
  9638.  
  9639. if( DIFF_TICK(sd->canjoinchn_tick, gettick()) > 0 )
  9640. {
  9641. clif_displaymessage(sd->fd, msg_txt(807));
  9642. return -1;
  9643. }
  9644.  
  9645. channel_join(sd, room_name, room_pass, false);
  9646. return 0;
  9647. }
  9648.  
  9649. ACMD_FUNC(exit)
  9650. {
  9651. if( !battle_config.channel_system_enable )
  9652. {
  9653. clif_displaymessage(fd, "Chat Channel System disabled.");
  9654. return -1;
  9655. }
  9656.  
  9657. if( !message || !*message )
  9658. {
  9659. clif_displaymessage(fd, "Usage: @exit <#channel_name>");
  9660. return -1;
  9661. }
  9662.  
  9663. channel_leave(sd, message, true);
  9664. return 0;
  9665. }
  9666.  
  9667. ACMD_FUNC(list)
  9668. {
  9669. if( !battle_config.channel_system_enable )
  9670. {
  9671. clif_displaymessage(fd, "Chat Channel System disabled.");
  9672. return -1;
  9673. }
  9674.  
  9675. channel_list(sd);
  9676. return 0;
  9677. }
  9678.  
  9679. /*=====================================
  9680. * Autorejecting Invites/Deals [LuzZza]
  9681. * Usage: @noask
  9682. *-------------------------------------*/
  9683. ACMD_FUNC(noask)
  9684. {
  9685. if(sd->state.noask) {
  9686. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  9687. sd->state.noask = 0;
  9688. } else {
  9689. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  9690. sd->state.noask = 1;
  9691. }
  9692.  
  9693. return 0;
  9694. }
  9695.  
  9696. /*=====================================
  9697. * Send a @request message to all GMs of lowest_gm_level.
  9698. * Usage: @request <petition>
  9699. *-------------------------------------*/
  9700. ACMD_FUNC(request)
  9701. {
  9702. if (!message || !*message) {
  9703. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  9704. return -1;
  9705. }
  9706.  
  9707. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  9708. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  9709. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9710. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  9711. return 0;
  9712. }
  9713.  
  9714. /*==========================================
  9715. * Feel (SG save map) Reset [HiddenDragon]
  9716. *------------------------------------------*/
  9717. ACMD_FUNC(feelreset)
  9718. {
  9719. pc_resetfeel(sd);
  9720. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  9721.  
  9722. return 0;
  9723. }
  9724.  
  9725. /*==========================================
  9726. * Modo PK para jugadores - Duelos abiertos sin necesidad de crear duelo
  9727. *------------------------------------------*/
  9728. ACMD_FUNC(pvpmode)
  9729. {
  9730. nullpo_retr(-1, sd);
  9731.  
  9732. if( sd->duel_group > 0 && !sd->state.pvpmode )
  9733. {
  9734. clif_displaymessage(fd, msg_txt(848));
  9735. return -1;
  9736. }
  9737.  
  9738. if( sd->state.pvpmode )
  9739. pc_pvpmodeoff(sd,0,1);
  9740. else
  9741. pc_pvpmode(sd);
  9742.  
  9743. return 0;
  9744. }
  9745.  
  9746. /*==========================================
  9747. * Comando buscador de Personas en Modo PK
  9748. *------------------------------------------*/
  9749. static int atwhopk_sub(struct block_list *bl,va_list ap)
  9750. {
  9751. int fd;
  9752. struct map_session_data *sd, *pl;
  9753. static int number=0;
  9754. char pl_info[100];
  9755.  
  9756. if( !ap )
  9757. {
  9758. number = 0;
  9759. return 0;
  9760. }
  9761. fd = va_arg(ap,int);
  9762. sd = va_arg(ap,struct map_session_data*);
  9763.  
  9764. pl = (TBL_PC*)bl; // Esto lo retorna el Map_foreachinmap
  9765.  
  9766. if( !pl->state.pvpmode || pl == sd )
  9767. return 0; // Ignora jugadores que no estén en Modo PK o al Mismo Jugador
  9768.  
  9769. if( fd )
  9770. {
  9771. sprintf(pl_info, msg_txt(849), pl->status.name, bl->x, bl->y, pl->status.pk.score);
  9772. clif_disp_onlyself(sd ,(const char*)pl_info,(int)strlen((const char*)pl_info));
  9773. clif_viewpoint(sd, 1, 0, bl->x, bl->y, ++number, 0xFF0000);
  9774. }
  9775.  
  9776. return 0;
  9777. }
  9778.  
  9779. ACMD_FUNC(whopk)
  9780. {
  9781. int map_id;
  9782. nullpo_retr(-1, sd);
  9783.  
  9784. if( !sd->state.pvpmode )
  9785. {
  9786. clif_displaymessage(fd, msg_txt(850) );
  9787. return -1;
  9788. }
  9789.  
  9790. map_id = sd->bl.m;
  9791. clif_displaymessage(fd, msg_txt(851) );
  9792. map_foreachinmap(atwhopk_sub, map_id, BL_PC, fd, sd);
  9793.  
  9794. atwhopk_sub(&sd->bl,0);
  9795.  
  9796. return 0;
  9797. }
  9798.  
  9799. /*==========================================
  9800. * Comando para abrir el Storage adicional
  9801. *------------------------------------------*/
  9802. ACMD_FUNC(rentstorage)
  9803. {
  9804. nullpo_retr(-1, sd);
  9805.  
  9806. if (sd->npc_id || sd->vender_id || sd->buyer_id || sd->state.trading || sd->state.storage_flag)
  9807. return -1;
  9808.  
  9809. if( premium_usage && map_flag_vs(sd->bl.m) )
  9810. return -1;
  9811.  
  9812. if (ext_storage_open(sd) == 1)
  9813. { //Already open.
  9814. clif_displaymessage(fd, msg_txt(250));
  9815. return -1;
  9816. }
  9817. return 0;
  9818. }
  9819.  
  9820. /*==========================================
  9821. * Auras personalizadas
  9822. *------------------------------------------*/
  9823. ACMD_FUNC(aura)
  9824. {
  9825. int type;
  9826.  
  9827. type = atoi(message);
  9828. sprintf(atcmd_output, "Current Aura: %d", sd->user_aura);
  9829. clif_displaymessage(fd, atcmd_output);
  9830.  
  9831. sd->user_aura = type;
  9832. pc_setglobalreg(sd,"USERAURA",type);
  9833. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  9834.  
  9835. return 0;
  9836. }
  9837.  
  9838. /*==========================================
  9839. * AUCTION SYSTEM
  9840. *------------------------------------------*/
  9841. ACMD_FUNC(auction)
  9842. {
  9843. nullpo_ret(sd);
  9844.  
  9845. #ifndef TXT_ONLY
  9846. clif_Auction_openwindow(sd);
  9847. #endif
  9848.  
  9849. return 0;
  9850. }
  9851.  
  9852. /*==========================================
  9853. * Kill Steal Protection
  9854. *------------------------------------------*/
  9855. ACMD_FUNC(ksprotection)
  9856. {
  9857. nullpo_retr(-1,sd);
  9858.  
  9859. if( sd->state.noks )
  9860. {
  9861. sd->state.noks = 0;
  9862. sprintf(atcmd_output, msg_txt(857));
  9863. }
  9864. else
  9865. {
  9866. if( !message || !*message || !strcmpi(message, "party") )
  9867. { // Default is Party
  9868. sd->state.noks = 2;
  9869. sprintf(atcmd_output, msg_txt(858));
  9870. }
  9871. else if( !strcmpi(message, "self") )
  9872. {
  9873. sd->state.noks = 1;
  9874. sprintf(atcmd_output, msg_txt(859));
  9875. }
  9876. else if( !strcmpi(message, "guild") )
  9877. {
  9878. sd->state.noks = 3;
  9879. sprintf(atcmd_output, msg_txt(860));
  9880. }
  9881. else
  9882. sprintf(atcmd_output, msg_txt(861));
  9883. }
  9884.  
  9885. clif_displaymessage(fd, atcmd_output);
  9886. return 0;
  9887. }
  9888. /*==========================================
  9889. * Map Kill Steal Protection Setting
  9890. *------------------------------------------*/
  9891. ACMD_FUNC(allowks)
  9892. {
  9893. nullpo_retr(-1,sd);
  9894.  
  9895. if( map[sd->bl.m].flag.allowks )
  9896. {
  9897. map[sd->bl.m].flag.allowks = 0;
  9898. sprintf(atcmd_output, msg_txt(862));
  9899. }
  9900. else
  9901. {
  9902. map[sd->bl.m].flag.allowks = 1;
  9903. sprintf(atcmd_output, msg_txt(863));
  9904. }
  9905.  
  9906. clif_displaymessage(fd, atcmd_output);
  9907. return 0;
  9908. }
  9909.  
  9910. ACMD_FUNC(resetstat)
  9911. {
  9912. nullpo_retr(-1, sd);
  9913.  
  9914. pc_resetstate(sd);
  9915. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  9916. clif_displaymessage(fd, atcmd_output);
  9917. return 0;
  9918. }
  9919.  
  9920. ACMD_FUNC(resetskill)
  9921. {
  9922. nullpo_retr(-1,sd);
  9923.  
  9924. pc_resetskill(sd,1);
  9925. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  9926. clif_displaymessage(fd, atcmd_output);
  9927. return 0;
  9928. }
  9929.  
  9930. /*==========================================
  9931. * #storagelist: Displays the items list of a player's storage.
  9932. * #cartlist: Displays contents of target's cart.
  9933. * #itemlist: Displays contents of target's inventory.
  9934. *------------------------------------------*/
  9935. ACMD_FUNC(itemlist)
  9936. {
  9937. int i, j, count, counter;
  9938. const char* location;
  9939. const struct item* items;
  9940. int size;
  9941. StringBuf buf;
  9942.  
  9943. nullpo_retr(-1, sd);
  9944.  
  9945. if( strcmp(command+1, "storagelist") == 0 )
  9946. {
  9947. location = "storage";
  9948. items = sd->status.storage.items;
  9949. size = MAX_STORAGE;
  9950. }
  9951. else
  9952. if( strcmp(command+1, "cartlist") == 0 )
  9953. {
  9954. location = "cart";
  9955. items = sd->status.cart;
  9956. size = MAX_CART;
  9957. }
  9958. else
  9959. if( strcmp(command+1, "itemlist") == 0 )
  9960. {
  9961. location = "inventory";
  9962. items = sd->status.inventory;
  9963. size = MAX_INVENTORY;
  9964. }
  9965. else
  9966. return 1;
  9967.  
  9968. StringBuf_Init(&buf);
  9969.  
  9970. count = 0; // total slots occupied
  9971. counter = 0; // total items found
  9972. for( i = 0; i < size; ++i )
  9973. {
  9974. const struct item* it = &items[i];
  9975. struct item_data* itd;
  9976.  
  9977. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  9978. continue;
  9979.  
  9980. counter += it->amount;
  9981. count++;
  9982.  
  9983. if( count == 1 )
  9984. {
  9985. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  9986. clif_displaymessage(fd, StringBuf_Value(&buf));
  9987. StringBuf_Clear(&buf);
  9988. }
  9989.  
  9990. if( it->refine )
  9991. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  9992. else
  9993. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  9994.  
  9995. if( it->equip )
  9996. {
  9997. char equipstr[CHAT_SIZE_MAX];
  9998. strcpy(equipstr, " | equipped: ");
  9999. if( it->equip & EQP_GARMENT )
  10000. strcat(equipstr, "garment, ");
  10001. if( it->equip & EQP_ACC_L )
  10002. strcat(equipstr, "left accessory, ");
  10003. if( it->equip & EQP_ARMOR )
  10004. strcat(equipstr, "body/armor, ");
  10005. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  10006. strcat(equipstr, "right hand, ");
  10007. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  10008. strcat(equipstr, "left hand, ");
  10009. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  10010. strcat(equipstr, "both hands, ");
  10011. if( it->equip & EQP_SHOES )
  10012. strcat(equipstr, "feet, ");
  10013. if( it->equip & EQP_ACC_R )
  10014. strcat(equipstr, "right accessory, ");
  10015. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  10016. strcat(equipstr, "lower head, ");
  10017. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  10018. strcat(equipstr, "top head, ");
  10019. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  10020. strcat(equipstr, "lower/top head, ");
  10021. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  10022. strcat(equipstr, "mid head, ");
  10023. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  10024. strcat(equipstr, "lower/mid head, ");
  10025. if( (it->equip & EQP_HELM) == EQP_HELM )
  10026. strcat(equipstr, "lower/mid/top head, ");
  10027. // remove final ', '
  10028. equipstr[strlen(equipstr) - 2] = '\0';
  10029. StringBuf_AppendStr(&buf, equipstr);
  10030. }
  10031.  
  10032. clif_displaymessage(fd, StringBuf_Value(&buf));
  10033. StringBuf_Clear(&buf);
  10034.  
  10035. if( it->card[0] == CARD0_PET )
  10036. {// pet egg
  10037. if (it->card[3])
  10038. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  10039. else
  10040. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  10041. }
  10042. else
  10043. if(it->card[0] == CARD0_FORGE)
  10044. {// forged item
  10045. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  10046. }
  10047. else
  10048. if(it->card[0] == CARD0_CREATE)
  10049. {// created item
  10050. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  10051. }
  10052. else
  10053. {// normal item
  10054. int counter2 = 0;
  10055.  
  10056. for( j = 0; j < itd->slot; ++j )
  10057. {
  10058. struct item_data* card;
  10059.  
  10060. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  10061. continue;
  10062.  
  10063. counter2++;
  10064.  
  10065. if( counter2 == 1 )
  10066. StringBuf_AppendStr(&buf, " -> (card(s): ");
  10067.  
  10068. if( counter2 != 1 )
  10069. StringBuf_AppendStr(&buf, ", ");
  10070.  
  10071. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  10072. }
  10073.  
  10074. if( counter2 > 0 )
  10075. StringBuf_AppendStr(&buf, ")");
  10076. }
  10077.  
  10078. if( StringBuf_Length(&buf) > 0 )
  10079. clif_displaymessage(fd, StringBuf_Value(&buf));
  10080.  
  10081. StringBuf_Clear(&buf);
  10082. }
  10083.  
  10084. if( count == 0 )
  10085. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  10086. else
  10087. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  10088.  
  10089. clif_displaymessage(fd, StringBuf_Value(&buf));
  10090.  
  10091. StringBuf_Destroy(&buf);
  10092.  
  10093. return 0;
  10094. }
  10095.  
  10096. ACMD_FUNC(stats)
  10097. {
  10098. char job_jobname[100];
  10099. char output[CHAT_SIZE_MAX];
  10100. int i;
  10101. struct {
  10102. const char* format;
  10103. int value;
  10104. } output_table[] = {
  10105. { "Base Level - %d", 0 },
  10106. { NULL, 0 },
  10107. { "Hp - %d", 0 },
  10108. { "MaxHp - %d", 0 },
  10109. { "Sp - %d", 0 },
  10110. { "MaxSp - %d", 0 },
  10111. { "Str - %3d", 0 },
  10112. { "Agi - %3d", 0 },
  10113. { "Vit - %3d", 0 },
  10114. { "Int - %3d", 0 },
  10115. { "Dex - %3d", 0 },
  10116. { "Luk - %3d", 0 },
  10117. { "Zeny - %d", 0 },
  10118. { "Free SK Points - %d", 0 },
  10119. { "Used SK Points - %d", 0 },
  10120. { "JobChangeLvl - %d", 0 },
  10121. { "Attack Speed MS - %d", 0 },
  10122. { NULL, 0 }
  10123. };
  10124.  
  10125. memset(job_jobname, '\0', sizeof(job_jobname));
  10126. memset(output, '\0', sizeof(output));
  10127.  
  10128. //direct array initialization with variables is not standard C compliant.
  10129. output_table[0].value = sd->status.base_level;
  10130. output_table[1].format = job_jobname;
  10131. output_table[1].value = sd->status.job_level;
  10132. output_table[2].value = sd->status.hp;
  10133. output_table[3].value = sd->status.max_hp;
  10134. output_table[4].value = sd->status.sp;
  10135. output_table[5].value = sd->status.max_sp;
  10136. output_table[6].value = sd->status.str;
  10137. output_table[7].value = sd->status.agi;
  10138. output_table[8].value = sd->status.vit;
  10139. output_table[9].value = sd->status.int_;
  10140. output_table[10].value = sd->status.dex;
  10141. output_table[11].value = sd->status.luk;
  10142. output_table[12].value = sd->status.zeny;
  10143. output_table[13].value = sd->status.skill_point;
  10144. output_table[14].value = pc_calc_skillpoint(sd);
  10145. output_table[15].value = sd->change_level;
  10146. output_table[16].value = status_get_adelay(&sd->bl);
  10147.  
  10148. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  10149. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  10150.  
  10151. clif_displaymessage(fd, output);
  10152.  
  10153. for (i = 0; output_table[i].format != NULL; i++) {
  10154. sprintf(output, output_table[i].format, output_table[i].value);
  10155. clif_displaymessage(fd, output);
  10156. }
  10157.  
  10158. return 0;
  10159. }
  10160.  
  10161. ACMD_FUNC(myinfo)
  10162. {
  10163. char output[CHAT_SIZE_MAX];
  10164. uint32 ip;
  10165. int i;
  10166.  
  10167. struct {
  10168. const char* format;
  10169. int value;
  10170. } output_table[] = {
  10171. { "Cash Points - %d", 0 },
  10172. { "Free/Kafra Points - %d", 0 },
  10173. { NULL, 0 },
  10174. { NULL, 0 },
  10175. { NULL, 0 }
  10176. };
  10177.  
  10178. memset(output, '\0', sizeof(output));
  10179.  
  10180. //direct array initialization with variables is not standard C compliant.
  10181. output_table[0].value = sd->cashPoints;
  10182. output_table[1].value = sd->kafraPoints;
  10183. if( battle_config.myinfo_event_vote_points )
  10184. {
  10185. output_table[2].format = "Event Points - %d";
  10186. output_table[2].value = pc_readaccountreg(sd,"#EVENTPOINTS");
  10187. output_table[3].format = "Vote Points - %d";
  10188. output_table[3].value = pc_readaccountreg(sd,"#VOTEPOINTS");
  10189. }
  10190.  
  10191. sprintf(output, "'%s' Info:", sd->status.name); // '%s' stats:
  10192. clif_displaymessage(fd,output);
  10193.  
  10194. for( i = 0; output_table[i].format != NULL; i++ )
  10195. {
  10196. sprintf(output,output_table[i].format,output_table[i].value);
  10197. clif_displaymessage(fd,output);
  10198. }
  10199.  
  10200. if( pc_isPremium(sd) )
  10201. {
  10202. int tick = sd->Premium_Tick - (int)time(NULL), day, hour, minute, second;
  10203.  
  10204. clif_displaymessage(fd,"- Premium Account Enable -");
  10205. atcommand_expinfo_sub(tick, &day, &hour, &minute, &second);
  10206. sprintf(output,"Expires at - %d days, %02d:%02d:%02d", day, hour, minute, second);
  10207. clif_displaymessage(fd,output);
  10208. }
  10209.  
  10210. ip = session[sd->fd]->client_addr;
  10211. sprintf(output,"IP Address - %d.%d.%d.%d",CONVIP(ip));
  10212. clif_displaymessage(fd,output);
  10213.  
  10214. return 0;
  10215. }
  10216.  
  10217. ACMD_FUNC(delitem)
  10218. {
  10219. char item_name[100];
  10220. int nameid, amount = 0, total, idx;
  10221. struct item_data* id;
  10222.  
  10223. nullpo_retr(-1, sd);
  10224.  
  10225. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  10226. {
  10227. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  10228. return -1;
  10229. }
  10230.  
  10231. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  10232. {
  10233. nameid = id->nameid;
  10234. }
  10235. else
  10236. {
  10237. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  10238. return -1;
  10239. }
  10240.  
  10241. total = amount;
  10242.  
  10243. // delete items
  10244. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  10245. {
  10246. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  10247.  
  10248. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  10249. {// delete pet
  10250. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  10251. }
  10252.  
  10253. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  10254.  
  10255. amount-= delamount;
  10256. }
  10257.  
  10258. // notify target
  10259. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  10260. clif_displaymessage(sd->fd, atcmd_output);
  10261.  
  10262. // notify source
  10263. if( amount == total )
  10264. {
  10265. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  10266. }
  10267. else if( amount )
  10268. {
  10269. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  10270. clif_displaymessage(fd, atcmd_output);
  10271. }
  10272. else
  10273. {
  10274. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  10275. clif_displaymessage(fd, atcmd_output);
  10276. }
  10277.  
  10278. return 0;
  10279. }
  10280.  
  10281. /*==========================================
  10282. * Exp Gain Information
  10283. *------------------------------------------*/
  10284. void atcommand_expinfo_sub(int time, int* day, int* hour, int* minute, int* second)
  10285. {
  10286. *day = time / 86400; time -= *day * 84600;
  10287. *hour = time / 3600; time -= *hour * 3600;
  10288. *minute = time / 60; time -= *minute * 60;
  10289. *second = time;
  10290.  
  10291. *day = *day > 0 ? *day : 0;
  10292. *hour = *hour > 0 ? *hour : 0;
  10293. *minute = *minute > 0 ? *minute : 0;
  10294. *second = *second > 0 ? *second : 0;
  10295.  
  10296. return;
  10297. }
  10298.  
  10299. ACMD_FUNC(expinfo)
  10300. {
  10301. unsigned int nextb, nextj, bexp_ps, jexp_ps, nextbt, nextjt;
  10302. int session_time, day = 0, hour = 0, minute = 0, second = 0;
  10303.  
  10304. nullpo_retr(-1,sd);
  10305.  
  10306. if( !strcmpi(message, "reset") )
  10307. { // Restart Vars
  10308. sd->custom_data.session_base_exp = 0;
  10309. sd->custom_data.session_job_exp = 0;
  10310. sd->custom_data.session_start = last_tick;
  10311. }
  10312. else if( !strcmpi(message, "off") )
  10313. {
  10314. sd->state.showgain = 0;
  10315. clif_displaymessage(fd, msg_txt(864));
  10316.  
  10317. return 0;
  10318. }
  10319. else if( !strcmpi(message, "on") )
  10320. {
  10321. sd->state.showgain = 1;
  10322. clif_displaymessage(fd, msg_txt(865));
  10323.  
  10324. return 0;
  10325. }
  10326. else
  10327. clif_displaymessage(fd, msg_txt(866));
  10328.  
  10329. session_time = DIFF_TICK(last_tick, sd->custom_data.session_start);
  10330.  
  10331. atcommand_expinfo_sub(session_time, &day, &hour, &minute, &second);
  10332. sprintf(atcmd_output, msg_txt(867), day, hour, minute, second);
  10333. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  10334.  
  10335. if( session_time <= 0 )
  10336. return 0;
  10337.  
  10338. nextb = pc_nextbaseexp(sd);
  10339. nextj = pc_nextjobexp(sd);
  10340.  
  10341. sprintf(atcmd_output, msg_txt(868), sd->custom_data.session_base_exp, sd->custom_data.session_job_exp);
  10342. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  10343.  
  10344. if( nextb )
  10345. { // Next Base lvl information
  10346. if( (bexp_ps = sd->custom_data.session_base_exp / session_time) < 1 )
  10347. sprintf(atcmd_output, msg_txt(869), bexp_ps);
  10348. else if( (nextbt = (nextb - sd->status.base_exp) / bexp_ps) < 604800 )
  10349. {
  10350. atcommand_expinfo_sub(nextbt, &day, &hour, &minute, &second);
  10351. if( day )
  10352. sprintf(atcmd_output, msg_txt(870), bexp_ps, day, hour, minute, second);
  10353. else
  10354. sprintf(atcmd_output, msg_txt(871), bexp_ps, hour, minute, second);
  10355. }
  10356. else
  10357. sprintf(atcmd_output, msg_txt(869), bexp_ps);
  10358.  
  10359. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  10360. }
  10361.  
  10362. if( nextj )
  10363. { // Next Job lvl information
  10364. if( (jexp_ps = sd->custom_data.session_job_exp / session_time) < 1 )
  10365. sprintf(atcmd_output, msg_txt(872), jexp_ps);
  10366. else if( (nextjt = (nextj - sd->status.job_exp) / jexp_ps) < 604800 )
  10367. {
  10368. atcommand_expinfo_sub(nextjt, &day, &hour, &minute, &second);
  10369. if( day )
  10370. sprintf(atcmd_output, msg_txt(873), jexp_ps, day, hour, minute, second);
  10371. else
  10372. sprintf(atcmd_output, msg_txt(874), jexp_ps, hour, minute, second);
  10373. }
  10374. else
  10375. sprintf(atcmd_output, msg_txt(872), jexp_ps);
  10376.  
  10377. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  10378. }
  10379.  
  10380. return 0;
  10381. }
  10382. /*==========================================
  10383. * Hunting Mission [Zephyrus]
  10384. *------------------------------------------*/
  10385. ACMD_FUNC(mission)
  10386. {
  10387. int i, c = 0;
  10388. nullpo_retr(-1,sd);
  10389.  
  10390. if( sd->hunting[0].mob_id == 0 )
  10391. {
  10392. clif_displaymessage(fd, "You are not hunting.");
  10393. return 0;
  10394. }
  10395.  
  10396. for( i = 0; i < 5; i++ )
  10397. {
  10398. if( sd->hunting[i].count < 1 )
  10399. continue;
  10400.  
  10401. sprintf(atcmd_output, "- Hunting %d '%s' (ID : %d)", sd->hunting[i].count, mob_db(sd->hunting[i].mob_id)->jname, sd->hunting[i].mob_id);
  10402. clif_displaymessage(fd, atcmd_output);
  10403.  
  10404. c = sd->hunting[i].count;
  10405. }
  10406.  
  10407. if( c < 1 )
  10408. clif_displaymessage(fd, "Hunting Mission Completed");
  10409. else if( sd->hunting_time < (int)time(NULL) )
  10410. clif_displaymessage(fd, "Hunting Mission Failed");
  10411. else
  10412. {
  10413. int tick = sd->hunting_time - (int)time(NULL),
  10414. day, hour, minute, second;
  10415.  
  10416. atcommand_expinfo_sub(tick, &day, &hour, &minute, &second);
  10417. sprintf(atcmd_output, "Time Left : %02d:%02d:%02d", hour, minute, second);
  10418. clif_displaymessage(fd, atcmd_output);
  10419. }
  10420.  
  10421. return 0;
  10422. }
  10423.  
  10424. /*==========================================
  10425. * Custom Fonts
  10426. *------------------------------------------*/
  10427. ACMD_FUNC(font)
  10428. {
  10429. int font_id;
  10430. nullpo_retr(-1,sd);
  10431.  
  10432. font_id = atoi(message);
  10433. if( font_id == 0 )
  10434. {
  10435. if( sd->user_font )
  10436. {
  10437. sd->user_font = 0;
  10438. clif_displaymessage(fd, "Returning to normal font.");
  10439. clif_font(sd);
  10440. }
  10441. else
  10442. {
  10443. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  10444. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  10445. }
  10446. }
  10447. else if( font_id < 0 || font_id > 9 )
  10448. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  10449. else if( font_id != sd->user_font )
  10450. {
  10451. sd->user_font = font_id;
  10452. clif_font(sd);
  10453. clif_displaymessage(fd, "Font changed.");
  10454. }
  10455. else
  10456. clif_displaymessage(fd, "Already using this font.");
  10457.  
  10458. return 0;
  10459. }
  10460.  
  10461. /*==========================================
  10462. * Char Data Backup Generation.
  10463. *------------------------------------------*/
  10464. ACMD_FUNC(char2dump)
  10465. {
  10466. int char_id;
  10467.  
  10468. nullpo_retr(-1,sd);
  10469.  
  10470. if( (char_id = atoi(message)) <= 0 )
  10471. return -1;
  10472.  
  10473. chrif_char2dumpfile(char_id);
  10474. clif_displaymessage(fd, "Requesting char server to do a backup of Char data");
  10475.  
  10476. return 0;
  10477. }
  10478.  
  10479. /*=========================================
  10480. * Item Security System
  10481. *-----------------------------------------*/
  10482. ACMD_FUNC(security)
  10483. {
  10484. nullpo_retr(-1,sd);
  10485. if( sd->npc_id || sd->vender_id || sd->buyer_id || sd->state.trading || sd->state.storage_flag )
  10486. return -1;
  10487.  
  10488. npc_event(sd,"SecuritySystem::OnSettings",0);
  10489. return 0;
  10490. }
  10491.  
  10492. /*==========================================
  10493. * Packet Filter
  10494. *------------------------------------------*/
  10495. ACMD_FUNC(packetfilter)
  10496. {
  10497. nullpo_retr(-1,sd);
  10498. if( !message || !*message )
  10499. {
  10500. clif_displaymessage(fd,"<<----- Packet Filtering Usage ----->>");
  10501. clif_displaymessage(fd,". @packetfilter <options>");
  10502. clif_displaymessage(fd,". C : To filter global chat messages.");
  10503. clif_displaymessage(fd,". I : To filter item usage.");
  10504. clif_displaymessage(fd,". - Samples");
  10505. clif_displaymessage(fd,". @packetfilter CI : To filter the 2 options.");
  10506. clif_displaymessage(fd,". @packetfilter off : To turn packet filter off.");
  10507. }
  10508. else if( !strcmpi(message,"off") )
  10509. {
  10510. sd->state.packet_filter = 0;
  10511. clif_displaymessage(fd,"<< Packet Filtering Off >>");
  10512. }
  10513. else
  10514. {
  10515. if( strstr(message,"C") )
  10516. sd->state.packet_filter |= 1;
  10517. if( strstr(message,"I") )
  10518. sd->state.packet_filter |= 2;
  10519.  
  10520. sprintf(atcmd_output,"<< Packet Filtering | Chat %s | Items %s >>", (sd->state.packet_filter&1) ? "ON" : "OFF", (sd->state.packet_filter&2) ? "ON" : "OFF");
  10521. clif_displaymessage(fd,atcmd_output);
  10522. }
  10523.  
  10524. return 0;
  10525. }
  10526.  
  10527. /*==========================================
  10528. * Guild Skill Usage for Guild Masters
  10529. *------------------------------------------*/
  10530. ACMD_FUNC(guildskill)
  10531. {
  10532. int i, skillnum = 0, skilllv = 0, idx;
  10533. unsigned int tick = gettick();
  10534. struct battleground_data *bg;
  10535. struct guild *g;
  10536.  
  10537. const struct { char skillstr[3]; int id; } skills[] = {
  10538. { "BO", 10010 },
  10539. { "RG", 10011 },
  10540. { "RS", 10012 },
  10541. { "EC", 10013 },
  10542. };
  10543.  
  10544. // Check for Skill ID
  10545. for( i = 0; i < ARRAYLENGTH(skills); i++ )
  10546. {
  10547. if( strncmpi(message, skills[i].skillstr, 3) == 0 )
  10548. {
  10549. skillnum = skills[i].id;
  10550. break;
  10551. }
  10552. }
  10553. if( !skillnum )
  10554. {
  10555. clif_displaymessage(fd, "Invalid Skill string. Use @guildskill EC/RS/RG/BO");
  10556. return -1;
  10557. }
  10558.  
  10559. idx = battle_config.guild_skills_separed_delay ? skillnum - GD_SKILLBASE : 0;
  10560. if( !map[sd->bl.m].flag.battleground )
  10561. {
  10562. if( (g = sd->state.gmaster_flag) != NULL )
  10563. {
  10564. if( g->skill_block_timer[idx] == INVALID_TIMER )
  10565. skilllv = guild_checkskill(g, skillnum);
  10566. else
  10567. {
  10568. guild_block_skill_status(g, skillnum);
  10569. skilllv = 0;
  10570. }
  10571. }
  10572. else
  10573. {
  10574. clif_displaymessage(fd, "This command is reserved for Guild Leaders Only.");
  10575. return -1;
  10576. }
  10577. }
  10578. else
  10579. {
  10580. if( (bg = sd->bmaster_flag) != NULL )
  10581. {
  10582. if( bg->skill_block_timer[idx] == INVALID_TIMER )
  10583. skilllv = bg_checkskill(bg, skillnum);
  10584. else
  10585. {
  10586. bg_block_skill_status(bg, skillnum);
  10587. skilllv = 0;
  10588. }
  10589. }
  10590. else
  10591. {
  10592. clif_displaymessage(fd, "This command is reserved for Team Leaders Only.");
  10593. return -1;
  10594. }
  10595. }
  10596.  
  10597. if( pc_cant_act(sd) || pc_issit(sd) || skillnotok(skillnum, sd) || sd->ud.skilltimer != -1 || sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER) || sd->state.only_walk || sd->sc.data[SC_BASILICA] )
  10598. return -1;
  10599.  
  10600. if( DIFF_TICK(tick, sd->ud.canact_tick) < 0 )
  10601. return -1;
  10602.  
  10603. if( sd->menuskill_id )
  10604. {
  10605. if( sd->menuskill_id == SA_TAMINGMONSTER )
  10606. sd->menuskill_id = sd->menuskill_val = 0; //Cancel pet capture.
  10607. else if( sd->menuskill_id != SA_AUTOSPELL )
  10608. return -1; //Can't use skills while a menu is open.
  10609. }
  10610.  
  10611. sd->skillitem = sd->skillitemlv = 0;
  10612. if( skilllv ) unit_skilluse_id(&sd->bl, sd->bl.id, skillnum, skilllv);
  10613. return 0;
  10614. }
  10615.  
  10616. /*==========================================
  10617. * Battleground Leader Commands
  10618. *------------------------------------------*/
  10619. ACMD_FUNC(order)
  10620. {
  10621. nullpo_retr(-1,sd);
  10622. if( !message || !*message )
  10623. {
  10624. clif_displaymessage(fd, "Please, enter a message (usage: @order <message>).");
  10625. return -1;
  10626. }
  10627.  
  10628. if( map[sd->bl.m].flag.battleground )
  10629. {
  10630. if( !sd->bmaster_flag )
  10631. {
  10632. clif_displaymessage(fd, "This command is reserved for Team Leaders Only.");
  10633. return -1;
  10634. }
  10635. clif_broadcast2(&sd->bl, message, (int)strlen(message)+1, sd->bmaster_flag->color, 0x190, 20, 0, 0, BG);
  10636. }
  10637. else
  10638. {
  10639. if( !sd->state.gmaster_flag )
  10640. {
  10641. clif_displaymessage(fd, "This command is reserved for Guild Leaders Only.");
  10642. return -1;
  10643. }
  10644. clif_broadcast2(&sd->bl, message, (int)strlen(message)+1, 0xFF0000, 0x190, 20, 0, 0, GUILD);
  10645. }
  10646.  
  10647. return 0;
  10648. }
  10649.  
  10650. ACMD_FUNC(leader)
  10651. {
  10652. struct map_session_data *pl_sd;
  10653. nullpo_retr(-1,sd);
  10654. if( !sd->bmaster_flag )
  10655. clif_displaymessage(fd, "This command is reserved for Team Leaders Only.");
  10656. else if( sd->ud.skilltimer != INVALID_TIMER )
  10657. clif_displaymessage(fd, "Command not allow while casting a skill.");
  10658. else if( !message || !*message )
  10659. clif_displaymessage(fd, "Please, enter the new Leader name (usage: @leader <name>).");
  10660. else if( (pl_sd = map_nick2sd((char *)message)) == NULL )
  10661. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  10662. else if( sd->bg_id != pl_sd->bg_id )
  10663. clif_displaymessage(fd, "Destination Player is not in your Team.");
  10664. else if( sd == pl_sd )
  10665. clif_displaymessage(fd, "You are already the Team Leader.");
  10666. else
  10667. { // Everytest OK!
  10668. sprintf(atcmd_output, "Team Leader transfered to [%s]", pl_sd->status.name);
  10669. clif_broadcast2(&sd->bl, atcmd_output, (int)strlen(atcmd_output)+1, sd->bmaster_flag->color, 0x190, 20, 0, 0, BG);
  10670.  
  10671. sd->bmaster_flag->leader_char_id = pl_sd->status.char_id;
  10672. pl_sd->bmaster_flag = sd->bmaster_flag;
  10673. sd->bmaster_flag = NULL;
  10674.  
  10675. clif_charnameupdate(sd);
  10676. clif_charnameupdate(pl_sd);
  10677. return 0;
  10678. }
  10679. return -1;
  10680. }
  10681.  
  10682. ACMD_FUNC(reportafk)
  10683. {
  10684. struct map_session_data *pl_sd;
  10685. nullpo_retr(-1,sd);
  10686. if( !sd->bg_id )
  10687. clif_displaymessage(fd, "This command is reserved for Battleground Only.");
  10688. else if( !sd->bmaster_flag && battle_config.bg_reportafk_leaderonly )
  10689. clif_displaymessage(fd, "This command is reserved for Team Leaders Only.");
  10690. else if( !message || !*message )
  10691. clif_displaymessage(fd, "Please, enter the character name (usage: @reportafk <name>).");
  10692. else if( (pl_sd = map_nick2sd((char *)message)) == NULL )
  10693. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  10694. else if( sd->bg_id != pl_sd->bg_id )
  10695. clif_displaymessage(fd, "Destination Player is not in your Team.");
  10696. else if( sd == pl_sd )
  10697. clif_displaymessage(fd, "You cannot kick yourself.");
  10698. else if( pl_sd->state.bg_afk == 0 )
  10699. clif_displaymessage(fd, "The player is not AFK on this Battleground.");
  10700. else
  10701. { // Everytest OK!
  10702. struct battleground_data *bg;
  10703. if( (bg = bg_team_search(sd->bg_id)) == NULL )
  10704. return -1;
  10705.  
  10706. bg_team_leave(pl_sd,2);
  10707. clif_displaymessage(pl_sd->fd, "You have been kicked from Battleground because of your AFK status.");
  10708. pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,3);
  10709.  
  10710. sprintf(atcmd_output, "- AFK [%s] Kicked -", pl_sd->status.name);
  10711. clif_broadcast2(&sd->bl, atcmd_output, (int)strlen(atcmd_output)+1, bg->color, 0x190, 20, 0, 0, BG);
  10712. return 0;
  10713. }
  10714. return -1;
  10715. }
  10716.  
  10717. ACMD_FUNC(listenbg)
  10718. {
  10719. if( sd->state.bg_listen )
  10720. {
  10721. sd->state.bg_listen = 0;
  10722. clif_displaymessage(fd, "You will not receive Battleground announcements.");
  10723. }
  10724. else
  10725. {
  10726. sd->state.bg_listen = 1;
  10727. clif_displaymessage(fd, "You will receive Battleground announcements.");
  10728. }
  10729.  
  10730. return 0;
  10731. }
  10732.  
  10733. ACMD_FUNC(unboundall)
  10734. {
  10735. struct map_session_data *pl_sd;
  10736. nullpo_retr(-1,sd);
  10737. if( !message || !*message )
  10738. clif_displaymessage(fd, "Please, enter the character name (usage: @unboundall <name>).");
  10739. else if( (pl_sd = map_nick2sd((char *)message)) == NULL )
  10740. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  10741. else
  10742. { // Start Unbound process
  10743. int i, c = 0;
  10744. for( i = 0; i < MAX_INVENTORY; i++ )
  10745. {
  10746. if( pl_sd->status.inventory[i].nameid && pl_sd->status.inventory[i].bound )
  10747. {
  10748. pl_sd->status.inventory[i].bound = 0;
  10749. c++;
  10750. }
  10751. }
  10752.  
  10753. if( c )
  10754. {
  10755. sprintf(atcmd_output,"Unbounded %d inventory items.", c);
  10756. clif_displaymessage(fd, atcmd_output);
  10757. c = 0;
  10758. }
  10759.  
  10760. for( i = 0; i < MAX_CART; i++ )
  10761. {
  10762. if( pl_sd->status.cart[i].nameid && pl_sd->status.cart[i].bound )
  10763. {
  10764. pl_sd->status.cart[i].bound = 0;
  10765. c++;
  10766. }
  10767. }
  10768.  
  10769. if( c )
  10770. {
  10771. sprintf(atcmd_output,"Unbounded %d cart items.", c);
  10772. clif_displaymessage(fd, atcmd_output);
  10773. c = 0;
  10774. }
  10775.  
  10776. for( i = 0; i < MAX_STORAGE; i++ )
  10777. {
  10778. if( pl_sd->status.storage.items[i].nameid && pl_sd->status.storage.items[i].bound )
  10779. {
  10780. pl_sd->status.storage.items[i].bound = 0;
  10781. c++;
  10782. }
  10783. }
  10784.  
  10785. if( c )
  10786. {
  10787. sprintf(atcmd_output,"Unbounded %d storage items.", c);
  10788. clif_displaymessage(fd, atcmd_output);
  10789. c = 0;
  10790. }
  10791.  
  10792. for( i = 0; i < MAX_EXTRA_STORAGE; i++ )
  10793. {
  10794. if( pl_sd->status.ext_storage.items[i].nameid && pl_sd->status.ext_storage.items[i].bound )
  10795. {
  10796. pl_sd->status.ext_storage.items[i].bound = 0;
  10797. c++;
  10798. }
  10799. }
  10800.  
  10801. if( c )
  10802. {
  10803. sprintf(atcmd_output,"Unbounded %d ext storage items.", c);
  10804. clif_displaymessage(fd, atcmd_output);
  10805. c = 0;
  10806. }
  10807.  
  10808. clif_refresh(pl_sd);
  10809. return 0;
  10810. }
  10811. return -1;
  10812. }
  10813.  
  10814. ACMD_FUNC(bgranked)
  10815. {
  10816. int i;
  10817.  
  10818. clif_displaymessage(fd, "============= RANKED BATTLEGROUND FAME LIST =============");
  10819. for( i = 0; i < MAX_FAME_LIST && bgrank_fame_list[i].id; i++ )
  10820. {
  10821. sprintf(atcmd_output,"%d - %s - %d points",i+1,bgrank_fame_list[i].name,bgrank_fame_list[i].fame);
  10822. clif_displaymessage(fd, atcmd_output);
  10823. }
  10824. clif_displaymessage(fd, "============= RANKED BATTLEGROUND FAME LIST =============");
  10825. return 0;
  10826. }
  10827.  
  10828. ACMD_FUNC(bgregular)
  10829. {
  10830. int i;
  10831.  
  10832. clif_displaymessage(fd, "============= REGULAR BATTLEGROUND FAME LIST =============");
  10833. for( i = 0; i < MAX_FAME_LIST && bg_fame_list[i].id; i++ )
  10834. {
  10835. sprintf(atcmd_output,"%d - %s - %d points",i+1,bg_fame_list[i].name,bg_fame_list[i].fame);
  10836. clif_displaymessage(fd, atcmd_output);
  10837. }
  10838. clif_displaymessage(fd, "============= REGULAR BATTLEGROUND FAME LIST =============");
  10839. return 0;
  10840. }
  10841.  
  10842. ACMD_FUNC(battleinfo)
  10843. {
  10844. if( sd->state.battleinfo )
  10845. {
  10846. clif_displaymessage(fd, "- Battle Information Display OFF - Kill/Death -");
  10847. sd->state.battleinfo = 0;
  10848. }
  10849. else
  10850. {
  10851. clif_displaymessage(fd, "- Battle Information Display ON - Kill/Death -");
  10852. sd->state.battleinfo = 1;
  10853. }
  10854. return 0;
  10855. }
  10856.  
  10857. /*==========================================
  10858. * Ranking Reset
  10859. *------------------------------------------*/
  10860. ACMD_FUNC(rankreset)
  10861. {
  10862. int type;
  10863. nullpo_retr(-1, sd);
  10864.  
  10865. if( (type = atoi(message)) < 1 || type > 3 )
  10866. {
  10867. clif_displaymessage(fd, "Enter reset rank type. Usage: @rankreset <n>");
  10868. clif_displaymessage(fd, "n = 1 WoE | 2 BG | 3 PVP");
  10869. return -1;
  10870. }
  10871.  
  10872. pc_ranking_reset(type - 1, true);
  10873. clif_displaymessage(fd, "Reseting Ranking...");
  10874. return 0;
  10875. }
  10876.  
  10877. /*==========================================
  10878. * Item Remover
  10879. *------------------------------------------*/
  10880. ACMD_FUNC(item_remove4all)
  10881. {
  10882. int nameid;
  10883. nullpo_retr(-1, sd);
  10884.  
  10885. if( (nameid = atoi(message)) < 500 || !itemdb_exists(nameid) )
  10886. {
  10887. clif_displaymessage(fd, "Enter a Valid Item ID. Usage: @itemdestroy <itemid>");
  10888. return -1;
  10889. }
  10890.  
  10891. pc_item_remove4all(nameid,true);
  10892. clif_displaymessage(fd, "Destroying Item...");
  10893. return 0;
  10894. }
  10895.  
  10896. /*==========================================
  10897. * Fame Points
  10898. *------------------------------------------*/
  10899. ACMD_FUNC(addfame)
  10900. {
  10901. int fame = 0, type = 0;
  10902. nullpo_retr(-1, sd);
  10903.  
  10904. if( !message || !*message || sscanf(message, "%d %d", &type, &fame) < 2 )
  10905. {
  10906. clif_displaymessage(fd, "Usage: @addfame <type> <points>");
  10907. clif_displaymessage(fd, "- type : 0 Class (Alche/BS/TK) | 1 PK | 2 BG Ranked | 3 BG Regular");
  10908.  
  10909. return -1;
  10910. }
  10911.  
  10912. if( type < 0 || type > 3 )
  10913. {
  10914. clif_displaymessage(fd, "Invalid type : 0 Class (Alche/BS/TK) | 1 PK | 2 BG Ranked | 3 BG Regular");
  10915. return -1;
  10916. }
  10917.  
  10918. if( fame <= 0 )
  10919. {
  10920. clif_displaymessage(fd, "Invalid points. Positive value required.");
  10921. return -1;
  10922. }
  10923.  
  10924. pc_addfame(sd,fame,type);
  10925. return 0;
  10926. }
  10927.  
  10928. /*==========================================
  10929. * Visual Mob Info Mode
  10930. *------------------------------------------*/
  10931. static int atcommand_viewmobinfo_sub(struct block_list *bl, va_list ap)
  10932. {
  10933. struct map_session_data *sd;
  10934. struct mob_data *md;
  10935.  
  10936. nullpo_ret(bl);
  10937. nullpo_ret(md = (struct mob_data *)bl);
  10938. nullpo_ret(sd = va_arg(ap, struct map_session_data *));
  10939.  
  10940. clif_mobnameack(sd,md,0);
  10941. return 0;
  10942. }
  10943.  
  10944. ACMD_FUNC(viewmobinfo)
  10945. {
  10946. nullpo_retr(-1,sd);
  10947. if( sd->state.view_mob_info )
  10948. {
  10949. sd->state.view_mob_info = 0;
  10950. clif_displaymessage(fd,"* Viewing mob info data - Disabled *");
  10951. }
  10952. else
  10953. {
  10954. sd->state.view_mob_info = 1;
  10955. clif_displaymessage(fd,"* Viewing mob info data - Enable *");
  10956. }
  10957.  
  10958. map_foreachinarea(atcommand_viewmobinfo_sub, sd->bl.m, sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE, sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE, BL_MOB, sd);
  10959. return 0;
  10960. }
  10961.  
  10962. /*==========================================
  10963. * Teleport On/Off
  10964. *------------------------------------------*/
  10965. ACMD_FUNC(teleport)
  10966. {
  10967. int mode;
  10968.  
  10969. if( !strcmpi(message,"on") )
  10970. mode = 1;
  10971. else if( !strcmpi(message,"off") )
  10972. mode = 0;
  10973. else
  10974. {
  10975. clif_displaymessage(fd,"Usage @mobtele / @pctele <on/off>");
  10976. return -1;
  10977. }
  10978.  
  10979. if( !strcmpi(command+1,"mobtele") )
  10980. map[sd->bl.m].flag.monster_noteleport = mode;
  10981. else if( !strcmpi(command+1,"pctele") )
  10982. map[sd->bl.m].flag.noteleport = mode;
  10983.  
  10984. sprintf(atcmd_output,"Setting : pc %d | monster %d", map[sd->bl.m].flag.noteleport, map[sd->bl.m].flag.monster_noteleport);
  10985. clif_displaymessage(fd,atcmd_output);
  10986. return 0;
  10987. }
  10988.  
  10989. /*==========================================
  10990. * Achievements
  10991. *------------------------------------------*/
  10992. ACMD_FUNC(achievements)
  10993. {
  10994. int i, j;
  10995. struct achievement_data *ad;
  10996. struct s_achievement *sad;
  10997. int x, y;
  10998. char rate[32];
  10999.  
  11000. if( sd->achievement_count <= 0 )
  11001. {
  11002. clif_displaymessage(fd,"You have no progress on any Achievement.");
  11003. return 0;
  11004. }
  11005.  
  11006. for( i = 0; i < sd->achievement_count; i++ )
  11007. {
  11008. sad = &sd->achievement[i];
  11009. if( !sad->id || (ad = achievement_search(sad->id)) == NULL )
  11010. continue;
  11011.  
  11012. if( sad->completed )
  11013. safestrncpy(rate,"100.00%",sizeof(rate));
  11014. else
  11015. {
  11016. x = 0;
  11017. y = 0;
  11018.  
  11019. for( j = 0; j < ad->objectives; j++ )
  11020. {
  11021. x += ad->ao[j].count;
  11022. y += sad->count[j];
  11023. }
  11024. if( x <= 0 )
  11025. safestrncpy(rate,"0.00%",sizeof(rate));
  11026. else
  11027. sprintf(rate,"%02.02f%%", (float)y * 100. / (float)x);
  11028. }
  11029.  
  11030. sprintf(atcmd_output,"[%d] %s. %s Completed.", ad->id, ad->name, rate);
  11031. clif_displaymessage(fd,atcmd_output);
  11032. }
  11033.  
  11034. return 0;
  11035. }
  11036.  
  11037. ACMD_FUNC(achieve)
  11038. {
  11039. int i, id = atoi(message);
  11040. struct achievement_data *ad;
  11041.  
  11042. if( id <= 0 || (ad = achievement_search(id)) == NULL || (i = achievement_index(sd,id)) < 0 )
  11043. {
  11044. clif_displaymessage(fd,"Achievement ID not found.");
  11045. return -1;
  11046. }
  11047.  
  11048. if( sd->achievement[i].completed )
  11049. {
  11050. clif_displaymessage(fd,"Achievement already completed.");
  11051. return -1;
  11052. }
  11053.  
  11054. achievement_complete(sd,ad);
  11055. return 0;
  11056. }
  11057.  
  11058. ACMD_FUNC(unachieve)
  11059. {
  11060. int i, id = atoi(message);
  11061. struct achievement_data *ad;
  11062.  
  11063. if( id <= 0 || (ad = achievement_search(id)) == NULL )
  11064. {
  11065. clif_displaymessage(fd,"Achievement ID not found.");
  11066. return -1;
  11067. }
  11068.  
  11069. ARR_FIND(0,sd->achievement_count,i,sd->achievement[i].id == id);
  11070. if( i < sd->achievement_count )
  11071. {
  11072. if( sd->achievement_count-- < ACHIEVEMENT_MAX && sd->achievement[i+1].id )
  11073. memmove(&sd->achievement[i], &sd->achievement[i+1], sizeof(struct s_achievement)*(sd->achievement_count-i));
  11074.  
  11075. memset(&sd->achievement[sd->achievement_count],0,sizeof(struct s_achievement));
  11076. sd->save_achievement = true;
  11077. clif_displaymessage(fd,"Achievement removed at all from this Character.");
  11078. }
  11079. else
  11080. clif_displaymessage(fd,"Achievement not available for this Character.");
  11081.  
  11082. return 0;
  11083. }
  11084.  
  11085. ACMD_FUNC(reloadachievements)
  11086. {
  11087. achievement_db_load(true);
  11088. clif_displaymessage(fd,"Achievement Database loaded.");
  11089. return 0;
  11090. }
  11091.  
  11092. /*==========================================
  11093. * Faction System
  11094. *------------------------------------------*/
  11095. ACMD_FUNC(faction)
  11096. {
  11097. int id = atoi(message);
  11098. struct faction_data* faction;
  11099.  
  11100. if( id <= 0 || (faction = faction_search(id)) == NULL )
  11101. {
  11102. clif_displaymessage(fd,"Faction not found. Use @faction <Faction ID>");
  11103. return -1;
  11104. }
  11105.  
  11106. sd->status.faction_id = id;
  11107. snprintf(atcmd_output,sizeof(atcmd_output),"- You have joined the faction [ %s ] -",faction->name);
  11108. clif_broadcast2(&sd->bl,atcmd_output,strlen(atcmd_output) + 1,0xFFA500,0x190,20,0,0,SELF);
  11109. status_calc_pc(sd,0);
  11110. sd->lang_id = faction->lang_id;
  11111.  
  11112. return 0;
  11113. }
  11114.  
  11115. ACMD_FUNC(language)
  11116. {
  11117. int id = atoi(message);
  11118. struct lang_data* ld;
  11119.  
  11120. if( !strcmpi(message,"off") )
  11121. {
  11122. struct faction_data* faction = faction_search(sd->status.faction_id);
  11123. if( !faction || faction->lang_id == 0 )
  11124. {
  11125. sd->lang_id = 0;
  11126. clif_displaymessage(fd,"Now you will speak normally to everybody.");
  11127. }
  11128. else
  11129. {
  11130. if( faction->lang_id && (ld = lang_search(faction->lang_id)) != NULL )
  11131. {
  11132. sd->lang_id = faction->lang_id;
  11133. snprintf(atcmd_output,sizeof(atcmd_output),"Now you will speak and understand '%s' language.",ld->name);
  11134. clif_displaymessage(fd,atcmd_output);
  11135. }
  11136. else
  11137. {
  11138. sd->lang_id = 0;
  11139. clif_displaymessage(fd,"Now you will speak normally to everybody.");
  11140. }
  11141. }
  11142. return 0;
  11143. }
  11144.  
  11145. if( id <= 0 || (ld = lang_search(id)) == NULL || !ld->max_len )
  11146. {
  11147. clif_displaymessage(fd,"Invalid or Disabled Language. Use @language <Lang ID>");
  11148. return -1;
  11149. }
  11150.  
  11151. if( battle_config.lowest_gm_level > pc_isGM(sd) && !(sd->lang_mastery&lang_pow[id-1]) )
  11152. {
  11153. sprintf(atcmd_output,"You don't know '%s'. Learn it with @learnlang %d",ld->name,id);
  11154. clif_displaymessage(fd,atcmd_output);
  11155. return -1;
  11156. }
  11157.  
  11158. sd->lang_id = id;
  11159. snprintf(atcmd_output,sizeof(atcmd_output),"Now you will speak and understand '%s'.",ld->name);
  11160. clif_displaymessage(fd,atcmd_output);
  11161. return 0;
  11162. }
  11163.  
  11164. ACMD_FUNC(learnlang)
  11165. {
  11166. int id = atoi(message);
  11167. struct lang_data* ld;
  11168.  
  11169. if( id <= 0 || (ld = lang_search(id)) == NULL )
  11170. {
  11171. clif_displaymessage(fd,"Invalid Language. Use @learnlang <Lang ID>");
  11172. return -1;
  11173. }
  11174.  
  11175. if( sd->lang_mastery&lang_pow[id-1] )
  11176. {
  11177. sprintf(atcmd_output,"You already know '%s'. Unlearn it with @unlearnlang %d",ld->name,id);
  11178. clif_displaymessage(fd,atcmd_output);
  11179. return -1;
  11180. }
  11181.  
  11182. sd->lang_mastery |= lang_pow[id-1];
  11183. pc_setglobalreg(sd,"eAmod_Languages",sd->lang_mastery);
  11184. snprintf(atcmd_output,sizeof(atcmd_output),"You learn how to speak '%s'. Use @language %d to use it.",ld->name,id);
  11185. clif_displaymessage(fd,atcmd_output);
  11186. return 0;
  11187. }
  11188.  
  11189. ACMD_FUNC(unlearnlang)
  11190. {
  11191. int id = atoi(message);
  11192. struct lang_data* ld;
  11193.  
  11194. if( id <= 0 || (ld = lang_search(id)) == NULL )
  11195. {
  11196. clif_displaymessage(fd,"Invalid Language. Use @unlearnlang <Lang ID>");
  11197. return -1;
  11198. }
  11199.  
  11200. if( sd->lang_mastery&lang_pow[id-1] )
  11201. {
  11202. sd->lang_mastery &= ~lang_pow[id-1];
  11203. snprintf(atcmd_output,sizeof(atcmd_output),"Now you don't know to speak '%s'.",ld->name);
  11204. clif_displaymessage(fd,atcmd_output);
  11205. return 0;
  11206. }
  11207.  
  11208. sprintf(atcmd_output,"You don't know '%s'. Learn it with @learnlang %d",ld->name,id);
  11209. clif_displaymessage(fd,atcmd_output);
  11210. return -1;
  11211. }
  11212.  
  11213. ACMD_FUNC(say)
  11214. {
  11215. if( !message || !*message || strlen(message) < 1 )
  11216. {
  11217. clif_displaymessage(fd,"Invalid Message. Use @say <Message>");
  11218. return -1;
  11219. }
  11220.  
  11221. memset(atcmd_output,0,sizeof(atcmd_output));
  11222. lang_convert(atcmd_output,message,sizeof(atcmd_output),sd->lang_id);
  11223. clif_displaymessage(fd,atcmd_output);
  11224. return 0;
  11225. }
  11226.  
  11227. /*==========================================
  11228. * atcommand_info[] structure definition
  11229. *------------------------------------------*/
  11230.  
  11231. AtCommandInfo atcommand_info[] = {
  11232. { "rura", 40,40, 0, atcommand_mapmove },
  11233. { "warp", 40,40, 0, atcommand_mapmove },
  11234. { "mapmove", 40,40, 0, atcommand_mapmove }, // + /mm
  11235. { "where", 1,1, 0, atcommand_where },
  11236. { "jumpto", 20,20, 0, atcommand_jumpto }, // + /shift
  11237. { "warpto", 20,20, 0, atcommand_jumpto },
  11238. { "goto", 20,20, 0, atcommand_jumpto },
  11239. { "jump", 40,40, 0, atcommand_jump },
  11240. { "who", 20,20, 0, atcommand_who },
  11241. { "whois", 20,20, 0, atcommand_who },
  11242. { "who2", 20,20, 0, atcommand_who2 },
  11243. { "who3", 20,20, 0, atcommand_who3 },
  11244. { "whomap", 20,20, 0, atcommand_whomap },
  11245. { "whomap2", 20,20, 0, atcommand_whomap2 },
  11246. { "whomap3", 20,20, 0, atcommand_whomap3 },
  11247. { "whogm", 20,20, 0, atcommand_whogm },
  11248. { "save", 40,40, 0, atcommand_save },
  11249. { "return", 40,40, 0, atcommand_load },
  11250. { "load", 40,40, 0, atcommand_load },
  11251. { "speed", 40,40, 0, atcommand_speed },
  11252. { "storage", 1,1, 0, atcommand_storage },
  11253. { "gstorage", 50,50, 0, atcommand_guildstorage },
  11254. { "option", 40,40, 0, atcommand_option },
  11255. { "hide", 40,40, 0, atcommand_hide }, // + /hide
  11256. { "jobchange", 40,40, 0, atcommand_jobchange },
  11257. { "job", 40,40, 0, atcommand_jobchange },
  11258. { "die", 1,1, 0, atcommand_die },
  11259. { "kill", 60,60, 0, atcommand_kill },
  11260. { "alive", 60,60, 0, atcommand_alive },
  11261. { "kami", 40,40, 0, atcommand_kami },
  11262. { "kamib", 40,40, 0, atcommand_kami },
  11263. { "kamic", 40,40, 0, atcommand_kami },
  11264. { "heal", 40,60, 0, atcommand_heal },
  11265. { "item", 60,60, 0, atcommand_item },
  11266. { "costumeitem", 60,60, 0, atcommand_item },
  11267. { "bounditem", 60,60, 0, atcommand_item },
  11268. { "item2", 60,60, 0, atcommand_item2 },
  11269. { "bounditem2", 60,60, 0, atcommand_item2 },
  11270. { "itemreset", 40,40, 0, atcommand_itemreset },
  11271. { "blvl", 60,60, 0, atcommand_baselevelup },
  11272. { "lvup", 60,60, 0, atcommand_baselevelup },
  11273. { "blevel", 60,60, 0, atcommand_baselevelup },
  11274. { "baselvl", 60,60, 0, atcommand_baselevelup },
  11275. { "baselvup", 60,60, 0, atcommand_baselevelup },
  11276. { "baselevel", 60,60, 0, atcommand_baselevelup },
  11277. { "baselvlup", 60,60, 0, atcommand_baselevelup },
  11278. { "jlvl", 60,60, 0, atcommand_joblevelup },
  11279. { "jlevel", 60,60, 0, atcommand_joblevelup },
  11280. { "joblvl", 60,60, 0, atcommand_joblevelup },
  11281. { "joblevel", 60,60, 0, atcommand_joblevelup },
  11282. { "joblvup", 60,60, 0, atcommand_joblevelup },
  11283. { "joblvlup", 60,60, 0, atcommand_joblevelup },
  11284. { "h", 20,20, 0, atcommand_help },
  11285. { "help", 20,20, 0, atcommand_help },
  11286. { "h2", 20,20, 0, atcommand_help2 },
  11287. { "help2", 20,20, 0, atcommand_help2 },
  11288. { "pvpoff", 40,40, 0, atcommand_pvpoff },
  11289. { "pvpon", 40,40, 0, atcommand_pvpon },
  11290. { "gvgoff", 40,40, 0, atcommand_gvgoff },
  11291. { "gpvpoff", 40,40, 0, atcommand_gvgoff },
  11292. { "gvgon", 40,40, 0, atcommand_gvgon },
  11293. { "gpvpon", 40,40, 0, atcommand_gvgon },
  11294. { "model", 20,20, 0, atcommand_model },
  11295. { "go", 10,10, 0, atcommand_go },
  11296. { "monster", 50,50, 0, atcommand_monster },
  11297. { "spawn", 50,50, 0, atcommand_monster },
  11298. { "monstersmall", 50,50, 0, atcommand_monstersmall },
  11299. { "monsterbig", 50,50, 0, atcommand_monsterbig },
  11300. { "killmonster", 60,60, 0, atcommand_killmonster },
  11301. { "killmonster2", 40,40, 0, atcommand_killmonster2 },
  11302. { "refine", 60,60, 0, atcommand_refine },
  11303. { "produce", 60,60, 0, atcommand_produce },
  11304. { "memo", 40,40, 0, atcommand_memo },
  11305. { "gat", 99,99, 0, atcommand_gat },
  11306. { "displaystatus", 99,99, 0, atcommand_displaystatus },
  11307. { "stpoint", 60,60, 0, atcommand_statuspoint },
  11308. { "skpoint", 60,60, 0, atcommand_skillpoint },
  11309. { "zeny", 60,60, 0, atcommand_zeny },
  11310. { "str", 60,60, 0, atcommand_param },
  11311. { "agi", 60,60, 0, atcommand_param },
  11312. { "vit", 60,60, 0, atcommand_param },
  11313. { "int", 60,60, 0, atcommand_param },
  11314. { "dex", 60,60, 0, atcommand_param },
  11315. { "luk", 60,60, 0, atcommand_param },
  11316. { "glvl", 60,60, 0, atcommand_guildlevelup },
  11317. { "glevel", 60,60, 0, atcommand_guildlevelup },
  11318. { "guildlvl", 60,60, 0, atcommand_guildlevelup },
  11319. { "guildlvup", 60,60, 0, atcommand_guildlevelup },
  11320. { "guildlevel", 60,60, 0, atcommand_guildlevelup },
  11321. { "guildlvlup", 60,60, 0, atcommand_guildlevelup },
  11322. { "makeegg", 60,60, 0, atcommand_makeegg },
  11323. { "hatch", 60,60, 0, atcommand_hatch },
  11324. { "petfriendly", 40,40, 0, atcommand_petfriendly },
  11325. { "pethungry", 40,40, 0, atcommand_pethungry },
  11326. { "petrename", 1,1, 0, atcommand_petrename },
  11327. { "recall", 60,60, 0, atcommand_recall }, // + /recall
  11328. { "night", 80,80, 0, atcommand_night },
  11329. { "day", 80,80, 0, atcommand_day },
  11330. { "doom", 80,80, 0, atcommand_doom },
  11331. { "doommap", 80,80, 0, atcommand_doommap },
  11332. { "raise", 80,80, 0, atcommand_raise },
  11333. { "raisemap", 80,80, 0, atcommand_raisemap },
  11334. { "kick", 20,20, 0, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  11335. { "kickall", 99,99, 0, atcommand_kickall },
  11336. { "allskill", 60,60, 0, atcommand_allskill },
  11337. { "allskills", 60,60, 0, atcommand_allskill },
  11338. { "skillall", 60,60, 0, atcommand_allskill },
  11339. { "skillsall", 60,60, 0, atcommand_allskill },
  11340. { "questskill", 40,40, 0, atcommand_questskill },
  11341. { "lostskill", 40,40, 0, atcommand_lostskill },
  11342. { "spiritball", 40,40, 0, atcommand_spiritball },
  11343. { "party", 1,1, 0, atcommand_party },
  11344. { "guild", 50,50, 0, atcommand_guild },
  11345. { "agitstart", 60,60, 0, atcommand_agitstart },
  11346. { "agitend", 60,60, 0, atcommand_agitend },
  11347. { "mapexit", 99,99, 0, atcommand_mapexit },
  11348. { "idsearch", 60,60, 0, atcommand_idsearch },
  11349. { "broadcast", 40,40, 0, atcommand_broadcast }, // + /b and /nb
  11350. { "localbroadcast", 40,40, 0, atcommand_localbroadcast }, // + /lb and /nlb
  11351. { "recallall", 80,80, 0, atcommand_recallall },
  11352. { "reloaditemdb", 99,99, 0, atcommand_reloaditemdb },
  11353. { "reloadmobdb", 99,99, 0, atcommand_reloadmobdb },
  11354. { "reloadskilldb", 99,99, 0, atcommand_reloadskilldb },
  11355. { "reloadscript", 99,99, 0, atcommand_reloadscript },
  11356. { "reloadatcommand", 99,99, 0, atcommand_reloadatcommand },
  11357. { "reloadbattleconf", 99,99, 0, atcommand_reloadbattleconf },
  11358. { "reloadstatusdb", 99,99, 0, atcommand_reloadstatusdb },
  11359. { "reloadpcdb", 99,99, 0, atcommand_reloadpcdb },
  11360. { "reloadmotd", 99,99, 0, atcommand_reloadmotd },
  11361. { "mapinfo", 99,99, 0, atcommand_mapinfo },
  11362. { "dye", 40,40, 0, atcommand_dye },
  11363. { "ccolor", 40,40, 0, atcommand_dye },
  11364. { "hairstyle", 40,40, 0, atcommand_hair_style },
  11365. { "hstyle", 40,40, 0, atcommand_hair_style },
  11366. { "haircolor", 40,40, 0, atcommand_hair_color },
  11367. { "hcolor", 40,40, 0, atcommand_hair_color },
  11368. { "statall", 60,60, 0, atcommand_stat_all },
  11369. { "statsall", 60,60, 0, atcommand_stat_all },
  11370. { "allstats", 60,60, 0, atcommand_stat_all },
  11371. { "allstat", 60,60, 0, atcommand_stat_all },
  11372. { "block", 60,60, 0, atcommand_char_block },
  11373. { "charblock", 60,60, 0, atcommand_char_block },
  11374. { "ban", 60,60, 0, atcommand_char_ban },
  11375. { "banish", 60,60, 0, atcommand_char_ban },
  11376. { "charban", 60,60, 0, atcommand_char_ban },
  11377. { "charbanish", 60,60, 0, atcommand_char_ban },
  11378. { "unblock", 60,60, 0, atcommand_char_unblock },
  11379. { "charunblock", 60,60, 0, atcommand_char_unblock },
  11380. { "unban", 60,60, 0, atcommand_char_unban },
  11381. { "unbanish", 60,60, 0, atcommand_char_unban },
  11382. { "charunban", 60,60, 0, atcommand_char_unban },
  11383. { "charunbanish", 60,60, 0, atcommand_char_unban },
  11384. { "mount", 20,20, 0, atcommand_mount_peco },
  11385. { "mountpeco", 20,20, 0, atcommand_mount_peco },
  11386. { "guildspy", 60,60, 0, atcommand_guildspy },
  11387. { "partyspy", 60,60, 0, atcommand_partyspy },
  11388. { "repairall", 60,60, 0, atcommand_repairall },
  11389. { "guildrecall", 60,60, 0, atcommand_guildrecall },
  11390. { "partyrecall", 60,60, 0, atcommand_partyrecall },
  11391. { "nuke", 60,60, 0, atcommand_nuke },
  11392. { "shownpc", 80,80, 0, atcommand_shownpc },
  11393. { "hidenpc", 80,80, 0, atcommand_hidenpc },
  11394. { "loadnpc", 80,80, 0, atcommand_loadnpc },
  11395. { "unloadnpc", 80,80, 0, atcommand_unloadnpc },
  11396. { "time", 1,1, 0, atcommand_servertime },
  11397. { "date", 1,1, 0, atcommand_servertime },
  11398. { "serverdate", 1,1, 0, atcommand_servertime },
  11399. { "servertime", 1,1, 0, atcommand_servertime },
  11400. { "jail", 60,60, 0, atcommand_jail },
  11401. { "unjail", 60,60, 0, atcommand_unjail },
  11402. { "discharge", 60,60, 0, atcommand_unjail },
  11403. { "jailfor", 60,60, 0, atcommand_jailfor },
  11404. { "jailtime", 1,1, 0, atcommand_jailtime },
  11405. { "disguise", 20,20, 0, atcommand_disguise },
  11406. { "undisguise", 20,20, 0, atcommand_undisguise },
  11407. { "email", 1,1, 0, atcommand_email },
  11408. { "effect", 40,40, 0, atcommand_effect },
  11409. { "follow", 20,20, 0, atcommand_follow },
  11410. { "addwarp", 60,60, 0, atcommand_addwarp },
  11411. { "skillon", 80,80, 0, atcommand_skillon },
  11412. { "skilloff", 80,80, 0, atcommand_skilloff },
  11413. { "killer", 60,60, 0, atcommand_killer },
  11414. { "npcmove", 80,80, 0, atcommand_npcmove },
  11415. { "killable", 40,40, 0, atcommand_killable },
  11416. { "dropall", 40,40, 0, atcommand_dropall },
  11417. { "storeall", 40,40, 0, atcommand_storeall },
  11418. { "skillid", 40,40, 0, atcommand_skillid },
  11419. { "blockskill", 40,40, 0, atcommand_blockskill },
  11420. { "useskill", 40,40, 0, atcommand_useskill },
  11421. { "displayskill", 99,99, 0, atcommand_displayskill },
  11422. { "snow", 99,99, 0, atcommand_snow },
  11423. { "sakura", 99,99, 0, atcommand_sakura },
  11424. { "clouds", 99,99, 0, atcommand_clouds },
  11425. { "clouds2", 99,99, 0, atcommand_clouds2 },
  11426. { "fog", 99,99, 0, atcommand_fog },
  11427. { "fireworks", 99,99, 0, atcommand_fireworks },
  11428. { "leaves", 99,99, 0, atcommand_leaves },
  11429. { "summon", 60,60, 0, atcommand_summon },
  11430. { "adjgmlvl", 99,99, 0, atcommand_adjgmlvl },
  11431. { "adjcmdlvl", 99,99, 0, atcommand_adjcmdlvl },
  11432. { "trade", 60,60, 0, atcommand_trade },
  11433. { "send", 99,99, 0, atcommand_send },
  11434. { "setbattleflag", 99,99, 0, atcommand_setbattleflag },
  11435. { "unmute", 80,80, 0, atcommand_unmute },
  11436. { "clearweather", 99,99, 0, atcommand_clearweather },
  11437. { "uptime", 1,1, 0, atcommand_uptime },
  11438. { "changesex", 60,60, 0, atcommand_changesex },
  11439. { "mute", 80,80, 0, atcommand_mute },
  11440. { "refresh", 1,1, 0, atcommand_refresh },
  11441. { "autorefresh", 1,1, 0, atcommand_autorefresh },
  11442. { "identify", 40,40, 0, atcommand_identify },
  11443. { "gmotd", 20,20, 0, atcommand_gmotd },
  11444. { "misceffect", 50,50, 0, atcommand_misceffect },
  11445. { "mobsearch", 10,10, 0, atcommand_mobsearch },
  11446. { "cleanmap", 40,40, 0, atcommand_cleanmap },
  11447. { "npctalk", 20,20, 0, atcommand_npctalk },
  11448. { "npctalkc", 20,20, 0, atcommand_npctalk },
  11449. { "pettalk", 10,10, 0, atcommand_pettalk },
  11450. { "users", 40,40, 0, atcommand_users },
  11451. { "reset", 40,40, 0, atcommand_reset },
  11452. { "skilltree", 40,40, 0, atcommand_skilltree },
  11453. { "marry", 40,40, 0, atcommand_marry },
  11454. { "divorce", 40,40, 0, atcommand_divorce },
  11455. { "sound", 40,40, 0, atcommand_sound },
  11456. { "undisguiseall", 99,99, 0, atcommand_undisguiseall },
  11457. { "disguiseall", 99,99, 0, atcommand_disguiseall },
  11458. { "changelook", 60,60, 0, atcommand_changelook },
  11459. { "autoloot", 10,10, 0, atcommand_autoloot },
  11460. { "aloot", 10,10, 0, atcommand_autoloot },
  11461. { "mobinfo", 1,1, 0, atcommand_mobinfo },
  11462. { "monsterinfo", 1,1, 0, atcommand_mobinfo },
  11463. { "mi", 1,1, 0, atcommand_mobinfo },
  11464. { "exp", 1,1, 0, atcommand_exp },
  11465. { "adopt", 40,40, 0, atcommand_adopt },
  11466. { "version", 1,1, 0, atcommand_version },
  11467. { "mutearea", 99,99, 0, atcommand_mutearea },
  11468. { "stfu", 99,99, 0, atcommand_mutearea },
  11469. { "rates", 1,1, 0, atcommand_rates },
  11470. { "iteminfo", 1,1, 0, atcommand_iteminfo },
  11471. { "ii", 1,1, 0, atcommand_iteminfo },
  11472. { "whodrops", 1,1, 0, atcommand_whodrops },
  11473. { "whereis", 10,10, 0, atcommand_whereis },
  11474. { "mapflag", 99,99, 0, atcommand_mapflag },
  11475. { "me", 20,20, 0, atcommand_me },
  11476. { "monsterignore", 99,99, 0, atcommand_monsterignore },
  11477. { "battleignore", 99,99, 0, atcommand_monsterignore },
  11478. { "fakename", 20,20, 0, atcommand_fakename },
  11479. { "size", 20,20, 0, atcommand_size },
  11480. { "sizeall", 20,20, 0, atcommand_sizeall },
  11481. { "showexp", 10,10, 0, atcommand_showexp},
  11482. { "showzeny", 10,10, 0, atcommand_showzeny},
  11483. { "showdelay", 1,1, 0, atcommand_showdelay},
  11484. { "autotrade", 10,10, 0, atcommand_autotrade },
  11485. { "at", 10,10, 0, atcommand_autotrade },
  11486. { "changegm", 10,10, 0, atcommand_changegm },
  11487. { "changeleader", 10,10, 0, atcommand_changeleader },
  11488. { "partyoption", 10,10, 0, atcommand_partyoption},
  11489. { "invite", 1,1, 0, atcommand_invite },
  11490. { "duel", 1,1, 0, atcommand_duel },
  11491. { "leave", 1,1, 0, atcommand_leave },
  11492. { "accept", 1,1, 0, atcommand_accept },
  11493. { "reject", 1,1, 0, atcommand_reject },
  11494. { "away", 1,1, 0, atcommand_away },
  11495. { "aw", 1,1, 0, atcommand_away },
  11496. { "clone", 50,50, 0, atcommand_clone },
  11497. { "slaveclone", 50,50, 0, atcommand_clone },
  11498. { "evilclone", 50,50, 0, atcommand_clone },
  11499. { "tonpc", 40,40, 0, atcommand_tonpc },
  11500. { "commands", 1,1, 0, atcommand_commands },
  11501. { "noask", 1,1, 0, atcommand_noask },
  11502. { "request", 20,20, 0, atcommand_request },
  11503. { "hlvl", 60,60, 0, atcommand_homlevel },
  11504. { "hlevel", 60,60, 0, atcommand_homlevel },
  11505. { "homlvl", 60,60, 0, atcommand_homlevel },
  11506. { "homlvup", 60,60, 0, atcommand_homlevel },
  11507. { "homlevel", 60,60, 0, atcommand_homlevel },
  11508. { "homevolve", 60,60, 0, atcommand_homevolution },
  11509. { "homevolution", 60,60, 0, atcommand_homevolution },
  11510. { "makehomun", 60,60, 0, atcommand_makehomun },
  11511. { "homfriendly", 60,60, 0, atcommand_homfriendly },
  11512. { "homhungry", 60,60, 0, atcommand_homhungry },
  11513. { "homtalk", 10,10, 0, atcommand_homtalk },
  11514. { "hominfo", 1,1, 0, atcommand_hominfo },
  11515. { "homstats", 1,1, 0, atcommand_homstats },
  11516. { "homshuffle", 60,60, 0, atcommand_homshuffle },
  11517. { "showmobs", 10,10, 0, atcommand_showmobs },
  11518. { "feelreset", 10,10, 0, atcommand_feelreset },
  11519. { "auction", 60,60, 0, atcommand_auction },
  11520. { "mail", 1,1, 0, atcommand_mail },
  11521. { "noks", 1,1, 0, atcommand_ksprotection },
  11522. { "allowks", 6,6, 0, atcommand_allowks },
  11523. { "cash", 60,60, 0, atcommand_cash },
  11524. { "gcash", 1,1, 0, atcommand_gcash },
  11525. { "points", 60,60, 0, atcommand_cash },
  11526. { "gpoints", 1,1, 0, atcommand_gpoints },
  11527. { "skreset", 60,60, 0, atcommand_resetskill },
  11528. { "streset", 60,60, 0, atcommand_resetstat },
  11529. { "storagelist", 40,40, 0, atcommand_itemlist },
  11530. { "cartlist", 40,40, 0, atcommand_itemlist },
  11531. { "itemlist", 40,40, 0, atcommand_itemlist },
  11532. { "stats", 40,40, 0, atcommand_stats },
  11533. { "myinfo", 0,40, 0, atcommand_myinfo },
  11534. { "delitem", 60,60, 0, atcommand_delitem },
  11535. { "charcommands", 1,1, 0, atcommand_commands },
  11536. { "disguiseguild", 99,99, 0, atcommand_disguiseguild },
  11537. { "ddrop", 0,1, 0, atcommand_displaydrop },
  11538. { "dexp", 10,10, 0, atcommand_showexp},
  11539. { "showcast", 1,1, 0, atcommand_showcast},
  11540. { "showcastdelay", 1,1, 0, atcommand_showcastdelay},
  11541. { "invitar", 1,1, 0, atcommand_invite },
  11542. { "duelo", 1,1, 0, atcommand_duel },
  11543. { "dejar", 1,1, 0, atcommand_leave },
  11544. { "aceptar", 1,1, 0, atcommand_accept },
  11545. { "declinar", 1,1, 0, atcommand_reject },
  11546. { "away", 1,1, 0, atcommand_away },
  11547. { "afk", 1,1, 0, atcommand_away },
  11548. { "create", 1,1, 0, atcommand_create },
  11549. { "join", 1,1, 0, atcommand_join },
  11550. { "exit", 1,1, 0, atcommand_exit },
  11551. { "list", 1,1, 0, atcommand_list },
  11552. #ifndef TXT_ONLY
  11553. { "charlist", 4,4, 0, atcommand_charlist },
  11554. { "accountinfo", 4,4, 0, atcommand_accountinfo },
  11555. { "memberinfo", 4,4, 0, atcommand_memberinfo },
  11556. { "logininfo", 4,4, 0, atcommand_logininfo },
  11557. { "ipinfo", 1,4, 0, atcommand_ipinfo },
  11558. { "whoip", 1,1, 0, atcommand_whoip },
  11559. { "moveaccount", 99,99, 0, atcommand_moveaccount },
  11560. #endif
  11561. { "power", 99,99, 0, atcommand_maspowerr },
  11562. { "mobdemolition", 99,99, 0, atcommand_mobdemolition },
  11563. { "mobevent", 4,4, 0, atcommand_mobevent },
  11564. { "exppenalty", 40,40, 0, atcommand_exppenalty },
  11565. { "undeadmode", 40,40, 0, atcommand_residente },
  11566. { "mapdeadcounter", 40,40, 0, atcommand_contadormuertes },
  11567. { "whosell", 1,1, 0, atcommand_whosell },
  11568. { "cityheart", 40,40, 0, atcommand_cityheart },
  11569. { "pvpmode", 1,1, 0, atcommand_pvpmode },
  11570. { "whopk", 1,1, 0, atcommand_whopk },
  11571. { "rentstorage", 1,1, 0, atcommand_rentstorage },
  11572. { "aura", 1,1, 0, atcommand_aura },
  11573. { "flooritem", 60,60, 0, atcommand_flooritem },
  11574. { "expinfo", 1,1, 0, atcommand_expinfo },
  11575. { "mission", 1,1, 0, atcommand_mission },
  11576. { "char2dump", 60,60, 0, atcommand_char2dump },
  11577. { "security", 1,1, 0, atcommand_security },
  11578. { "font", 1,1, 1, atcommand_font },
  11579. { "packetfilter", 0,1, 0, atcommand_packetfilter },
  11580. { "guildskill", 0,60, 0, atcommand_guildskill },
  11581. { "rankreset", 60,60, 0, atcommand_rankreset },
  11582. { "itemdestroy", 99,99, 0, atcommand_item_remove4all },
  11583. { "viewmobinfo", 60,60, 0, atcommand_viewmobinfo },
  11584. { "order", 0,60, 0, atcommand_order },
  11585. { "leader", 0,60, 0, atcommand_leader },
  11586. { "reportafk", 0,60, 0, atcommand_reportafk },
  11587. { "listenbg", 0,60, 0, atcommand_listenbg },
  11588. { "bgranked", 0,60, 0, atcommand_bgranked },
  11589. { "bgregular", 0,60, 0, atcommand_bgregular },
  11590. { "battleinfo", 0,60, 0, atcommand_battleinfo },
  11591. { "addfame", 99,99, 0, atcommand_addfame },
  11592. { "unboundall", 60,60, 0, atcommand_unboundall },
  11593. { "mobtele", 60,60, 0, atcommand_teleport },
  11594. { "pctele", 60,60, 0, atcommand_teleport },
  11595. { "achievements", 60,60, 0, atcommand_achievements },
  11596. { "achieve", 60,60, 0, atcommand_achieve },
  11597. { "unachieve", 60,60, 0, atcommand_unachieve },
  11598. { "reloadachievedb", 60,60, 0, atcommand_reloadachievements },
  11599. { "faction", 60,60, 0, atcommand_faction },
  11600. { "language", 60,60, 0, atcommand_language },
  11601. { "learnlang", 60,60, 0, atcommand_learnlang },
  11602. { "unlearnlang", 60,60, 0, atcommand_unlearnlang },
  11603. { "say", 60,60, 0, atcommand_say },
  11604. };
  11605.  
  11606.  
  11607. /*==========================================
  11608. * Command lookup functions
  11609. *------------------------------------------*/
  11610. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  11611. {
  11612. int i;
  11613. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  11614. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  11615. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  11616. }
  11617.  
  11618. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  11619. {
  11620. int i;
  11621. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  11622. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  11623. }
  11624.  
  11625.  
  11626. /*==========================================
  11627. * Retrieve the command's required gm level
  11628. *------------------------------------------*/
  11629. int get_atcommand_level(const AtCommandFunc func)
  11630. {
  11631. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  11632. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  11633. }
  11634.  
  11635. struct Atcmd_Binding* get_atcommandbind_byname(const char* name)
  11636. {
  11637. int i;
  11638. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  11639. ARR_FIND( 0, ARRAYLENGTH(atcmd_binding), i, strcmp(atcmd_binding[i].command, name) == 0 );
  11640. return ( i < ARRAYLENGTH(atcmd_binding) ) ? &atcmd_binding[i] : NULL;
  11641. }
  11642.  
  11643. /// Executes an at-command.
  11644. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  11645. {
  11646. char charname[NAME_LENGTH], params[100];
  11647. char charname2[NAME_LENGTH], params2[100];
  11648. char command[100];
  11649. char output[CHAT_SIZE_MAX];
  11650. int x, y, z;
  11651. int lv = 0;
  11652.  
  11653. //Reconstructed message
  11654. char atcmd_msg[CHAT_SIZE_MAX];
  11655.  
  11656. TBL_PC * ssd = NULL; //sd for target
  11657. AtCommandInfo * info;
  11658.  
  11659. nullpo_retr(false, sd);
  11660.  
  11661. //Shouldn't happen
  11662. if( !message || !*message )
  11663. return false;
  11664.  
  11665. //Block NOCHAT but do not display it as a normal message
  11666. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  11667. return true;
  11668.  
  11669. // skip 10/11-langtype's codepage indicator, if detected
  11670. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  11671. message += 3;
  11672.  
  11673. //Should display as a normal message
  11674. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  11675. return false;
  11676.  
  11677. // type value 0 = server invoked: bypass restrictions
  11678. // 1 = player invoked
  11679. if( type )
  11680. {
  11681. //Commands are disabled on maps flagged as 'nocommand'
  11682. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  11683. {
  11684. clif_displaymessage(fd, msg_txt(143));
  11685. return false;
  11686. }
  11687.  
  11688. //Displays as a normal message for Non-GMs
  11689. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  11690. return false;
  11691. }
  11692.  
  11693. while (*message == charcommand_symbol)
  11694. {
  11695. //Checks to see if #command has a name or a name + parameters.
  11696. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  11697. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  11698.  
  11699. //z always has the value of the scan that was successful
  11700. z = ( x > 1 ) ? x : y;
  11701.  
  11702. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) )
  11703. {
  11704. sprintf(output, "%s failed. Player not found.", command);
  11705. clif_displaymessage(fd, output);
  11706. return true;
  11707. }
  11708.  
  11709. //#command + name means the sufficient target was used and anything else after
  11710. //can be looked at by the actual command function since most scan to see if the
  11711. //right parameters are used.
  11712. if ( x > 2 ) {
  11713. sprintf(atcmd_msg, "%s %s", command, params);
  11714. break;
  11715. }
  11716. else if ( y > 2 ) {
  11717. sprintf(atcmd_msg, "%s %s", command, params2);
  11718. break;
  11719. }
  11720. //Regardless of what style the #command is used, if it's correct, it will always have
  11721. //this value if there is no parameter. Send it as just the #command
  11722. else if ( z == 2 ) {
  11723. sprintf(atcmd_msg, "%s", command);
  11724. break;
  11725. }
  11726.  
  11727. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  11728. clif_displaymessage(fd, output);
  11729. return true;
  11730. }
  11731.  
  11732. if (*message == atcommand_symbol) {
  11733. //atcmd_msg is constructed above differently for charcommands
  11734. //it's copied from message if not a charcommand so it can
  11735. //pass through the rest of the code compatible with both symbols
  11736. sprintf(atcmd_msg, "%s", message);
  11737. }
  11738.  
  11739. //Clearing these to be used once more.
  11740. memset(command, '\0', sizeof(command));
  11741. memset(params, '\0', sizeof(params));
  11742.  
  11743. //check to see if any params exist within this command
  11744. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  11745. params[0] = '\0';
  11746.  
  11747. //check for atcmd events
  11748. if( type == 1 )
  11749. {
  11750. Atcmd_Binding * binding = get_atcommandbind_byname(command);
  11751. if( binding != NULL && binding->npc_event[0] && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) >= binding->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) >= binding->level2)) )
  11752. { // Execute event if binded
  11753. npc_do_atcmd_event((*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params, binding->npc_event);
  11754. return true;
  11755. }
  11756. }
  11757.  
  11758. //Grab the command information and check for the proper GM level required to use it or if the command exists
  11759. info = get_atcommandinfo_byname(command);
  11760. if( info == NULL || info->func == NULL )
  11761. {
  11762. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  11763. clif_displaymessage(fd, output);
  11764. return true;
  11765. }
  11766.  
  11767. if( type )
  11768. {
  11769. if( *atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level )
  11770. {
  11771. if( info->premium && pc_isPremium(sd) )
  11772. premium_usage = true; // Obviosly, it's Premium
  11773. else
  11774. {
  11775. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  11776. clif_displaymessage(fd, output);
  11777. return true;
  11778. }
  11779. }
  11780.  
  11781. if( *atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2 )
  11782. {
  11783. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  11784. clif_displaymessage(fd, output);
  11785. return true;
  11786. }
  11787. }
  11788.  
  11789. //Attempt to use the command
  11790. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  11791. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  11792. {
  11793. sprintf(output,msg_txt(154), command); // %s failed.
  11794. clif_displaymessage(fd, output);
  11795. }
  11796. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  11797.  
  11798. if( type && !premium_usage )
  11799. {
  11800. //Log atcommands
  11801. if( *atcmd_msg == atcommand_symbol )
  11802. log_atcommand(sd, info->level, atcmd_msg);
  11803. //Log Charcommands
  11804. if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  11805. log_atcommand(sd, info->level2, message);
  11806. }
  11807.  
  11808. premium_usage = false;
  11809. return true;
  11810. }
  11811.  
  11812.  
  11813. /*==========================================
  11814. *
  11815. *------------------------------------------*/
  11816. int atcommand_config_read(const char* cfgName)
  11817. {
  11818. char line[1024], w1[1024], w2[1024], w3[1024], w4[1024];
  11819. AtCommandInfo* p;
  11820. FILE* fp;
  11821.  
  11822. if( (fp = fopen(cfgName, "r")) == NULL )
  11823. {
  11824. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  11825. return 1;
  11826. }
  11827.  
  11828. while( fgets(line, sizeof(line), fp) )
  11829. {
  11830. if( line[0] == '/' && line[1] == '/' )
  11831. continue;
  11832.  
  11833. if( sscanf(line, "%1023[^:]:%1023[^,],%1023[^,],%1023s", w1, w2, w3, w4) != 4 &&
  11834. sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3) != 3 &&
  11835. (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 && strcmpi(w1, "import") != 0) &&
  11836. strcmpi(w1, "command_symbol") != 0 &&
  11837. strcmpi(w1, "char_symbol") != 0 )
  11838. continue;
  11839.  
  11840. p = get_atcommandinfo_byname(w1);
  11841. if( p != NULL )
  11842. {
  11843. p->level = atoi(w2);
  11844. p->level = cap_value(p->level, 0, 100);
  11845.  
  11846. if( sscanf(line, "%1023[^:]:%1023[^,],%1023[^,],%1023s", w1, w2, w3, w4) == 4 )
  11847. { // command:@level,#level,premium
  11848. p->level2 = atoi(w3);
  11849. p->level2 = cap_value(p->level2, 0, 100);
  11850. p->premium = atoi(w4);
  11851. p->premium = cap_value(p->premium, 0, 1);
  11852. }
  11853. else if( sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3) == 3 )
  11854. { // command:@level,#level
  11855. p->level2 = atoi(w3);
  11856. p->level2 = cap_value(p->level2, 0, 100);
  11857. p->premium = 0;
  11858. }
  11859. else
  11860. { // command:@level,#level
  11861. ShowWarning("atcommand_conf: setting %s:%d is deprecated! Please see atcommand_athena.conf for the new setting format.\n",w1,atoi(w2));
  11862. ShowWarning("atcommand_conf: defaulting %s charcommand level to 100.\n",w1);
  11863. p->level2 = 100;
  11864. }
  11865. }
  11866. else
  11867. if( strcmpi(w1, "import") == 0 )
  11868. atcommand_config_read(w2);
  11869. else
  11870. if( strcmpi(w1, "command_symbol") == 0 &&
  11871. w2[0] > 31 && // control characters
  11872. w2[0] != '/' && // symbol of standard ragnarok GM commands
  11873. w2[0] != '%' && // symbol of party chat speaking
  11874. w2[0] != '$' && // symbol of guild chat speaking
  11875. w2[0] != '#' ) // remote symbol
  11876. atcommand_symbol = w2[0];
  11877. else
  11878. if( strcmpi(w1, "char_symbol") == 0 &&
  11879. w2[0] > 31 &&
  11880. w2[0] != '/' &&
  11881. w2[0] != '%' &&
  11882. w2[0] != '$' &&
  11883. w2[0] != '@' )
  11884. charcommand_symbol = w2[0];
  11885. else
  11886. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  11887. }
  11888. fclose(fp);
  11889.  
  11890. return 0;
  11891. }
  11892.  
  11893. void do_init_atcommand()
  11894. {
  11895. memset(atcmd_binding,0,sizeof(atcmd_binding)); // clear atcmd bindings
  11896. }
  11897.  
  11898. void do_final_atcommand()
  11899. {
  11900. }
  11901.  
  11902.  
  11903. // commands that need to go _after_ the commands table
  11904.  
  11905. /*==========================================
  11906. * @commands Lists available @ commands to you
  11907. *------------------------------------------*/
  11908. ACMD_FUNC(commands)
  11909. {
  11910. char line_buff[CHATBOX_SIZE];
  11911. int i, gm_lvl = pc_isGM(sd), count = 0;
  11912. char* cur = line_buff;
  11913.  
  11914. memset(line_buff,' ',CHATBOX_SIZE);
  11915. line_buff[CHATBOX_SIZE-1] = 0;
  11916.  
  11917. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  11918.  
  11919. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  11920. {
  11921. unsigned int slen;
  11922.  
  11923. if( gm_lvl < atcommand_info[i].level && stristr(command,"commands") )
  11924. continue;
  11925. if( gm_lvl < atcommand_info[i].level2 && stristr(command,"charcommands") )
  11926. continue;
  11927.  
  11928. slen = strlen(atcommand_info[i].command);
  11929.  
  11930. // flush the text buffer if this command won't fit into it
  11931. if( slen + cur - line_buff >= CHATBOX_SIZE )
  11932. {
  11933. clif_displaymessage(fd,line_buff);
  11934. cur = line_buff;
  11935. memset(line_buff,' ',CHATBOX_SIZE);
  11936. line_buff[CHATBOX_SIZE-1] = 0;
  11937. }
  11938.  
  11939. memcpy(cur,atcommand_info[i].command,slen);
  11940. cur += slen+(10-slen%10);
  11941.  
  11942. count++;
  11943. }
  11944. clif_displaymessage(fd,line_buff);
  11945.  
  11946. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  11947. clif_displaymessage(fd, atcmd_output);
  11948.  
  11949. return 0;
  11950. }
Add Comment
Please, Sign In to add comment