viewing paste atcommand.c | C++

Posted on the
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3.  
  4. #include "../common/cbasetypes.h"
  5. #include "../common/mmo.h"
  6. #include "../common/timer.h"
  7. #include "../common/nullpo.h"
  8. #include "../common/core.h"
  9. #include "../common/showmsg.h"
  10. #include "../common/malloc.h"
  11. #include "../common/random.h"
  12. #include "../common/socket.h"
  13. #include "../common/strlib.h"
  14. #include "../common/utils.h"
  15. #include "../common/conf.h"
  16.  
  17. #include "atcommand.h"
  18. #include "battle.h"
  19. #include "chat.h"
  20. #include "clif.h"
  21. #include "chrif.h"
  22. #include "duel.h"
  23. #include "intif.h"
  24. #include "itemdb.h"
  25. #include "log.h"
  26. #include "map.h"
  27. #include "pc.h"
  28. #include "pc_groups.h" // groupid2name
  29. #include "status.h"
  30. #include "skill.h"
  31. #include "mob.h"
  32. #include "npc.h"
  33. #include "pet.h"
  34. #include "homunculus.h"
  35. #include "mail.h"
  36. #include "mercenary.h"
  37. #include "elemental.h"
  38. #include "party.h"
  39. #include "guild.h"
  40. #include "script.h"
  41. #include "storage.h"
  42. #include "trade.h"
  43. #include "unit.h"
  44. #include "mapreg.h"
  45.  
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49. #include <math.h>
  50.  
  51.  
  52. #define ATCOMMAND_LENGTH 50
  53. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  54. #define MAX_MSG 1000
  55.  
  56.  
  57. typedef struct AtCommandInfo AtCommandInfo;
  58. typedef struct AliasInfo AliasInfo;
  59.  
  60. int atcmd_binding_count = 0;
  61.  
  62. struct AtCommandInfo {
  63. 	char command[ATCOMMAND_LENGTH]; 
  64. 	AtCommandFunc func;
  65. 	char* at_groups;/* quick @commands "can-use" lookup */
  66. 	char* char_groups;/* quick @charcommands "can-use" lookup */
  67. };
  68.  
  69. struct AliasInfo {
  70. 	AtCommandInfo *command;
  71. 	char alias[ATCOMMAND_LENGTH];
  72. };
  73.  
  74.  
  75. char atcommand_symbol = '@'; // first char of the commands
  76. char charcommand_symbol = '#';
  77.  
  78. static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  79. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  80. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  81. static config_t atcommand_config;
  82.  
  83. static char atcmd_output[CHAT_SIZE_MAX];
  84. static char atcmd_player_name[NAME_LENGTH];
  85.  
  86. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  87. static const char* atcommand_checkalias(const char *aliasname); // @help
  88. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  89.  
  90. // @commands (script-based)
  91. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  92. 	int i = 0;
  93.  
  94. 	if( *name == atcommand_symbol || *name == charcommand_symbol )
  95. 		name++; // for backwards compatibility
  96.  
  97. 	ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  98.  
  99. 	return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  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.  * Read Message Data
  116.  *------------------------------------------*/
  117. int msg_config_read(const char* cfgName)
  118. {
  119. 	int msg_number;
  120. 	char line[1024], w1[1024], w2[1024];
  121. 	FILE *fp;
  122. 	static int called = 1;
  123.  
  124. 	if ((fp = fopen(cfgName, "r")) == NULL) {
  125. 		ShowError("Messages file not found: %s\n", cfgName);
  126. 		return 1;
  127. 	}
  128.  
  129. 	if ((--called) == 0)
  130. 		memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  131.  
  132. 	while(fgets(line, sizeof(line), fp))
  133. 	{
  134. 		if (line[0] == '/' && line[1] == '/')
  135. 			continue;
  136. 		if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  137. 			continue;
  138.  
  139. 		if (strcmpi(w1, "import") == 0)
  140. 			msg_config_read(w2);
  141. 		else
  142. 		{
  143. 			msg_number = atoi(w1);
  144. 			if (msg_number >= 0 && msg_number < MAX_MSG)
  145. 			{
  146. 				if (msg_table[msg_number] != NULL)
  147. 					aFree(msg_table[msg_number]);
  148. 				msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  149. 				strcpy(msg_table[msg_number],w2);
  150. 			}
  151. 		}
  152. 	}
  153.  
  154. 	fclose(fp);
  155.  
  156. 	return 0;
  157. }
  158.  
  159. /*==========================================
  160.  * Cleanup Message Data
  161.  *------------------------------------------*/
  162. void do_final_msg(void)
  163. {
  164. 	int i;
  165. 	for (i = 0; i < MAX_MSG; i++)
  166. 		aFree(msg_table[i]);
  167. }
  168.  
  169. /**
  170.  * retrieves the help string associated with a given command.
  171.  *
  172.  * @param name the name of the command to retrieve help information for
  173.  * @return the string associated with the command, or NULL
  174.  */
  175. static const char* atcommand_help_string(const char* name)
  176. {
  177. 	const char* str = NULL;
  178. 	config_setting_t* info;
  179.  
  180. 	if( *name == atcommand_symbol || *name == charcommand_symbol )
  181. 	{// remove the prefix symbol for the raw name of the command
  182. 		name ++;
  183. 	}
  184.  
  185. 	// attept to find the first default help command
  186. 	info = config_lookup(&atcommand_config, "help");
  187.  
  188. 	if( info == NULL )
  189. 	{// failed to find the help property in the configuration file
  190. 		return NULL;
  191. 	}
  192.  
  193. 	if( !config_setting_lookup_string( info, name, &str ) )
  194. 	{// failed to find the matching help string
  195. 		return NULL;
  196. 	}
  197.  
  198. 	// push the result from the method
  199. 	return str;
  200. }
  201.  
  202.  
  203. /*==========================================
  204.  * @send (used for testing packet sends from the client)
  205.  *------------------------------------------*/
  206. ACMD_FUNC(send)
  207. {
  208. 	int len=0,off,end,type;
  209. 	long num;
  210.  
  211. 	// read message type as hex number (without the 0x)
  212. 	if(!message || !*message ||
  213. 			!((sscanf(message, "len %x", &type)==1 && (len=1))
  214. 			|| sscanf(message, "%x", &type)==1) )
  215. 	{
  216. 		clif_displaymessage(fd, "Usage:");
  217. 		clif_displaymessage(fd, "	@send len <packet hex number>");
  218. 		clif_displaymessage(fd, "	@send <packet hex number> {<value>}*");
  219. 		clif_displaymessage(fd, "	Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  220. 		return -1;
  221. 	}
  222.  
  223. #define PARSE_ERROR(error,p) \
  224. 	{\
  225. 		clif_displaymessage(fd, (error));\
  226. 		sprintf(atcmd_output, ">%s", (p));\
  227. 		clif_displaymessage(fd, atcmd_output);\
  228. 	}
  229. //define PARSE_ERROR
  230.  
  231. #define CHECK_EOS(p) \
  232. 	if(*(p) == 0){\
  233. 		clif_displaymessage(fd, "Unexpected end of string");\
  234. 		return -1;\
  235. 	}
  236. //define CHECK_EOS
  237.  
  238. #define SKIP_VALUE(p) \
  239. 	{\
  240. 		while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  241. 		while(*(p) && ISSPACE(*(p)))  ++(p); /* space */\
  242. 	}
  243. //define SKIP_VALUE
  244.  
  245. #define GET_VALUE(p,num) \
  246. 	{\
  247. 		if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  248. 			PARSE_ERROR("Invalid number in:",(p));\
  249. 			return -1;\
  250. 		}\
  251. 	}
  252. //define GET_VALUE
  253.  
  254. 	if (type > 0 && type < MAX_PACKET_DB) {
  255.  
  256. 		if(len)
  257. 		{// show packet length
  258. 			sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  259. 			clif_displaymessage(fd, atcmd_output);
  260. 			return 0;
  261. 		}
  262.  
  263. 		len=packet_db[sd->packet_ver][type].len;
  264. 		off=2;
  265. 		if(len == 0)
  266. 		{// unknown packet - ERROR
  267. 			sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  268. 			clif_displaymessage(fd, atcmd_output);
  269. 			return -1;
  270. 		} else if(len == -1)
  271. 		{// dynamic packet
  272. 			len=SHRT_MAX-4; // maximum length
  273. 			off=4;
  274. 		}
  275. 		WFIFOHEAD(fd, len);
  276. 		WFIFOW(fd,0)=TOW(type);
  277.  
  278. 		// parse packet contents
  279. 		SKIP_VALUE(message);
  280. 		while(*message != 0 && off < len){
  281. 			if(ISDIGIT(*message) || *message == '-' || *message == '+')
  282. 			{// default (byte)
  283. 				GET_VALUE(message,num);
  284. 				WFIFOB(fd,off)=TOB(num);
  285. 				++off;
  286. 			} else if(TOUPPER(*message) == 'B')
  287. 			{// byte
  288. 				++message;
  289. 				GET_VALUE(message,num);
  290. 				WFIFOB(fd,off)=TOB(num);
  291. 				++off;
  292. 			} else if(TOUPPER(*message) == 'W')
  293. 			{// word (2 bytes)
  294. 				++message;
  295. 				GET_VALUE(message,num);
  296. 				WFIFOW(fd,off)=TOW(num);
  297. 				off+=2;
  298. 			} else if(TOUPPER(*message) == 'L')
  299. 			{// long word (4 bytes)
  300. 				++message;
  301. 				GET_VALUE(message,num);
  302. 				WFIFOL(fd,off)=TOL(num);
  303. 				off+=4;
  304. 			} else if(TOUPPER(*message) == 'S')
  305. 			{// string - escapes are valid
  306. 				// get string length - num <= 0 means not fixed length (default)
  307. 				++message;
  308. 				if(*message == '"'){
  309. 					num=0;
  310. 				} else {
  311. 					GET_VALUE(message,num);
  312. 					while(*message != '"')
  313. 					{// find start of string
  314. 						if(*message == 0 || ISSPACE(*message)){
  315. 							PARSE_ERROR("Not a string:",message);
  316. 							return -1;
  317. 						}
  318. 						++message;
  319. 					}
  320. 				}
  321.  
  322. 				// parse string
  323. 				++message;
  324. 				CHECK_EOS(message);
  325. 				end=(num<=0? 0: min(off+((int)num),len));
  326. 				for(; *message != '"' && (off < end || end == 0); ++off){
  327. 					if(*message == '\\'){
  328. 						++message;
  329. 						CHECK_EOS(message);
  330. 						switch(*message){
  331. 							case 'a': num=0x07; break; // Bell
  332. 							case 'b': num=0x08; break; // Backspace
  333. 							case 't': num=0x09; break; // Horizontal tab
  334. 							case 'n': num=0x0A; break; // Line feed
  335. 							case 'v': num=0x0B; break; // Vertical tab
  336. 							case 'f': num=0x0C; break; // Form feed
  337. 							case 'r': num=0x0D; break; // Carriage return
  338. 							case 'e': num=0x1B; break; // Escape
  339. 							default:  num=*message; break;
  340. 							case 'x': // Hexadecimal
  341. 							{
  342. 								++message;
  343. 								CHECK_EOS(message);
  344. 								if(!ISXDIGIT(*message)){
  345. 									PARSE_ERROR("Not a hexadecimal digit:",message);
  346. 									return -1;
  347. 								}
  348. 								num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  349. 								if(ISXDIGIT(*message)){
  350. 									++message;
  351. 									CHECK_EOS(message);
  352. 									num<<=8;
  353. 									num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  354. 								}
  355. 								WFIFOB(fd,off)=TOB(num);
  356. 								++message;
  357. 								CHECK_EOS(message);
  358. 								continue;
  359. 							}
  360. 							case '0':
  361. 							case '1':
  362. 							case '2':
  363. 							case '3':
  364. 							case '4':
  365. 							case '5':
  366. 							case '6':
  367. 							case '7': // Octal
  368. 							{
  369. 								num=*message-'0'; // 1st octal digit
  370. 								++message;
  371. 								CHECK_EOS(message);
  372. 								if(ISDIGIT(*message) && *message < '8'){
  373. 									num<<=3;
  374. 									num+=*message-'0'; // 2nd octal digit
  375. 									++message;
  376. 									CHECK_EOS(message);
  377. 									if(ISDIGIT(*message) && *message < '8'){
  378. 										num<<=3;
  379. 										num+=*message-'0'; // 3rd octal digit
  380. 										++message;
  381. 										CHECK_EOS(message);
  382. 									}
  383. 								}
  384. 								WFIFOB(fd,off)=TOB(num);
  385. 								continue;
  386. 							}
  387. 						}
  388. 					} else
  389. 						num=*message;
  390. 					WFIFOB(fd,off)=TOB(num);
  391. 					++message;
  392. 					CHECK_EOS(message);
  393. 				}//for
  394. 				while(*message != '"')
  395. 				{// ignore extra characters
  396. 					++message;
  397. 					CHECK_EOS(message);
  398. 				}
  399.  
  400. 				// terminate the string
  401. 				if(off < end)
  402. 				{// fill the rest with 0's
  403. 					memset(WFIFOP(fd,off),0,end-off);
  404. 					off=end;
  405. 				}
  406. 			} else
  407. 			{// unknown
  408. 				PARSE_ERROR("Unknown type of value in:",message);
  409. 				return -1;
  410. 			}
  411. 			SKIP_VALUE(message);
  412. 		}
  413.  
  414. 		if(packet_db[sd->packet_ver][type].len == -1)
  415. 		{// send dynamic packet
  416. 			WFIFOW(fd,2)=TOW(off);
  417. 			WFIFOSET(fd,off);
  418. 		} else
  419. 		{// send static packet
  420. 			if(off < len)
  421. 				memset(WFIFOP(fd,off),0,len-off);
  422. 			WFIFOSET(fd,len);
  423. 		}
  424. 	} else {
  425. 		clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  426. 		return -1;
  427. 	}
  428. 	sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  429. 	clif_displaymessage(fd, atcmd_output);
  430. 	return 0;
  431. #undef PARSE_ERROR
  432. #undef CHECK_EOS
  433. #undef SKIP_VALUE
  434. #undef GET_VALUE
  435. }
  436.  
  437. /*==========================================
  438.  * @rura, @warp, @mapmove
  439.  *------------------------------------------*/
  440. ACMD_FUNC(mapmove)
  441. {
  442. 	char map_name[MAP_NAME_LENGTH_EXT];
  443. 	unsigned short mapindex;
  444. 	short x = 0, y = 0;
  445. 	int m = -1;
  446.  
  447. 	nullpo_retr(-1, sd);
  448.  
  449. 	memset(map_name, '\0', sizeof(map_name));
  450.  
  451. 	if (!message || !*message ||
  452. 		(sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  453. 		 sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  454.  
  455. 			clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  456. 			return -1;
  457. 	}
  458.  
  459. 	mapindex = mapindex_name2id(map_name);
  460. 	if (mapindex)
  461. 		m = map_mapindex2mapid(mapindex);
  462.  
  463. 	if (!mapindex) { // m < 0 means on different server! [Kevin]
  464. 		clif_displaymessage(fd, msg_txt(1)); // Map not found.
  465. 		return -1;
  466. 	}
  467.  
  468. 	if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  469.   	{	//This is to prevent the pc_setpos call from printing an error.
  470. 		clif_displaymessage(fd, msg_txt(2));
  471. 		if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  472. 			x = y = 0; //Invalid cell, use random spot.
  473. 	}
  474. 	if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  475. 		clif_displaymessage(fd, msg_txt(247));
  476. 		return -1;
  477. 	}
  478. 	if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  479. 		clif_displaymessage(fd, msg_txt(248));
  480. 		return -1;
  481. 	}
  482. 	if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  483. 		clif_displaymessage(fd, msg_txt(1)); // Map not found.
  484. 		return -1;
  485. 	}
  486.  
  487. 	clif_displaymessage(fd, msg_txt(0)); // Warped.
  488. 	return 0;
  489. }
  490.  
  491. /*==========================================
  492.  * Displays where a character is. Corrected version by Silent. [Skotlex]
  493.  *------------------------------------------*/
  494. ACMD_FUNC(where)
  495. {
  496. 	struct map_session_data* pl_sd;
  497.  
  498. 	nullpo_retr(-1, sd);
  499. 	memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  500.  
  501. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  502. 		clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  503. 		return -1;
  504. 	}
  505.  
  506. 	pl_sd = map_nick2sd(atcmd_player_name);
  507. 	if (pl_sd == NULL ||
  508. 	    strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  509. 	    (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  510. 	) {
  511. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  512. 		return -1;
  513. 	}
  514.  
  515. 	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);
  516. 	clif_displaymessage(fd, atcmd_output);
  517.  
  518. 	return 0;
  519. }
  520.  
  521. /*==========================================
  522.  *
  523.  *------------------------------------------*/
  524. ACMD_FUNC(jumpto)
  525. {
  526. 	struct map_session_data *pl_sd = NULL;
  527.  
  528. 	nullpo_retr(-1, sd);
  529.  
  530. 	if (!message || !*message) {
  531. 		clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  532. 		return -1;
  533. 	}
  534.  
  535. 	if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  536. 	{
  537. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  538. 		return -1;
  539. 	}
  540.  
  541. 	if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  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 && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  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, msg_txt(664));
  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 && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  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, msg_txt(664));
  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.  * Display list of online characters with
  605.  * various info.
  606.  *------------------------------------------*/
  607. ACMD_FUNC(who)
  608. {
  609. 	struct map_session_data *pl_sd = NULL;
  610. 	struct s_mapiterator *iter = NULL;
  611. 	char map_name[MAP_NAME_LENGTH_EXT] = "";
  612. 	char player_name[NAME_LENGTH] = "";
  613. 	int count = 0;
  614. 	int level = 0;
  615. 	StringBuf buf;
  616. 	/**
  617. 	 * 1 = @who  : Player name, [Title], [Party name], [Guild name]
  618. 	 * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  619. 	 * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  620. 	 */
  621. 	int display_type = 1;
  622. 	int map_id = -1;
  623.  
  624. 	nullpo_retr(-1, sd);
  625.  
  626. 	if (strstr(command, "map") != NULL) {
  627. 		if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  628. 			map_id = sd->bl.m;
  629. 	} else {
  630. 		sscanf(message, "%23s", player_name);
  631. 	}
  632.  
  633. 	if (strstr(command, "2") != NULL)
  634. 		display_type = 2;
  635. 	else if (strstr(command, "3") != NULL)
  636. 		display_type = 3;
  637.  
  638. 	level = pc_get_group_level(sd);
  639. 	StringBuf_Init(&buf);
  640.  
  641. 	iter = mapit_getallusers();
  642. 	for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter))	{
  643. 		if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  644. 			if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  645. 				|| (map_id >= 0 && pl_sd->bl.m != map_id))
  646. 				continue;
  647. 			switch (display_type) {
  648. 				case 2: {
  649. 					StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  650. 					if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  651. 						StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  652. 					StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
  653. 						job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  654. 					break;
  655. 				}
  656. 				case 3: {
  657. 					if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  658. 						StringBuf_Printf(&buf, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  659. 					StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  660. 					if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  661. 						StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  662. 					StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  663. 					break;
  664. 				}
  665. 				default: {
  666. 					struct party_data *p = party_search(pl_sd->status.party_id);
  667. 					struct guild *g = guild_search(pl_sd->status.guild_id);
  668.  
  669. 					StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  670. 					if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  671. 						StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  672. 					if (p != NULL)
  673. 						StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'"
  674. 					if (g != NULL)
  675. 						StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'"
  676. 					break;
  677. 				}
  678. 			}
  679. 			clif_displaymessage(fd, StringBuf_Value(&buf));
  680. 			StringBuf_Clear(&buf);
  681. 			count++;
  682. 		}
  683. 	}
  684. 	mapit_free(iter);
  685.  
  686. 	if (map_id < 0) {
  687. 		if (count == 0)
  688. 			StringBuf_Printf(&buf, msg_txt(28)); // No player found.
  689. 		else if (count == 1)
  690. 			StringBuf_Printf(&buf, msg_txt(29)); // 1 player found.
  691. 		else
  692. 			StringBuf_Printf(&buf, msg_txt(30), count); // %d players found.
  693. 	} else {
  694. 		if (count == 0)
  695. 			StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  696. 		else if (count == 1)
  697. 			StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  698. 		else
  699. 			StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  700. 	}
  701. 	clif_displaymessage(fd, StringBuf_Value(&buf));
  702. 	StringBuf_Destroy(&buf);
  703. 	return 0;
  704. }
  705.  
  706. /*==========================================
  707.  *
  708.  *------------------------------------------*/
  709. ACMD_FUNC(whogm)
  710. {
  711. 	struct map_session_data* pl_sd;
  712. 	struct s_mapiterator* iter;
  713. 	int j, count;
  714. 	int pl_level, level;
  715. 	char match_text[CHAT_SIZE_MAX];
  716. 	char player_name[NAME_LENGTH];
  717. 	struct guild *g;
  718. 	struct party_data *p;
  719.  
  720. 	nullpo_retr(-1, sd);
  721.  
  722. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  723. 	memset(match_text, '\0', sizeof(match_text));
  724. 	memset(player_name, '\0', sizeof(player_name));
  725.  
  726. 	if (sscanf(message, "%199[^\n]", match_text) < 1)
  727. 		strcpy(match_text, "");
  728. 	for (j = 0; match_text[j]; j++)
  729. 		match_text[j] = TOLOWER(match_text[j]);
  730.  
  731. 	count = 0;
  732. 	level = pc_get_group_level(sd);
  733.  
  734. 	iter = mapit_getallusers();
  735. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  736. 	{
  737. 		pl_level = pc_get_group_level(pl_sd);
  738. 		if (!pl_level)
  739. 			continue;
  740.  
  741. 		if (match_text[0])
  742. 		{
  743. 			memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  744. 			for (j = 0; player_name[j]; j++)
  745. 				player_name[j] = TOLOWER(player_name[j]);
  746. 		  	// search with no case sensitive
  747. 			if (strstr(player_name, match_text) == NULL)
  748. 				continue;
  749. 		}
  750. 		if (pl_level > level) {
  751. 			if (pl_sd->sc.option & OPTION_INVISIBLE)
  752. 				continue;
  753. 			sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  754. 			clif_displaymessage(fd, atcmd_output);
  755. 			count++;
  756. 			continue;
  757. 		}
  758.  
  759. 		sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  760. 			pl_sd->status.name, pl_level,
  761. 			mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  762. 		clif_displaymessage(fd, atcmd_output);
  763.  
  764. 		sprintf(atcmd_output, "       BLvl: %d | Job: %s (Lvl: %d)",
  765. 			pl_sd->status.base_level,
  766. 			job_name(pl_sd->status.class_), pl_sd->status.job_level);
  767. 		clif_displaymessage(fd, atcmd_output);
  768.  
  769. 		p = party_search(pl_sd->status.party_id);
  770. 		g = guild_search(pl_sd->status.guild_id);
  771.  
  772. 		sprintf(atcmd_output,"       Party: '%s' | Guild: '%s'",
  773. 			p?p->party.name:"None", g?g->name:"None");
  774.  
  775. 		clif_displaymessage(fd, atcmd_output);
  776. 		count++;
  777. 	}
  778. 	mapit_free(iter);
  779.  
  780. 	if (count == 0)
  781. 		clif_displaymessage(fd, msg_txt(150)); // No GM found.
  782. 	else if (count == 1)
  783. 		clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  784. 	else {
  785. 		sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  786. 		clif_displaymessage(fd, atcmd_output);
  787. 	}
  788.  
  789. 	return 0;
  790. }
  791.  
  792. /*==========================================
  793.  *
  794.  *------------------------------------------*/
  795. ACMD_FUNC(save)
  796. {
  797. 	nullpo_retr(-1, sd);
  798.  
  799. 	pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  800. 	if (sd->status.pet_id > 0 && sd->pd)
  801. 		intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  802.  
  803. 	chrif_save(sd,0);
  804.  
  805. 	clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  806.  
  807. 	return 0;
  808. }
  809.  
  810. /*==========================================
  811.  *
  812.  *------------------------------------------*/
  813. ACMD_FUNC(load)
  814. {
  815. 	int m;
  816.  
  817. 	nullpo_retr(-1, sd);
  818.  
  819. 	m = map_mapindex2mapid(sd->status.save_point.map);
  820. 	if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  821. 		clif_displaymessage(fd, msg_txt(249));	// You are not authorized to warp to your save map.
  822. 		return -1;
  823. 	}
  824. 	if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  825. 		clif_displaymessage(fd, msg_txt(248));	// You are not authorized to warp from your current map.
  826. 		return -1;
  827. 	}
  828.  
  829. 	pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  830. 	clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  831.  
  832. 	return 0;
  833. }
  834.  
  835. /*==========================================
  836.  *
  837.  *------------------------------------------*/
  838. ACMD_FUNC(speed)
  839. {
  840. 	int speed;
  841.  
  842. 	nullpo_retr(-1, sd);
  843.  
  844. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  845.  
  846. 	if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  847. 		sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  848. 		clif_displaymessage(fd, atcmd_output);
  849. 		return -1;
  850. 	}
  851.  
  852. 	sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  853. 	status_calc_bl(&sd->bl, SCB_SPEED);
  854. 	clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  855. 	return 0;
  856. }
  857.  
  858. /*==========================================
  859.  *
  860.  *------------------------------------------*/
  861. ACMD_FUNC(storage)
  862. {
  863. 	nullpo_retr(-1, sd);
  864.  
  865. 	if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  866. 		return -1;
  867.  
  868. 	if (storage_storageopen(sd) == 1)
  869. 	{	//Already open.
  870. 		clif_displaymessage(fd, msg_txt(250));
  871. 		return -1;
  872. 	}
  873.  
  874. 	clif_displaymessage(fd, "Storage opened.");
  875.  
  876. 	return 0;
  877. }
  878.  
  879.  
  880. /*==========================================
  881.  *
  882.  *------------------------------------------*/
  883. ACMD_FUNC(guildstorage)
  884. {
  885. 	nullpo_retr(-1, sd);
  886.  
  887. 	if (!sd->status.guild_id) {
  888. 		clif_displaymessage(fd, msg_txt(252));
  889. 		return -1;
  890. 	}
  891.  
  892. 	if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  893. 		return -1;
  894.  
  895. 	if (sd->state.storage_flag == 1) {
  896. 		clif_displaymessage(fd, msg_txt(250));
  897. 		return -1;
  898. 	}
  899.  
  900. 	if (sd->state.storage_flag == 2) {
  901. 		clif_displaymessage(fd, msg_txt(251));
  902. 		return -1;
  903. 	}
  904.  
  905. 	storage_guild_storageopen(sd);
  906. 	clif_displaymessage(fd, "Guild storage opened.");
  907. 	return 0;
  908. }
  909.  
  910. /*==========================================
  911.  *
  912.  *------------------------------------------*/
  913. ACMD_FUNC(option)
  914. {
  915. 	int param1 = 0, param2 = 0, param3 = 0;
  916. 	nullpo_retr(-1, sd);
  917.  
  918. 	if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  919. 	{// failed to match the parameters so inform the user of the options
  920. 		const char* text = NULL;
  921.  
  922. 		// attempt to find the setting information for this command
  923. 		text = atcommand_help_string( command );
  924.  
  925. 		// notify the user of the requirement to enter an option
  926. 		clif_displaymessage(fd, "Please, enter at least one option..");
  927.  
  928. 		if( text )
  929. 		{// send the help text associated with this command
  930. 			clif_displaymessage( fd, text );
  931. 		}
  932.  
  933. 		return -1;
  934. 	}
  935.  
  936. 	sd->sc.opt1 = param1;
  937. 	sd->sc.opt2 = param2;
  938. 	pc_setoption(sd, param3);
  939.  
  940. 	clif_displaymessage(fd, msg_txt(9)); // Options changed.
  941.  
  942. 	return 0;
  943. }
  944.  
  945. /*==========================================
  946.  *
  947.  *------------------------------------------*/
  948. ACMD_FUNC(hide)
  949. {
  950. 	nullpo_retr(-1, sd);
  951. 	if (sd->sc.option & OPTION_INVISIBLE) {
  952. 		sd->sc.option &= ~OPTION_INVISIBLE;
  953. 		if (sd->disguise)
  954. 			status_set_viewdata(&sd->bl, sd->disguise);
  955. 		else
  956. 			status_set_viewdata(&sd->bl, sd->status.class_);
  957. 		clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  958.  
  959. 		// increment the number of pvp players on the map
  960. 		map[sd->bl.m].users_pvp++;
  961.  
  962. 		if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  963. 		{// register the player for ranking calculations
  964. 			sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  965. 		}
  966. 		//bugreport:2266
  967. 		map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  968. 	} else {
  969. 		sd->sc.option |= OPTION_INVISIBLE;
  970. 		sd->vd.class_ = INVISIBLE_CLASS;
  971. 		clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  972.  
  973. 		// decrement the number of pvp players on the map
  974. 		map[sd->bl.m].users_pvp--;
  975.  
  976. 		if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  977. 		{// unregister the player for ranking
  978. 			delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  979. 			sd->pvp_timer = INVALID_TIMER;
  980. 		}
  981. 	}
  982. 	clif_changeoption(&sd->bl);
  983.  
  984. 	return 0;
  985. }
  986.  
  987. /*==========================================
  988.  * Changes a character's class
  989.  *------------------------------------------*/
  990. ACMD_FUNC(jobchange)
  991. {
  992. 	//FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  993. 	int job = 0, upper = 0;
  994. 	nullpo_retr(-1, sd);
  995.  
  996. 	if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  997. 	{
  998. 		int i, found = 0;
  999. 		const struct { char name[24]; int id; } jobs[] = {
  1000. 			{ "novice",		0 },
  1001. 			{ "swordman",	1 },
  1002. 			{ "swordsman",	1 },
  1003. 			{ "magician",	2 },
  1004. 			{ "mage",		2 },
  1005. 			{ "archer",		3 },
  1006. 			{ "acolyte",	4 },
  1007. 			{ "merchant",	5 },
  1008. 			{ "thief",		6 },
  1009. 			{ "knight",		7 },
  1010. 			{ "priest",		8 },
  1011. 			{ "priestess",	8 },
  1012. 			{ "wizard",		9 },
  1013. 			{ "blacksmith",	10 },
  1014. 			{ "hunter",		11 },
  1015. 			{ "assassin",	12 },
  1016. 			{ "crusader",	14 },
  1017. 			{ "monk",		15 },
  1018. 			{ "sage",		16 },
  1019. 			{ "rogue",		17 },
  1020. 			{ "alchemist",	18 },
  1021. 			{ "bard",		19 },
  1022. 			{ "dancer",		20 },
  1023. 			{ "super novice",	23 },
  1024. 			{ "supernovice",	23 },
  1025. 			{ "gunslinger",	24 },
  1026. 			{ "gunner",	24 },
  1027. 			{ "ninja",	25 },
  1028. 			{ "novice high",	4001 },
  1029. 			{ "high novice",	4001 },
  1030. 			{ "swordman high",	4002 },
  1031. 			{ "swordsman high",	4002 },
  1032. 			{ "magician high",	4003 },
  1033. 			{ "mage high",		4003 },
  1034. 			{ "archer high",	4004 },
  1035. 			{ "acolyte high",	4005 },
  1036. 			{ "merchant high",	4006 },
  1037. 			{ "thief high",		4007 },
  1038. 			{ "lord knight",	4008 },
  1039. 			{ "high priest",	4009 },
  1040. 			{ "high priestess",	4009 },
  1041. 			{ "high wizard",	4010 },
  1042. 			{ "whitesmith",		4011 },
  1043. 			{ "sniper",		4012 },
  1044. 			{ "assassin cross",	4013 },
  1045. 			{ "paladin",	4015 },
  1046. 			{ "champion",	4016 },
  1047. 			{ "professor",	4017 },
  1048. 			{ "stalker",	4018 },
  1049. 			{ "creator",	4019 },
  1050. 			{ "clown",		4020 },
  1051. 			{ "gypsy",		4021 },
  1052. 			{ "baby novice",	4023 },
  1053. 			{ "baby swordman",	4024 },
  1054. 			{ "baby swordsman",	4024 },
  1055. 			{ "baby magician",	4025 },
  1056. 			{ "baby mage",		4025 },
  1057. 			{ "baby archer",	4026 },
  1058. 			{ "baby acolyte",	4027 },
  1059. 			{ "baby merchant",	4028 },
  1060. 			{ "baby thief",		4029 },
  1061. 			{ "baby knight",	4030 },
  1062. 			{ "baby priest",	4031 },
  1063. 			{ "baby priestess",	4031 },
  1064. 			{ "baby wizard",	4032 },
  1065. 			{ "baby blacksmith",4033 },
  1066. 			{ "baby hunter",	4034 },
  1067. 			{ "baby assassin",	4035 },
  1068. 			{ "baby crusader",	4037 },
  1069. 			{ "baby monk",		4038 },
  1070. 			{ "baby sage",		4039 },
  1071. 			{ "baby rogue",		4040 },
  1072. 			{ "baby alchemist",	4041 },
  1073. 			{ "baby bard",		4042 },
  1074. 			{ "baby dancer",	4043 },
  1075. 			{ "super baby",		4045 },
  1076. 			{ "taekwon",		4046 },
  1077. 			{ "taekwon boy",	4046 },
  1078. 			{ "taekwon girl",	4046 },
  1079. 			{ "star gladiator",	4047 },
  1080. 			{ "soul linker",	4049 },
  1081. 			{ "gangsi",		4050 },
  1082. 			{ "bongun",		4050 },
  1083. 			{ "munak",		4050 },
  1084. 			{ "death knight",	4051 },
  1085. 			{ "dark collector",	4052 },
  1086. 			{ "rune knight",	4054 },
  1087. 			{ "warlock",		4055 },
  1088. 			{ "ranger",		4056 },
  1089. 			{ "arch bishop",	4057 },
  1090. 			{ "mechanic",		4058 },
  1091. 			{ "guillotine",		4059 },
  1092. 			{ "rune knight2",	4060 },
  1093. 			{ "warlock2",		4061 },
  1094. 			{ "ranger2",		4062 },
  1095. 			{ "arch bishop2",	4063 },
  1096. 			{ "mechanic2",		4064 },
  1097. 			{ "guillotine2",	4065 },
  1098. 			{ "royal guard",	4066 },
  1099. 			{ "sorcerer",		4067 },
  1100. 			{ "minstrel",		4068 },
  1101. 			{ "wanderer",		4069 },
  1102. 			{ "sura",		4070 },
  1103. 			{ "genetic",		4071 },
  1104. 			{ "shadow chaser",	4072 },
  1105. 			{ "royal guard2",	4073 },
  1106. 			{ "sorcerer2",		4074 },
  1107. 			{ "minstrel2",		4075 },
  1108. 			{ "wanderer2",		4076 },
  1109. 			{ "sura2",		4077 },
  1110. 			{ "genetic2",		4078 },
  1111. 			{ "shadow chaser2",	4079 },
  1112. 			{ "baby rune",		4096 },
  1113. 			{ "baby warlock",	4097 },
  1114. 			{ "baby ranger",	4098 },
  1115. 			{ "baby bishop",	4099 },
  1116. 			{ "baby mechanic",	4100 },
  1117. 			{ "baby cross",		4101 },
  1118. 			{ "baby guard",		4102 },
  1119. 			{ "baby sorcerer",	4103 },
  1120. 			{ "baby minstrel",	4104 },
  1121. 			{ "baby wanderer",	4105 },
  1122. 			{ "baby sura",		4106 },
  1123. 			{ "baby genetic",	4107 },
  1124. 			{ "baby chaser",	4108 },
  1125. 			{ "super novice e",	4190 },
  1126. 			{ "super baby e",	4191 },
  1127. 			{ "kagerou",		4211 },
  1128. 			{ "oboro",		4212 },
  1129. 		};
  1130.  
  1131. 		for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1132. 			if (strncmpi(message, jobs[i].name, 16) == 0) {
  1133. 				job = jobs[i].id;
  1134. 				upper = 0;
  1135. 				found = 1;
  1136. 				break;
  1137. 			}
  1138. 		}
  1139.  
  1140. 		// TODO: convert this to use atcommand_help_string()
  1141. 		if (!found) {
  1142. 			clif_displaymessage(fd, "Please, enter a job ID (usage: @job/@jobchange <job name/ID>).");
  1143. 			clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1144. 			clif_displaymessage(fd, "   0 Novice              1 Swordman            2 Magician            3 Archer");
  1145. 			clif_displaymessage(fd, "   4 Acolyte             5 Merchant            6 Thief");
  1146. 			clif_displaymessage(fd, "----- 2nd Class -----");
  1147. 			clif_displaymessage(fd, "   7 Knight              8 Priest              9 Wizard             10 Blacksmith");
  1148. 			clif_displaymessage(fd, "  11 Hunter             12 Assassin           14 Crusader           15 Monk");
  1149. 			clif_displaymessage(fd, "  16 Sage               17 Rogue              18 Alchemist          19 Bard");
  1150. 			clif_displaymessage(fd, "  20 Dancer");
  1151. 			clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1152. 			clif_displaymessage(fd, "4001 Novice High      4002 Swordman High    4003 Magician High    4004 Archer High");
  1153. 			clif_displaymessage(fd, "4005 Acolyte High     4006 Merchant High    4007 Thief High");
  1154. 			clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1155. 			clif_displaymessage(fd, "4008 Lord Knight      4009 High Priest      4010 High Wizard      4011 Whitesmith");
  1156. 			clif_displaymessage(fd, "4012 Sniper           4013 Assassin Cross   4015 Paladin          4016 Champion");
  1157. 			clif_displaymessage(fd, "4017 Professor        4018 Stalker          4019 Creator          4020 Clown");
  1158. 			clif_displaymessage(fd, "4021 Gypsy");
  1159. 			clif_displaymessage(fd, "----- 3rd Class (Regular) -----");
  1160. 			clif_displaymessage(fd, "4054 Rune Knight      4055 Warlock          4056 Ranger           4057 Arch Bishop");
  1161. 			clif_displaymessage(fd, "4058 Mechanic         4059 Guillotine Cross 4066 Royal Guard      4067 Sorcerer");
  1162. 			clif_displaymessage(fd, "4068 Minstrel         4069 Wanderer         4070 Sura             4071 Genetic");
  1163. 			clif_displaymessage(fd, "4072 Shadow Chaser");
  1164. 			clif_displaymessage(fd, "----- 3rd Class (Transcendent) -----");
  1165. 			clif_displaymessage(fd, "4060 Rune Knight      4061 Warlock          4062 Ranger           4063 Arch Bishop");
  1166. 			clif_displaymessage(fd, "4064 Mechanic         4065 Guillotine Cross 4073 Royal Guard      4074 Sorcerer");
  1167. 			clif_displaymessage(fd, "4075 Minstrel         4076 Wanderer         4077 Sura             4078 Genetic");
  1168. 			clif_displaymessage(fd, "4079 Shadow Chaser");
  1169. 			clif_displaymessage(fd, "----- Expanded Class -----");
  1170. 			clif_displaymessage(fd, "  23 Super Novice       24 Gunslinger         25 Ninja            4045 Super Baby");
  1171. 			clif_displaymessage(fd, "4046 Taekwon          4047 Star Gladiator   4049 Soul Linker      4050 Gangsi");
  1172. 			clif_displaymessage(fd, "4051 Death Knight     4052 Dark Collector   4190 Ex. Super Novice 4191 Ex. Super Baby");
  1173. 			clif_displaymessage(fd, "4211 Kagerou          4212 Oboro");
  1174. 			clif_displaymessage(fd, "----- Baby Novice And Baby 1st Class -----");
  1175. 			clif_displaymessage(fd, "4023 Baby Novice      4024 Baby Swordman    4025 Baby Magician    4026 Baby Archer");
  1176. 			clif_displaymessage(fd, "4027 Baby Acolyte     4028 Baby Merchant    4029 Baby Thief");
  1177. 			clif_displaymessage(fd, "---- Baby 2nd Class ----");
  1178. 			clif_displaymessage(fd, "4030 Baby Knight      4031 Baby Priest      4032 Baby Wizard      4033 Baby Blacksmith");
  1179. 			clif_displaymessage(fd, "4034 Baby Hunter      4035 Baby Assassin    4037 Baby Crusader    4038 Baby Monk");
  1180. 			clif_displaymessage(fd, "4039 Baby Sage        4040 Baby Rogue       4041 Baby Alchemist   4042 Baby Bard");
  1181. 			clif_displaymessage(fd, "4043 Baby Dancer");
  1182. 			clif_displaymessage(fd, "---- Baby 3rd Class ----");
  1183. 			clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock     4098 Baby Ranger      4099 Baby Arch Bishop");
  1184. 			clif_displaymessage(fd, "4100 Baby Mechanic    4101 Baby Glt. Cross  4102 Baby Royal Guard 4103 Baby Sorcerer");
  1185. 			clif_displaymessage(fd, "4104 Baby Minstrel    4105 Baby Wanderer    4106 Baby Sura        4107 Baby Genetic");
  1186. 			clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1187. 			//clif_displaymessage(fd, "---- Modes And Others ----");
  1188. 			//clif_displaymessage(fd, "  22 Wedding            26 Christmas          27 Summer           4048 Star Gladiator (Union)");
  1189. 			return -1;
  1190. 		}
  1191. 	}
  1192.  
  1193. 	if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27 || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1194. 		 || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  1195. 	) // Deny direct transformation into dummy jobs
  1196. 		{clif_displaymessage(fd, "You can not change to this job by command.");
  1197. 		return 0;}
  1198.  
  1199. 	if (pcdb_checkid(job))
  1200. 	{
  1201. 		if (pc_jobchange(sd, job, upper) == 0)
  1202. 			clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1203. 		else {
  1204. 			clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1205. 			return -1;
  1206. 		}
  1207. 	} else {
  1208. 			// TODO: convert this to use atcommand_help_string()
  1209. 			clif_displaymessage(fd, "Please enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1210. 			clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1211. 			clif_displaymessage(fd, "   0 Novice              1 Swordman            2 Magician            3 Archer");
  1212. 			clif_displaymessage(fd, "   4 Acolyte             5 Merchant            6 Thief");
  1213. 			clif_displaymessage(fd, "----- 2nd Class -----");
  1214. 			clif_displaymessage(fd, "   7 Knight              8 Priest              9 Wizard             10 Blacksmith");
  1215. 			clif_displaymessage(fd, "  11 Hunter             12 Assassin           14 Crusader           15 Monk");
  1216. 			clif_displaymessage(fd, "  16 Sage               17 Rogue              18 Alchemist          19 Bard");
  1217. 			clif_displaymessage(fd, "  20 Dancer");
  1218. 			clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1219. 			clif_displaymessage(fd, "4001 Novice High      4002 Swordman High    4003 Magician High    4004 Archer High");
  1220. 			clif_displaymessage(fd, "4005 Acolyte High     4006 Merchant High    4007 Thief High");
  1221. 			clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1222. 			clif_displaymessage(fd, "4008 Lord Knight      4009 High Priest      4010 High Wizard      4011 Whitesmith");
  1223. 			clif_displaymessage(fd, "4012 Sniper           4013 Assassin Cross   4015 Paladin          4016 Champion");
  1224. 			clif_displaymessage(fd, "4017 Professor        4018 Stalker          4019 Creator          4020 Clown");
  1225. 			clif_displaymessage(fd, "4021 Gypsy");
  1226. 			clif_displaymessage(fd, "----- 3rd Class (Regular) -----");
  1227. 			clif_displaymessage(fd, "4054 Rune Knight      4055 Warlock          4056 Ranger           4057 Arch Bishop");
  1228. 			clif_displaymessage(fd, "4058 Mechanic         4059 Guillotine Cross 4066 Royal Guard      4067 Sorcerer");
  1229. 			clif_displaymessage(fd, "4068 Minstrel         4069 Wanderer         4070 Sura             4071 Genetic");
  1230. 			clif_displaymessage(fd, "4072 Shadow Chaser");
  1231. 			clif_displaymessage(fd, "----- 3rd Class (Transcendent) -----");
  1232. 			clif_displaymessage(fd, "4060 Rune Knight      4061 Warlock          4062 Ranger           4063 Arch Bishop");
  1233. 			clif_displaymessage(fd, "4064 Mechanic         4065 Guillotine Cross 4073 Royal Guard      4074 Sorcerer");
  1234. 			clif_displaymessage(fd, "4075 Minstrel         4076 Wanderer         4077 Sura             4078 Genetic");
  1235. 			clif_displaymessage(fd, "4079 Shadow Chaser");
  1236. 			clif_displaymessage(fd, "----- Expanded Class -----");
  1237. 			clif_displaymessage(fd, "  23 Super Novice       24 Gunslinger         25 Ninja            4045 Super Baby");
  1238. 			clif_displaymessage(fd, "4046 Taekwon          4047 Star Gladiator   4049 Soul Linker      4050 Gangsi");
  1239. 			clif_displaymessage(fd, "4051 Death Knight     4052 Dark Collector   4190 Ex. Super Novice 4191 Ex. Super Baby");
  1240. 			clif_displaymessage(fd, "4211 Kagerou          4212 Oboro");
  1241. 			clif_displaymessage(fd, "----- Baby Novice And Baby 1st Class -----");
  1242. 			clif_displaymessage(fd, "4023 Baby Novice      4024 Baby Swordman    4025 Baby Magician    4026 Baby Archer");
  1243. 			clif_displaymessage(fd, "4027 Baby Acolyte     4028 Baby Merchant    4029 Baby Thief");
  1244. 			clif_displaymessage(fd, "---- Baby 2nd Class ----");
  1245. 			clif_displaymessage(fd, "4030 Baby Knight      4031 Baby Priest      4032 Baby Wizard      4033 Baby Blacksmith");
  1246. 			clif_displaymessage(fd, "4034 Baby Hunter      4035 Baby Assassin    4037 Baby Crusader    4038 Baby Monk");
  1247. 			clif_displaymessage(fd, "4039 Baby Sage        4040 Baby Rogue       4041 Baby Alchemist   4042 Baby Bard");
  1248. 			clif_displaymessage(fd, "4043 Baby Dancer");
  1249. 			clif_displaymessage(fd, "---- Baby 3rd Class ----");
  1250. 			clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock     4098 Baby Ranger      4099 Baby Arch Bishop");
  1251. 			clif_displaymessage(fd, "4100 Baby Mechanic    4101 Baby Glt. Cross  4102 Baby Royal Guard 4103 Baby Sorcerer");
  1252. 			clif_displaymessage(fd, "4104 Baby Minstrel    4105 Baby Wanderer    4106 Baby Sura        4107 Baby Genetic");
  1253. 			clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1254. 			//clif_displaymessage(fd, "---- Modes And Others ----");
  1255. 			//clif_displaymessage(fd, "  22 Wedding            26 Christmas          27 Summer           4048 Star Gladiator (Union)");
  1256. 		return -1;
  1257. 	}
  1258.  
  1259. 	return 0;
  1260. }
  1261.  
  1262. /*==========================================
  1263.  *
  1264.  *------------------------------------------*/
  1265. ACMD_FUNC(kill)
  1266. {
  1267. 	nullpo_retr(-1, sd);
  1268. 	status_kill(&sd->bl);
  1269. 	clif_displaymessage(sd->fd, msg_txt(13)); // A pity! You've died.
  1270. 	if (fd != sd->fd)
  1271. 		clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1272. 	return 0;
  1273. }
  1274.  
  1275. /*==========================================
  1276.  *
  1277.  *------------------------------------------*/
  1278. ACMD_FUNC(alive)
  1279. {
  1280. 	nullpo_retr(-1, sd);
  1281. 	if (!status_revive(&sd->bl, 100, 100))
  1282. 	{
  1283. 		clif_displaymessage(fd, msg_txt(667));
  1284. 		return -1;
  1285. 	}
  1286. 	clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1287. 	clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1288. 	return 0;
  1289. }
  1290.  
  1291. /*==========================================
  1292.  * +kamic [LuzZza]
  1293.  *------------------------------------------*/
  1294. ACMD_FUNC(kami)
  1295. {
  1296. 	unsigned long color=0;
  1297. 	nullpo_retr(-1, sd);
  1298.  
  1299. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  1300.  
  1301. 	if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1302. 		if (!message || !*message) {
  1303. 			clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1304. 			return -1;
  1305. 		}
  1306.  
  1307. 		sscanf(message, "%199[^\n]", atcmd_output);
  1308. 		if (strstr(command, "l") != NULL)
  1309. 			clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  1310. 		else
  1311. 			intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1312. 	} else {
  1313. 		if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1314. 			clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1315. 			return -1;
  1316. 		}
  1317.  
  1318. 		if(color > 0xFFFFFF) {
  1319. 			clif_displaymessage(fd, "Invalid color.");
  1320. 			return -1;
  1321. 		}
  1322. 		intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1323. 	}
  1324. 	return 0;
  1325. }
  1326.  
  1327. /*==========================================
  1328.  *
  1329.  *------------------------------------------*/
  1330. ACMD_FUNC(heal)
  1331. {
  1332. 	int hp = 0, sp = 0; // [Valaris] thanks to fov
  1333. 	nullpo_retr(-1, sd);
  1334.  
  1335. 	sscanf(message, "%d %d", &hp, &sp);
  1336.  
  1337. 	// some overflow checks
  1338. 	if( hp == INT_MIN ) hp++;
  1339. 	if( sp == INT_MIN ) sp++;
  1340.  
  1341. 	if ( hp == 0 && sp == 0 ) {
  1342. 		if (!status_percent_heal(&sd->bl, 100, 100))
  1343. 			clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1344. 		else
  1345. 			clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1346. 		return 0;
  1347. 	}
  1348.  
  1349. 	if ( hp > 0 && sp >= 0 ) {
  1350. 		if(!status_heal(&sd->bl, hp, sp, 0))
  1351. 			clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1352. 		else
  1353. 			clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1354. 		return 0;
  1355. 	}
  1356.  
  1357. 	if ( hp < 0 && sp <= 0 ) {
  1358. 		status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1359. 		clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1360. 		clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1361. 		return 0;
  1362. 	}
  1363.  
  1364. 	//Opposing signs.
  1365. 	if ( hp ) {
  1366. 		if (hp > 0)
  1367. 			status_heal(&sd->bl, hp, 0, 0);
  1368. 		else {
  1369. 			status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1370. 			clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1371. 		}
  1372. 	}
  1373.  
  1374. 	if ( sp ) {
  1375. 		if (sp > 0)
  1376. 			status_heal(&sd->bl, 0, sp, 0);
  1377. 		else
  1378. 			status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1379. 	}
  1380.  
  1381. 	clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1382. 	return 0;
  1383. }
  1384.  
  1385. /*==========================================
  1386.  * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1387.  *------------------------------------------*/
  1388. ACMD_FUNC(item)
  1389. {
  1390. 	char item_name[100];
  1391. 	int number = 0, item_id, flag;
  1392. 	struct item item_tmp;
  1393. 	struct item_data *item_data;
  1394. 	int get_count, i;
  1395. 	nullpo_retr(-1, sd);
  1396.  
  1397. 	memset(item_name, '\0', sizeof(item_name));
  1398.  
  1399. 	if (!message || !*message || (
  1400. 		sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1401. 		sscanf(message, "%99s %d", item_name, &number) < 1
  1402. 	)) {
  1403. 		clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1404. 		return -1;
  1405. 	}
  1406.  
  1407. 	if (number <= 0)
  1408. 		number = 1;
  1409.  
  1410. 	if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1411. 	    (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1412. 	{
  1413. 		clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1414. 		return -1;
  1415. 	}
  1416.  
  1417. 	item_id = item_data->nameid;
  1418. 	get_count = number;
  1419. 	//Check if it's stackable.
  1420. 	if (!itemdb_isstackable2(item_data))
  1421. 		get_count = 1;
  1422.  
  1423. 	for (i = 0; i < number; i += get_count) {
  1424. 		// if not pet egg
  1425. 		if (!pet_create_egg(sd, item_id)) {
  1426. 			memset(&item_tmp, 0, sizeof(item_tmp));
  1427. 			item_tmp.nameid = item_id;
  1428. 			item_tmp.identify = 1;
  1429.  
  1430. 			if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1431. 				clif_additem(sd, 0, 0, flag);
  1432. 		}
  1433. 	}
  1434.  
  1435. 	clif_displaymessage(fd, msg_txt(18)); // Item created.
  1436. 	return 0;
  1437. }
  1438.  
  1439. /*==========================================
  1440.  *
  1441.  *------------------------------------------*/
  1442. ACMD_FUNC(item2)
  1443. {
  1444. 	struct item item_tmp;
  1445. 	struct item_data *item_data;
  1446. 	char item_name[100];
  1447. 	int item_id, number = 0;
  1448. 	int identify = 0, refine = 0, attr = 0;
  1449. 	int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1450. 	int flag;
  1451. 	int loop, get_count, i;
  1452. 	nullpo_retr(-1, sd);
  1453.  
  1454. 	memset(item_name, '\0', sizeof(item_name));
  1455.  
  1456. 	if (!message || !*message || (
  1457. 		sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1458. 		sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1459. 	)) {
  1460. 		clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1461. 		clif_displaymessage(fd, "  <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1462. 		return -1;
  1463. 	}
  1464.  
  1465. 	if (number <= 0)
  1466. 		number = 1;
  1467.  
  1468. 	item_id = 0;
  1469. 	if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1470. 	    (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1471. 		item_id = item_data->nameid;
  1472.  
  1473. 	if (item_id > 500) {
  1474. 		loop = 1;
  1475. 		get_count = number;
  1476. 		if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1477. 			item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1478. 			loop = number;
  1479. 			get_count = 1;
  1480. 			if (item_data->type == IT_PETEGG) {
  1481. 				identify = 1;
  1482. 				refine = 0;
  1483. 			}
  1484. 			if (item_data->type == IT_PETARMOR)
  1485. 				refine = 0;
  1486. 			if (refine > MAX_REFINE)
  1487. 				refine = MAX_REFINE;
  1488. 		} else {
  1489. 			identify = 1;
  1490. 			refine = attr = 0;
  1491. 		}
  1492. 		for (i = 0; i < loop; i++) {
  1493. 			memset(&item_tmp, 0, sizeof(item_tmp));
  1494. 			item_tmp.nameid = item_id;
  1495. 			item_tmp.identify = identify;
  1496. 			item_tmp.refine = refine;
  1497. 			item_tmp.attribute = attr;
  1498. 			item_tmp.card[0] = c1;
  1499. 			item_tmp.card[1] = c2;
  1500. 			item_tmp.card[2] = c3;
  1501. 			item_tmp.card[3] = c4;
  1502. 			if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1503. 				clif_additem(sd, 0, 0, flag);
  1504. 		}
  1505.  
  1506. 		clif_displaymessage(fd, msg_txt(18)); // Item created.
  1507. 	} else {
  1508. 		clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1509. 		return -1;
  1510. 	}
  1511.  
  1512. 	return 0;
  1513. }
  1514.  
  1515. /*==========================================
  1516.  *
  1517.  *------------------------------------------*/
  1518. ACMD_FUNC(itemreset)
  1519. {
  1520. 	int i;
  1521. 	nullpo_retr(-1, sd);
  1522.  
  1523. 	for (i = 0; i < MAX_INVENTORY; i++) {
  1524. 		if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1525. 			pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1526. 		}
  1527. 	}
  1528. 	clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1529.  
  1530. 	return 0;
  1531. }
  1532.  
  1533. /*==========================================
  1534.  * Atcommand @lvlup
  1535.  *------------------------------------------*/
  1536. ACMD_FUNC(baselevelup)
  1537. {
  1538. 	int level=0, i=0, status_point=0;
  1539. 	nullpo_retr(-1, sd);
  1540. 	level = atoi(message);
  1541.  
  1542. 	if (!message || !*message || !level) {
  1543. 		clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1544. 		return -1;
  1545. 	}
  1546.  
  1547. 	if (level > 0) {
  1548. 		if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1549. 			clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1550. 			return -1;
  1551. 		} // End Addition
  1552. 		if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1553. 			level = pc_maxbaselv(sd) - sd->status.base_level;
  1554. 		for (i = 0; i < level; i++)
  1555. 			status_point += pc_gets_status_point(sd->status.base_level + i);
  1556.  
  1557. 		sd->status.status_point += status_point;
  1558. 		sd->status.base_level += (unsigned int)level;
  1559. 		status_percent_heal(&sd->bl, 100, 100);
  1560. 		clif_misceffect(&sd->bl, 0);
  1561. 		clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1562. 	} else {
  1563. 		if (sd->status.base_level == 1) {
  1564. 			clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1565. 			return -1;
  1566. 		}
  1567. 		level*=-1;
  1568. 		if ((unsigned int)level >= sd->status.base_level)
  1569. 			level = sd->status.base_level-1;
  1570. 		for (i = 0; i > -level; i--)
  1571. 			status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1572. 		if (sd->status.status_point < status_point)
  1573. 			pc_resetstate(sd);
  1574. 		if (sd->status.status_point < status_point)
  1575. 			sd->status.status_point = 0;
  1576. 		else
  1577. 			sd->status.status_point -= status_point;
  1578. 		sd->status.base_level -= (unsigned int)level;
  1579. 		clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1580. 	}
  1581. 	sd->status.base_exp = 0;
  1582. 	clif_updatestatus(sd, SP_STATUSPOINT);
  1583. 	clif_updatestatus(sd, SP_BASELEVEL);
  1584. 	clif_updatestatus(sd, SP_BASEEXP);
  1585. 	clif_updatestatus(sd, SP_NEXTBASEEXP);
  1586. 	status_calc_pc(sd, 0);
  1587. 	if(sd->status.party_id)
  1588. 		party_send_levelup(sd);
  1589. 	return 0;
  1590. }
  1591.  
  1592. /*==========================================
  1593.  *
  1594.  *------------------------------------------*/
  1595. ACMD_FUNC(joblevelup)
  1596. {
  1597. 	int level=0;
  1598. 	nullpo_retr(-1, sd);
  1599.  
  1600. 	level = atoi(message);
  1601.  
  1602. 	if (!message || !*message || !level) {
  1603. 		clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1604. 		return -1;
  1605. 	}
  1606. 	if (level > 0) {
  1607. 		if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1608. 			clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1609. 			return -1;
  1610. 		}
  1611. 		if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1612. 			level = pc_maxjoblv(sd) - sd->status.job_level;
  1613. 		sd->status.job_level += (unsigned int)level;
  1614. 		sd->status.skill_point += level;
  1615. 		clif_misceffect(&sd->bl, 1);
  1616. 		clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1617. 	} else {
  1618. 		if (sd->status.job_level == 1) {
  1619. 			clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1620. 			return -1;
  1621. 		}
  1622. 		level *=-1;
  1623. 		if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1624. 			level = sd->status.job_level-1;
  1625. 		sd->status.job_level -= (unsigned int)level;
  1626. 		if (sd->status.skill_point < level)
  1627. 			pc_resetskill(sd,0);	//Reset skills since we need to substract more points.
  1628. 		if (sd->status.skill_point < level)
  1629. 			sd->status.skill_point = 0;
  1630. 		else
  1631. 			sd->status.skill_point -= level;
  1632. 		clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1633. 	}
  1634. 	sd->status.job_exp = 0;
  1635. 	clif_updatestatus(sd, SP_JOBLEVEL);
  1636. 	clif_updatestatus(sd, SP_JOBEXP);
  1637. 	clif_updatestatus(sd, SP_NEXTJOBEXP);
  1638. 	clif_updatestatus(sd, SP_SKILLPOINT);
  1639. 	status_calc_pc(sd, 0);
  1640.  
  1641. 	return 0;
  1642. }
  1643.  
  1644. /*==========================================
  1645.  * @help
  1646.  *------------------------------------------*/
  1647. ACMD_FUNC(help)
  1648. {
  1649. 	config_setting_t *help;
  1650. 	const char *text = NULL;
  1651. 	const char *command_name = NULL;
  1652. 	char *default_command = "help";
  1653.  
  1654. 	nullpo_retr(-1, sd);
  1655.  
  1656. 	help = config_lookup(&atcommand_config, "help");
  1657. 	if (help == NULL) {
  1658. 		clif_displaymessage(fd, msg_txt(27)); // "Commands help is not available."
  1659. 		return -1;
  1660. 	}
  1661.  
  1662. 	if (!message || !*message) {
  1663. 		command_name = default_command; // If no command_name specified, display help for @help.
  1664. 	} else {
  1665. 		if (*message == atcommand_symbol || *message == charcommand_symbol)
  1666. 			++message;
  1667. 		command_name = atcommand_checkalias(message);
  1668. 	}
  1669.  
  1670. 	if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1671. 		sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
  1672. 		clif_displaymessage(fd, atcmd_output);
  1673. 		atcommand_get_suggestions(sd, command_name, true);
  1674. 		return -1;
  1675. 	}
  1676.  
  1677. 	if (!config_setting_lookup_string(help, command_name, &text)) {
  1678. 		clif_displaymessage(fd, "There is no help for this command_name.");
  1679. 		atcommand_get_suggestions(sd, command_name, true);
  1680. 		return -1;
  1681. 	}
  1682.  
  1683. 	sprintf(atcmd_output, "Help for command %c%s:", atcommand_symbol, command_name);
  1684. 	clif_displaymessage(fd, atcmd_output);
  1685.  
  1686. 	{   // Display aliases
  1687. 		DBIterator* iter;
  1688. 		AtCommandInfo *command_info;
  1689. 		AliasInfo *alias_info = NULL;
  1690. 		StringBuf buf;
  1691. 		bool has_aliases = false;
  1692.  
  1693. 		StringBuf_Init(&buf);
  1694. 		StringBuf_AppendStr(&buf, "Available aliases:");
  1695. 		command_info = get_atcommandinfo_byname(command_name);
  1696. 		iter = db_iterator(atcommand_alias_db);
  1697. 		for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1698. 			if (alias_info->command == command_info) {
  1699. 				StringBuf_Printf(&buf, " %s", alias_info->alias);
  1700. 				has_aliases = true;
  1701. 			}
  1702. 		}
  1703. 		dbi_destroy(iter);
  1704. 		if (has_aliases)
  1705. 			clif_displaymessage(fd, StringBuf_Value(&buf));
  1706. 		StringBuf_Destroy(&buf);
  1707. 	}
  1708.  
  1709. 	// Display help contents
  1710. 	clif_displaymessage(fd, text);
  1711. 	return 0;
  1712. }
  1713.  
  1714. // helper function, used in foreach calls to stop auto-attack timers
  1715. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1716. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1717. {
  1718. 	struct unit_data *ud = unit_bl2ud(bl);
  1719. 	int id = va_arg(ap, int);
  1720. 	if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1721. 	{
  1722. 		unit_stop_attack(bl);
  1723. 		return 1;
  1724. 	}
  1725. 	return 0;
  1726. }
  1727. /*==========================================
  1728.  *
  1729.  *------------------------------------------*/
  1730. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1731. {
  1732. 	TBL_PC* sd = (TBL_PC*)bl;
  1733. 	clif_pvpset(sd, 0, 0, 2);
  1734. 	if (sd->pvp_timer != INVALID_TIMER) {
  1735. 		delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1736. 		sd->pvp_timer = INVALID_TIMER;
  1737. 	}
  1738. 	return 0;
  1739. }
  1740.  
  1741. ACMD_FUNC(pvpoff)
  1742. {
  1743. 	nullpo_retr(-1, sd);
  1744.  
  1745. 	if (!map[sd->bl.m].flag.pvp) {
  1746. 		clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1747. 		return -1;
  1748. 	}
  1749.  
  1750. 	map[sd->bl.m].flag.pvp = 0;
  1751.  
  1752. 	if (!battle_config.pk_mode)
  1753. 		clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1754. 	map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1755. 	map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1756. 	clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1757. 	return 0;
  1758. }
  1759.  
  1760. /*==========================================
  1761.  *
  1762.  *------------------------------------------*/
  1763. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1764. {
  1765. 	TBL_PC* sd = (TBL_PC*)bl;
  1766. 	if (sd->pvp_timer == INVALID_TIMER) {
  1767. 		sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1768. 		sd->pvp_rank = 0;
  1769. 		sd->pvp_lastusers = 0;
  1770. 		sd->pvp_point = 5;
  1771. 		sd->pvp_won = 0;
  1772. 		sd->pvp_lost = 0;
  1773. 	}
  1774. 	return 0;
  1775. }
  1776.  
  1777. ACMD_FUNC(pvpon)
  1778. {
  1779. 	nullpo_retr(-1, sd);
  1780.  
  1781. 	if (map[sd->bl.m].flag.pvp) {
  1782. 		clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1783. 		return -1;
  1784. 	}
  1785.  
  1786. 	map[sd->bl.m].flag.pvp = 1;
  1787.  
  1788. 	if (!battle_config.pk_mode)
  1789. 	{// display pvp circle and rank
  1790. 		clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1791. 		map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1792. 	}
  1793.  
  1794. 	clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1795.  
  1796. 	return 0;
  1797. }
  1798.  
  1799. /*==========================================
  1800.  *
  1801.  *------------------------------------------*/
  1802. ACMD_FUNC(gvgoff)
  1803. {
  1804. 	nullpo_retr(-1, sd);
  1805.  
  1806. 	if (!map[sd->bl.m].flag.gvg) {
  1807. 		clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1808. 		return -1;
  1809. 	}
  1810.  
  1811. 	map[sd->bl.m].flag.gvg = 0;
  1812. 	clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1813. 	map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1814. 	clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1815.  
  1816. 	return 0;
  1817. }
  1818.  
  1819. /*==========================================
  1820.  *
  1821.  *------------------------------------------*/
  1822. ACMD_FUNC(gvgon)
  1823. {
  1824. 	nullpo_retr(-1, sd);
  1825.  
  1826. 	if (map[sd->bl.m].flag.gvg) {
  1827. 		clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1828. 		return -1;
  1829. 	}
  1830.  
  1831. 	map[sd->bl.m].flag.gvg = 1;
  1832. 	clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1833. 	clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1834.  
  1835. 	return 0;
  1836. }
  1837.  
  1838. /*==========================================
  1839.  *
  1840.  *------------------------------------------*/
  1841. ACMD_FUNC(model)
  1842. {
  1843. 	int hair_style = 0, hair_color = 0, cloth_color = 0;
  1844. 	nullpo_retr(-1, sd);
  1845.  
  1846. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  1847.  
  1848. 	if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1849. 		sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1850. 		        MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1851. 		clif_displaymessage(fd, atcmd_output);
  1852. 		return -1;
  1853. 	}
  1854.  
  1855. 	if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1856. 		hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1857. 		cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1858. 			pc_changelook(sd, LOOK_HAIR, hair_style);
  1859. 			pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1860. 			pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1861. 			clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1862. 	} else {
  1863. 		clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1864. 		return -1;
  1865. 	}
  1866.  
  1867. 	return 0;
  1868. }
  1869.  
  1870. /*==========================================
  1871.  * @dye && @ccolor
  1872.  *------------------------------------------*/
  1873. ACMD_FUNC(dye)
  1874. {
  1875. 	int cloth_color = 0;
  1876. 	nullpo_retr(-1, sd);
  1877.  
  1878. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  1879.  
  1880. 	if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1881. 		sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1882. 		clif_displaymessage(fd, atcmd_output);
  1883. 		return -1;
  1884. 	}
  1885.  
  1886. 	if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1887. 		pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1888. 		clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1889. 	} else {
  1890. 		clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1891. 		return -1;
  1892. 	}
  1893.  
  1894. 	return 0;
  1895. }
  1896.  
  1897. /*==========================================
  1898.  * @hairstyle && @hstyle
  1899.  *------------------------------------------*/
  1900. ACMD_FUNC(hair_style)
  1901. {
  1902. 	int hair_style = 0;
  1903. 	nullpo_retr(-1, sd);
  1904.  
  1905. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  1906.  
  1907. 	if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1908. 		sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1909. 		clif_displaymessage(fd, atcmd_output);
  1910. 		return -1;
  1911. 	}
  1912.  
  1913. 	if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1914. 			pc_changelook(sd, LOOK_HAIR, hair_style);
  1915. 			clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1916. 	} else {
  1917. 		clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1918. 		return -1;
  1919. 	}
  1920.  
  1921. 	return 0;
  1922. }
  1923.  
  1924. /*==========================================
  1925.  * @haircolor && @hcolor
  1926.  *------------------------------------------*/
  1927. ACMD_FUNC(hair_color)
  1928. {
  1929. 	int hair_color = 0;
  1930. 	nullpo_retr(-1, sd);
  1931.  
  1932. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  1933.  
  1934. 	if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1935. 		sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1936. 		clif_displaymessage(fd, atcmd_output);
  1937. 		return -1;
  1938. 	}
  1939.  
  1940. 	if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1941. 			pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1942. 			clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1943. 	} else {
  1944. 		clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1945. 		return -1;
  1946. 	}
  1947.  
  1948. 	return 0;
  1949. }
  1950.  
  1951. /*==========================================
  1952.  * @go [city_number or city_name] - Updated by Harbin
  1953.  *------------------------------------------*/
  1954. ACMD_FUNC(go)
  1955. {
  1956. 	int i;
  1957. 	int town;
  1958. 	char map_name[MAP_NAME_LENGTH];
  1959. 	int m;
  1960.  
  1961. 	const struct {
  1962. 		char map[MAP_NAME_LENGTH];
  1963. 		int x, y;
  1964. 	} data[] = {
  1965. 		{ MAP_PRONTERA,    156, 191 }, //  0=Prontera
  1966. 		{ MAP_MORROC,      156,  93 }, //  1=Morroc
  1967. 		{ MAP_GEFFEN,      119,  59 }, //  2=Geffen
  1968. 		{ MAP_PAYON,       162, 233 }, //  3=Payon
  1969. 		{ MAP_ALBERTA,     192, 147 }, //  4=Alberta
  1970. #ifdef RENEWAL
  1971. 		{ MAP_IZLUDE,      128, 146 }, //  5=Izlude (Renewal)
  1972. #else
  1973. 		{ MAP_IZLUDE,      128, 114 }, //  5=Izlude
  1974. #endif
  1975. 		{ MAP_ALDEBARAN,   140, 131 }, //  6=Al de Baran
  1976. 		{ MAP_LUTIE,       147, 134 }, //  7=Lutie
  1977. 		{ MAP_COMODO,      209, 143 }, //  8=Comodo
  1978. 		{ MAP_YUNO,        157,  51 }, //  9=Yuno
  1979. 		{ MAP_AMATSU,      198,  84 }, // 10=Amatsu
  1980. 		{ MAP_GONRYUN,     160, 120 }, // 11=Gonryun
  1981. 		{ MAP_UMBALA,       89, 157 }, // 12=Umbala
  1982. 		{ MAP_NIFLHEIM,     21, 153 }, // 13=Niflheim
  1983. 		{ MAP_LOUYANG,     217,  40 }, // 14=Louyang
  1984. 		{ MAP_NOVICE,       53, 111 }, // 15=Training Grounds
  1985. 		{ MAP_JAIL,         23,  61 }, // 16=Prison
  1986. 		{ MAP_JAWAII,      249, 127 }, // 17=Jawaii
  1987. 		{ MAP_AYOTHAYA,    151, 117 }, // 18=Ayothaya
  1988. 		{ MAP_EINBROCH,     64, 200 }, // 19=Einbroch
  1989. 		{ MAP_LIGHTHALZEN, 158,  92 }, // 20=Lighthalzen
  1990. 		{ MAP_EINBECH,      70,  95 }, // 21=Einbech
  1991. 		{ MAP_HUGEL,        96, 145 }, // 22=Hugel
  1992. 		{ MAP_RACHEL,      130, 110 }, // 23=Rachel
  1993. 		{ MAP_VEINS,       216, 123 }, // 24=Veins
  1994. 		{ MAP_MOSCOVIA,    223, 184 }, // 25=Moscovia
  1995. 		{ MAP_MIDCAMP,     180, 240 }, // 26=Midgard Camp
  1996. 		{ MAP_MANUK,       282, 138 }, // 27=Manuk
  1997. 		{ MAP_SPLENDIDE,   197, 176 }, // 28=Splendide
  1998. 		{ MAP_BRASILIS,    182, 239 }, // 29=Brasilis
  1999. <<<<<<< .mine
  2000. 		{ MAP_DICASTES,   198, 187 }, // 30=El Dicastes
  2001. 		{ MAP_MORA,   44, 151 }, // 31=Mora
  2002. 		{ MAP_DEWATA,   200, 180 }, // 32=Dewata
  2003. 		{ MAP_MALANGDO,   140, 114 }, // 33=Malangdo Island
  2004. 		{ MAP_MALAYA,   232, 222 }, // 34=Malaya Port
  2005. 		{ MAP_ECLAGE,   110, 39 }, // 35=Eclage
  2006. =======
  2007. 		{ MAP_DICASTES,    198, 187 }, // 30=El Dicastes
  2008. 		{ MAP_MORA,         44, 151 }, // 31=Mora
  2009. 		{ MAP_DEWATA,      200, 180 }, // 32=Dewata
  2010. 		{ MAP_MALANGDO,    140, 114 }, // 33=Malangdo Island
  2011. 		{ MAP_MALAYA,      242, 211 }, // 34=Malaya Port
  2012. 		{ MAP_ECLAGE,      110,  39 }, // 35=Eclage
  2013. >>>>>>> .r16590
  2014. 	};
  2015.  
  2016. 	nullpo_retr(-1, sd);
  2017.  
  2018. 	if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  2019. 		clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2020. 		return 0;
  2021. 	}
  2022.  
  2023. 	memset(map_name, '\0', sizeof(map_name));
  2024. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2025.  
  2026. 	// get the number
  2027. 	town = atoi(message);
  2028.  
  2029. 	if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  2030. 	{// no value matched so send the list of locations
  2031. 		const char* text;
  2032.  
  2033. 		// attempt to find the text help string
  2034. 		text = atcommand_help_string( command );
  2035.  
  2036. 		// Invalid location number, or name.
  2037. 		clif_displaymessage(fd, msg_txt(38));
  2038.  
  2039. 		if( text )
  2040. 		{// send the text to the client
  2041. 			clif_displaymessage( fd, text );
  2042. 		}
  2043.  
  2044. 		return -1;
  2045. 	}
  2046.  
  2047. 	// get possible name of the city
  2048. 	map_name[MAP_NAME_LENGTH-1] = '\0';
  2049. 	for (i = 0; map_name[i]; i++)
  2050. 		map_name[i] = TOLOWER(map_name[i]);
  2051. 	// try to identify the map name
  2052. 	if (strncmp(map_name, "prontera", 3) == 0) {
  2053. 		town = 0;
  2054. 	} else if (strncmp(map_name, "morocc", 3) == 0) {
  2055. 		town = 1;
  2056. 	} else if (strncmp(map_name, "geffen", 3) == 0) {
  2057. 		town = 2;
  2058. 	} else if (strncmp(map_name, "payon", 3) == 0 ||
  2059. 	           strncmp(map_name, "paion", 3) == 0) {
  2060. 		town = 3;
  2061. 	} else if (strncmp(map_name, "alberta", 3) == 0) {
  2062. 		town = 4;
  2063. 	} else if (strncmp(map_name, "izlude", 3) == 0 ||
  2064. 	           strncmp(map_name, "islude", 3) == 0) {
  2065. 		town = 5;
  2066. 	} else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2067. 	           strcmp(map_name,  "al") == 0) {
  2068. 		town = 6;
  2069. 	} else if (strncmp(map_name, "lutie", 3) == 0 ||
  2070. 	           strcmp(map_name,  "christmas") == 0 ||
  2071. 	           strncmp(map_name, "xmas", 3) == 0 ||
  2072. 	           strncmp(map_name, "x-mas", 3) == 0) {
  2073. 		town = 7;
  2074. 	} else if (strncmp(map_name, "comodo", 3) == 0) {
  2075. 		town = 8;
  2076. 	} else if (strncmp(map_name, "yuno", 3) == 0) {
  2077. 		town = 9;
  2078. 	} else if (strncmp(map_name, "amatsu", 3) == 0) {
  2079. 		town = 10;
  2080. 	} else if (strncmp(map_name, "gonryun", 3) == 0) {
  2081. 		town = 11;
  2082. 	} else if (strncmp(map_name, "umbala", 3) == 0) {
  2083. 		town = 12;
  2084. 	} else if (strncmp(map_name, "niflheim", 3) == 0) {
  2085. 		town = 13;
  2086. 	} else if (strncmp(map_name, "louyang", 3) == 0) {
  2087. 		town = 14;
  2088. 	} else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2089. 	           strncmp(map_name, "startpoint", 3) == 0 ||
  2090. 	           strncmp(map_name, "begining", 3) == 0) {
  2091. 		town = 15;
  2092. 	} else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2093. 	           strncmp(map_name, "prison", 3) == 0 ||
  2094. 	           strncmp(map_name, "jails", 3) == 0) {
  2095. 		town = 16;
  2096. 	} else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2097. 	           strncmp(map_name, "jawai", 3) == 0) {
  2098. 		town = 17;
  2099. 	} else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2100. 	           strncmp(map_name, "ayotaya", 3) == 0) {
  2101. 		town = 18;
  2102. 	} else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2103. 	           strncmp(map_name, "ainbroch", 5) == 0) {
  2104. 		town = 19;
  2105. 	} else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2106. 		town = 20;
  2107. 	} else if (strncmp(map_name, "einbech", 3) == 0) {
  2108. 		town = 21;
  2109. 	} else if (strncmp(map_name, "hugel", 3) == 0) {
  2110. 		town = 22;
  2111. 	} else if (strncmp(map_name, "rachel", 3) == 0) {
  2112. 		town = 23;
  2113. 	} else if (strncmp(map_name, "veins", 3) == 0) {
  2114. 		town = 24;
  2115. 	} else if (strncmp(map_name, "moscovia", 3) == 0) {
  2116. 		town = 25;
  2117. 	} else if (strncmp(map_name, "mid_camp", 3) == 0) {
  2118. 		town = 26;
  2119. 	} else if (strncmp(map_name, "manuk", 3) == 0) {
  2120. 		town = 27;
  2121. 	} else if (strncmp(map_name, "splendide", 3) == 0) {
  2122. 		town = 28;
  2123. 	} else if (strncmp(map_name, "brasilis", 3) == 0) {
  2124. 		town = 29;
  2125. 	} else if (strncmp(map_name, "dicastes01", 3) == 0) {
  2126. 		town = 30;
  2127. 	} else if (strncmp(map_name, "mora", 3) == 0) {
  2128. 		town = 31;
  2129. 	} else if (strncmp(map_name, "dewata", 3) == 0) {
  2130. 		town = 32;
  2131. 	} else if (strncmp(map_name, "malangdo", 3) == 0) {
  2132. 		town = 33;
  2133. 	} else if (strncmp(map_name, "malaya", 3) == 0) {
  2134. 		town = 34;
  2135. 	} else if (strncmp(map_name, "eclage", 3) == 0) {
  2136. 		town = 35;
  2137. 	}
  2138.  
  2139. 	if (town >= 0 && town < ARRAYLENGTH(data))
  2140. 	{
  2141. 		m = map_mapname2mapid(data[town].map);
  2142. 		if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2143. 			clif_displaymessage(fd, msg_txt(247));
  2144. 			return -1;
  2145. 		}
  2146. 		if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2147. 			clif_displaymessage(fd, msg_txt(248));
  2148. 			return -1;
  2149. 		}
  2150. 		if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2151. 			clif_displaymessage(fd, msg_txt(0)); // Warped.
  2152. 		} else {
  2153. 			clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2154. 			return -1;
  2155. 		}
  2156. 	} else { // if you arrive here, you have an error in town variable when reading of names
  2157. 		clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2158. 		return -1;
  2159. 	}
  2160.  
  2161. 	return 0;
  2162. }
  2163.  
  2164. /*==========================================
  2165.  *
  2166.  *------------------------------------------*/
  2167. ACMD_FUNC(monster)
  2168. {
  2169. 	char name[NAME_LENGTH];
  2170. 	char monster[NAME_LENGTH];
  2171. 	char eventname[EVENT_NAME_LENGTH] = "";
  2172. 	int mob_id;
  2173. 	int number = 0;
  2174. 	int count;
  2175. 	int i, k, range;
  2176. 	short mx, my;
  2177. 	nullpo_retr(-1, sd);
  2178.  
  2179. 	memset(name, '\0', sizeof(name));
  2180. 	memset(monster, '\0', sizeof(monster));
  2181. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2182.  
  2183. 	if (!message || !*message) {
  2184. 			clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2185. 			return -1;
  2186. 	}
  2187. 	if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2188. 		sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2189. 		//All data can be left as it is.
  2190. 	} else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2191. 		//Here, it is possible name was not given and we are using monster for it.
  2192. 		if (count < 3) //Blank mob's name.
  2193. 			name[0] = '\0';
  2194. 	} else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2195. 		//All data can be left as it is.
  2196. 	} else if (sscanf(message, "%23s", monster) > 0) {
  2197. 		//As before, name may be already filled.
  2198. 		name[0] = '\0';
  2199. 	} else {
  2200. 		clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2201. 		return -1;
  2202. 	}
  2203.  
  2204. 	if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2205. 		mob_id = mobdb_checkid(atoi(monster));
  2206.  
  2207. 	if (mob_id == 0) {
  2208. 		clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2209. 		return -1;
  2210. 	}
  2211.  
  2212. 	if (mob_id == MOBID_EMPERIUM) {
  2213. 		clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2214. 		return -1;
  2215. 	}
  2216.  
  2217. 	if (number <= 0)
  2218. 		number = 1;
  2219.  
  2220. 	if( !name[0] )
  2221. 		strcpy(name, "--ja--");
  2222.  
  2223. 	// 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
  2224. 	if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2225. 		number = battle_config.atc_spawn_quantity_limit;
  2226.  
  2227. 	if (strcmp(command+1, "monstersmall") == 0)
  2228. 		strcpy(eventname, "2");
  2229. 	else if (strcmp(command+1, "monsterbig") == 0)
  2230. 		strcpy(eventname, "4");
  2231.  
  2232. 	if (battle_config.etc_log)
  2233. 		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);
  2234.  
  2235. 	count = 0;
  2236. 	range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2237. 	for (i = 0; i < number; i++) {
  2238. 		map_search_freecell(&sd->bl, 0, &mx,  &my, range, range, 0);
  2239. 		k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname);
  2240. 		count += (k != 0) ? 1 : 0;
  2241. 	}
  2242.  
  2243. 	if (count != 0)
  2244. 		if (number == count)
  2245. 			clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2246. 		else {
  2247. 			sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2248. 			clif_displaymessage(fd, atcmd_output);
  2249. 		}
  2250. 	else {
  2251. 		clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2252. 		return -1;
  2253. 	}
  2254.  
  2255. 	return 0;
  2256. }
  2257.  
  2258. /*==========================================
  2259.  *
  2260.  *------------------------------------------*/
  2261. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2262. {
  2263. 	struct mob_data *md;
  2264. 	int flag;
  2265.  
  2266. 	nullpo_ret(md=(struct mob_data *)bl);
  2267. 	flag = va_arg(ap, int);
  2268.  
  2269. 	if (md->guardian_data)
  2270. 		return 0; //Do not touch WoE mobs!
  2271.  
  2272. 	if (flag)
  2273. 		status_zap(bl,md->status.hp, 0);
  2274. 	else
  2275. 		status_kill(bl);
  2276. 	return 1;
  2277. }
  2278.  
  2279. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2280. {
  2281. 	int map_id;
  2282. 	char map_name[MAP_NAME_LENGTH_EXT];
  2283.  
  2284. 	if (!sd) return;
  2285.  
  2286. 	memset(map_name, '\0', sizeof(map_name));
  2287.  
  2288. 	if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2289. 		map_id = sd->bl.m;
  2290. 	else {
  2291. 		if ((map_id = map_mapname2mapid(map_name)) < 0)
  2292. 			map_id = sd->bl.m;
  2293. 	}
  2294.  
  2295. 	map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2296.  
  2297. 	clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2298.  
  2299. 	return;
  2300. }
  2301.  
  2302. ACMD_FUNC(killmonster)
  2303. {
  2304. 	atcommand_killmonster_sub(fd, sd, message, 1);
  2305. 	return 0;
  2306. }
  2307.  
  2308. /*==========================================
  2309.  *
  2310.  *------------------------------------------*/
  2311. ACMD_FUNC(killmonster2)
  2312. {
  2313. 	atcommand_killmonster_sub(fd, sd, message, 0);
  2314. 	return 0;
  2315. }
  2316.  
  2317. /*==========================================
  2318.  *
  2319.  *------------------------------------------*/
  2320. ACMD_FUNC(refine)
  2321. {
  2322. 	int i,j, position = 0, refine = 0, current_position, final_refine;
  2323. 	int count;
  2324. 	nullpo_retr(-1, sd);
  2325.  
  2326. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2327.  
  2328. 	if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2329. 		clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2330. 		sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2331. 		clif_displaymessage(fd, atcmd_output);
  2332. 		sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2333. 		clif_displaymessage(fd, atcmd_output);
  2334. 		sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2335. 		clif_displaymessage(fd, atcmd_output);
  2336. 		sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2337. 		clif_displaymessage(fd, atcmd_output);
  2338. 		sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2339. 		clif_displaymessage(fd, atcmd_output);
  2340. 		sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2341. 		clif_displaymessage(fd, atcmd_output);
  2342. 		sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2343. 		clif_displaymessage(fd, atcmd_output);
  2344. 		sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2345. 		clif_displaymessage(fd, atcmd_output);
  2346. 		sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2347. 		clif_displaymessage(fd, atcmd_output);
  2348. 		sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2349. 		clif_displaymessage(fd, atcmd_output);
  2350. 		return -1;
  2351. 	}
  2352.  
  2353. 	refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2354.  
  2355. 	count = 0;
  2356. 	for (j = 0; j < EQI_MAX-1; j++) {
  2357. 		if ((i = sd->equip_index[j]) < 0)
  2358. 			continue;
  2359. 		if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2360. 			continue;
  2361. 		if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2362. 			continue;
  2363. 		if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2364. 			continue;
  2365.  
  2366. 		if(position && !(sd->status.inventory[i].equip & position))
  2367. 			continue;
  2368.  
  2369. 		final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2370. 		if (sd->status.inventory[i].refine != final_refine) {
  2371. 			sd->status.inventory[i].refine = final_refine;
  2372. 			current_position = sd->status.inventory[i].equip;
  2373. 			pc_unequipitem(sd, i, 3);
  2374. 			clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2375. 			clif_delitem(sd, i, 1, 3);
  2376. 			clif_additem(sd, i, 1, 0);
  2377. 			pc_equipitem(sd, i, current_position);
  2378. 			clif_misceffect(&sd->bl, 3);
  2379. 			count++;
  2380. 		}
  2381. 	}
  2382.  
  2383. 	if (count == 0)
  2384. 		clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2385. 	else if (count == 1)
  2386. 		clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2387. 	else {
  2388. 		sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2389. 		clif_displaymessage(fd, atcmd_output);
  2390. 	}
  2391.  
  2392. 	return 0;
  2393. }
  2394.  
  2395. /*==========================================
  2396.  *
  2397.  *------------------------------------------*/
  2398. ACMD_FUNC(produce)
  2399. {
  2400. 	char item_name[100];
  2401. 	int item_id, attribute = 0, star = 0;
  2402. 	int flag = 0;
  2403. 	struct item_data *item_data;
  2404. 	struct item tmp_item;
  2405. 	nullpo_retr(-1, sd);
  2406.  
  2407. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2408. 	memset(item_name, '\0', sizeof(item_name));
  2409.  
  2410. 	if (!message || !*message || (
  2411. 		sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2412. 		sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2413. 	)) {
  2414. 		clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2415. 		return -1;
  2416. 	}
  2417.  
  2418. 	item_id = 0;
  2419. 	if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2420. 	    (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2421. 	{
  2422. 		clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2423. 		return -1;
  2424. 	}
  2425. 	item_id = item_data->nameid;
  2426. 	if (itemdb_isequip2(item_data)) {
  2427. 		if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2428. 			attribute = ATTRIBUTE_NORMAL;
  2429. 		if (star < MIN_STAR || star > MAX_STAR)
  2430. 			star = 0;
  2431. 		memset(&tmp_item, 0, sizeof tmp_item);
  2432. 		tmp_item.nameid = item_id;
  2433. 		tmp_item.amount = 1;
  2434. 		tmp_item.identify = 1;
  2435. 		tmp_item.card[0] = CARD0_FORGE;
  2436. 		tmp_item.card[1] = item_data->type==IT_WEAPON?
  2437. 			((star*5) << 8) + attribute:0;
  2438. 		tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2439. 		tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2440. 		clif_produceeffect(sd, 0, item_id);
  2441. 		clif_misceffect(&sd->bl, 3);
  2442.  
  2443. 		if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2444. 			clif_additem(sd, 0, 0, flag);
  2445. 	} else {
  2446. 		sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2447. 		clif_displaymessage(fd, atcmd_output);
  2448. 		return -1;
  2449. 	}
  2450.  
  2451. 	return 0;
  2452. }
  2453.  
  2454. /*==========================================
  2455.  *
  2456.  *------------------------------------------*/
  2457. ACMD_FUNC(memo)
  2458. {
  2459. 	int position = 0;
  2460. 	nullpo_retr(-1, sd);
  2461.  
  2462. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2463.  
  2464. 	if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2465. 	{
  2466. 		int i;
  2467. 		clif_displaymessage(sd->fd,  msg_txt(668));
  2468. 		for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2469. 		{
  2470. 			if( sd->status.memo_point[i].map )
  2471. 				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);
  2472. 			else
  2473. 				sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2474. 			clif_displaymessage(sd->fd, atcmd_output);
  2475.  		}
  2476. 		return 0;
  2477.  	}
  2478.  
  2479. 	if( position < 0 || position >= MAX_MEMOPOINTS )
  2480. 	{
  2481. 		sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2482. 		clif_displaymessage(fd, atcmd_output);
  2483. 		return -1;
  2484. 	}
  2485.  
  2486. 	pc_memo(sd, position);
  2487. 	return 0;
  2488. }
  2489.  
  2490. /*==========================================
  2491.  *
  2492.  *------------------------------------------*/
  2493. ACMD_FUNC(gat)
  2494. {
  2495. 	int y;
  2496. 	nullpo_retr(-1, sd);
  2497.  
  2498. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2499.  
  2500. 	for (y = 2; y >= -2; y--) {
  2501. 		sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2502. 			map[sd->bl.m].name,   sd->bl.x - 2, sd->bl.y + y,
  2503.  			map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2504.  			map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2505.  			map_getcell(sd->bl.m, sd->bl.x,     sd->bl.y + y, CELL_GETTYPE),
  2506.  			map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2507.  			map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2508.  
  2509. 		clif_displaymessage(fd, atcmd_output);
  2510. 	}
  2511.  
  2512. 	return 0;
  2513. }
  2514.  
  2515. /*==========================================
  2516.  *
  2517.  *------------------------------------------*/
  2518. ACMD_FUNC(displaystatus)
  2519. {
  2520. 	int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2521. 	nullpo_retr(-1, sd);
  2522.  
  2523. 	if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2524. 		clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).");
  2525. 		return -1;
  2526. 	}
  2527. 	if (i < 2) flag = 1;
  2528. 	if (i < 3) tick = 0;
  2529.  
  2530. 	clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2531.  
  2532. 	return 0;
  2533. }
  2534.  
  2535. /*==========================================
  2536.  * @stpoint (Rewritten by [Yor])
  2537.  *------------------------------------------*/
  2538. ACMD_FUNC(statuspoint)
  2539. {
  2540. 	int point;
  2541. 	unsigned int new_status_point;
  2542.  
  2543. 	if (!message || !*message || (point = atoi(message)) == 0) {
  2544. 		clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2545. 		return -1;
  2546. 	}
  2547.  
  2548. 	if(point < 0)
  2549. 	{
  2550. 		if(sd->status.status_point < (unsigned int)(-point))
  2551. 		{
  2552. 			new_status_point = 0;
  2553. 		}
  2554. 		else
  2555. 		{
  2556. 			new_status_point = sd->status.status_point + point;
  2557. 		}
  2558. 	}
  2559. 	else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2560. 	{
  2561. 		new_status_point = UINT_MAX;
  2562. 	}
  2563. 	else
  2564. 	{
  2565. 		new_status_point = sd->status.status_point + point;
  2566. 	}
  2567.  
  2568. 	if (new_status_point != sd->status.status_point) {
  2569. 		sd->status.status_point = new_status_point;
  2570. 		clif_updatestatus(sd, SP_STATUSPOINT);
  2571. 		clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2572. 	} else {
  2573. 		if (point < 0)
  2574. 			clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2575. 		else
  2576. 			clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2577. 		return -1;
  2578. 	}
  2579.  
  2580. 	return 0;
  2581. }
  2582.  
  2583. /*==========================================
  2584.  * @skpoint (Rewritten by [Yor])
  2585.  *------------------------------------------*/
  2586. ACMD_FUNC(skillpoint)
  2587. {
  2588. 	int point;
  2589. 	unsigned int new_skill_point;
  2590. 	nullpo_retr(-1, sd);
  2591.  
  2592. 	if (!message || !*message || (point = atoi(message)) == 0) {
  2593. 		clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2594. 		return -1;
  2595. 	}
  2596.  
  2597. 	if(point < 0)
  2598. 	{
  2599. 		if(sd->status.skill_point < (unsigned int)(-point))
  2600. 		{
  2601. 			new_skill_point = 0;
  2602. 		}
  2603. 		else
  2604. 		{
  2605. 			new_skill_point = sd->status.skill_point + point;
  2606. 		}
  2607. 	}
  2608. 	else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2609. 	{
  2610. 		new_skill_point = UINT_MAX;
  2611. 	}
  2612. 	else
  2613. 	{
  2614. 		new_skill_point = sd->status.skill_point + point;
  2615. 	}
  2616.  
  2617. 	if (new_skill_point != sd->status.skill_point) {
  2618. 		sd->status.skill_point = new_skill_point;
  2619. 		clif_updatestatus(sd, SP_SKILLPOINT);
  2620. 		clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2621. 	} else {
  2622. 		if (point < 0)
  2623. 			clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2624. 		else
  2625. 			clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2626. 		return -1;
  2627. 	}
  2628.  
  2629. 	return 0;
  2630. }
  2631.  
  2632. /*==========================================
  2633.  * @zeny (Rewritten by [Yor])
  2634.  *------------------------------------------*/
  2635. ACMD_FUNC(zeny)
  2636. {
  2637. 	int zeny, new_zeny;
  2638. 	nullpo_retr(-1, sd);
  2639.  
  2640. 	if (!message || !*message || (zeny = atoi(message)) == 0) {
  2641. 		clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2642. 		return -1;
  2643. 	}
  2644.  
  2645. 	new_zeny = sd->status.zeny + zeny;
  2646. 	if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2647. 		new_zeny = MAX_ZENY;
  2648. 	else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2649. 		new_zeny = 0;
  2650.  
  2651. 	if (new_zeny != sd->status.zeny) {
  2652. 		sd->status.zeny = new_zeny;
  2653. 		clif_updatestatus(sd, SP_ZENY);
  2654. 		clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2655. 	} else {
  2656. 		if (zeny < 0)
  2657. 			clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2658. 		else
  2659. 			clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2660. 		return -1;
  2661. 	}
  2662.  
  2663. 	return 0;
  2664. }
  2665.  
  2666. /*==========================================
  2667.  *
  2668.  *------------------------------------------*/
  2669. ACMD_FUNC(param)
  2670. {
  2671. 	int i, value = 0, new_value, max;
  2672. 	const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2673. 	short* status[6];
  2674.  	//we don't use direct initialization because it isn't part of the c standard.
  2675. 	nullpo_retr(-1, sd);
  2676.  
  2677. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  2678.  
  2679. 	if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2680. 		sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2681. 		clif_displaymessage(fd, atcmd_output);
  2682. 		return -1;
  2683. 	}
  2684.  
  2685. 	ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2686.  
  2687. 	if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2688. 		sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2689. 		clif_displaymessage(fd, atcmd_output);
  2690. 		return -1;
  2691. 	}
  2692.  
  2693. 	status[0] = &sd->status.str;
  2694. 	status[1] = &sd->status.agi;
  2695. 	status[2] = &sd->status.vit;
  2696. 	status[3] = &sd->status.int_;
  2697. 	status[4] = &sd->status.dex;
  2698. 	status[5] = &sd->status.luk;
  2699.  
  2700. 	if( battle_config.atcommand_max_stat_bypass )
  2701. 		max = SHRT_MAX;
  2702. 	else
  2703. 		max = pc_maxparameter(sd);
  2704.  
  2705. 	if(value < 0 && *status[i] <= -value) {
  2706. 		new_value = 1;
  2707. 	} else if(max - *status[i] < value) {
  2708. 		new_value = max;
  2709. 	} else {
  2710. 		new_value = *status[i] + value;
  2711. 	}
  2712.  
  2713. 	if (new_value != *status[i]) {
  2714. 		*status[i] = new_value;
  2715. 		clif_updatestatus(sd, SP_STR + i);
  2716. 		clif_updatestatus(sd, SP_USTR + i);
  2717. 		status_calc_pc(sd, 0);
  2718. 		clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2719. 	} else {
  2720. 		if (value < 0)
  2721. 			clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2722. 		else
  2723. 			clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2724. 		return -1;
  2725. 	}
  2726.  
  2727. 	return 0;
  2728. }
  2729.  
  2730. /*==========================================
  2731.  * Stat all by fritz (rewritten by [Yor])
  2732.  *------------------------------------------*/
  2733. ACMD_FUNC(stat_all)
  2734. {
  2735. 	int index, count, value, max, new_value;
  2736. 	short* status[6];
  2737.  	//we don't use direct initialization because it isn't part of the c standard.
  2738. 	nullpo_retr(-1, sd);
  2739.  
  2740. 	status[0] = &sd->status.str;
  2741. 	status[1] = &sd->status.agi;
  2742. 	status[2] = &sd->status.vit;
  2743. 	status[3] = &sd->status.int_;
  2744. 	status[4] = &sd->status.dex;
  2745. 	status[5] = &sd->status.luk;
  2746.  
  2747. 	if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2748. 		value = pc_maxparameter(sd);
  2749. 		max = pc_maxparameter(sd);
  2750. 	} else {
  2751. 		if( battle_config.atcommand_max_stat_bypass )
  2752. 			max = SHRT_MAX;
  2753. 		else
  2754. 			max = pc_maxparameter(sd);
  2755. 	}
  2756.  
  2757. 	count = 0;
  2758. 	for (index = 0; index < ARRAYLENGTH(status); index++) {
  2759.  
  2760. 		if (value > 0 && *status[index] > max - value)
  2761. 			new_value = max;
  2762. 		else if (value < 0 && *status[index] <= -value)
  2763. 			new_value = 1;
  2764. 		else
  2765. 			new_value = *status[index] +value;
  2766.  
  2767. 		if (new_value != (int)*status[index]) {
  2768. 			*status[index] = new_value;
  2769. 			clif_updatestatus(sd, SP_STR + index);
  2770. 			clif_updatestatus(sd, SP_USTR + index);
  2771. 			count++;
  2772. 		}
  2773. 	}
  2774.  
  2775. 	if (count > 0) { // if at least 1 stat modified
  2776. 		status_calc_pc(sd, 0);
  2777. 		clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2778. 	} else {
  2779. 		if (value < 0)
  2780. 			clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2781. 		else
  2782. 			clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2783. 		return -1;
  2784. 	}
  2785.  
  2786. 	return 0;
  2787. }
  2788.  
  2789. /*==========================================
  2790.  *
  2791.  *------------------------------------------*/
  2792. ACMD_FUNC(guildlevelup)
  2793. {
  2794. 	int level = 0;
  2795. 	short added_level;
  2796. 	struct guild *guild_info;
  2797. 	nullpo_retr(-1, sd);
  2798.  
  2799. 	if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2800. 		clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2801. 		return -1;
  2802. 	}
  2803.  
  2804. 	if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2805. 		clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2806. 		return -1;
  2807. 	}
  2808. 	//if (strcmp(sd->status.name, guild_info->master) != 0) {
  2809. 	//	clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2810. 	//	return -1;
  2811. 	//}
  2812.  
  2813. 	added_level = (short)level;
  2814. 	if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2815. 		added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2816. 	else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2817. 		added_level = 1 - guild_info->guild_lv;
  2818.  
  2819. 	if (added_level != 0) {
  2820. 		intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2821. 		clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2822. 	} else {
  2823. 		clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2824. 		return -1;
  2825. 	}
  2826.  
  2827. 	return 0;
  2828. }
  2829.  
  2830. /*==========================================
  2831.  *
  2832.  *------------------------------------------*/
  2833. ACMD_FUNC(makeegg)
  2834. {
  2835. 	struct item_data *item_data;
  2836. 	int id, pet_id;
  2837. 	nullpo_retr(-1, sd);
  2838.  
  2839. 	if (!message || !*message) {
  2840. 		clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2841. 		return -1;
  2842. 	}
  2843.  
  2844. 	if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2845. 		id = item_data->nameid;
  2846. 	else
  2847. 	if ((id = mobdb_searchname(message)) != 0) // for monster name
  2848. 		;
  2849. 	else
  2850. 		id = atoi(message);
  2851.  
  2852. 	pet_id = search_petDB_index(id, PET_CLASS);
  2853. 	if (pet_id < 0)
  2854. 		pet_id = search_petDB_index(id, PET_EGG);
  2855. 	if (pet_id >= 0) {
  2856. 		sd->catch_target_class = pet_db[pet_id].class_;
  2857. 		intif_create_pet(
  2858. 			sd->status.account_id, sd->status.char_id,
  2859. 			(short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2860. 			(short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2861. 			100, 0, 1, pet_db[pet_id].jname);
  2862. 	} else {
  2863. 		clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2864. 		return -1;
  2865. 	}
  2866.  
  2867. 	return 0;
  2868. }
  2869.  
  2870. /*==========================================
  2871.  *
  2872.  *------------------------------------------*/
  2873. ACMD_FUNC(hatch)
  2874. {
  2875. 	nullpo_retr(-1, sd);
  2876. 	if (sd->status.pet_id <= 0)
  2877. 		clif_sendegg(sd);
  2878. 	else {
  2879. 		clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2880. 		return -1;
  2881. 	}
  2882.  
  2883. 	return 0;
  2884. }
  2885.  
  2886. /*==========================================
  2887.  *
  2888.  *------------------------------------------*/
  2889. ACMD_FUNC(petfriendly)
  2890. {
  2891. 	int friendly;
  2892. 	struct pet_data *pd;
  2893. 	nullpo_retr(-1, sd);
  2894.  
  2895. 	if (!message || !*message || (friendly = atoi(message)) < 0) {
  2896. 		clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2897. 		return -1;
  2898. 	}
  2899.  
  2900. 	pd = sd->pd;
  2901. 	if (!pd) {
  2902. 		clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2903. 		return -1;
  2904. 	}
  2905.  
  2906. 	if (friendly < 0 || friendly > 1000)
  2907. 	{
  2908. 		clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2909. 		return -1;
  2910. 	}
  2911.  
  2912. 	if (friendly == pd->pet.intimate) {
  2913. 		clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2914. 		return -1;
  2915. 	}
  2916.  
  2917. 	pet_set_intimate(pd, friendly);
  2918. 	clif_send_petstatus(sd);
  2919. 	clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2920. 	return 0;
  2921. }
  2922.  
  2923. /*==========================================
  2924.  *
  2925.  *------------------------------------------*/
  2926. ACMD_FUNC(pethungry)
  2927. {
  2928. 	int hungry;
  2929. 	struct pet_data *pd;
  2930. 	nullpo_retr(-1, sd);
  2931.  
  2932. 	if (!message || !*message || (hungry = atoi(message)) < 0) {
  2933. 		clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2934. 		return -1;
  2935. 	}
  2936.  
  2937. 	pd = sd->pd;
  2938. 	if (!sd->status.pet_id || !pd) {
  2939. 		clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2940. 		return -1;
  2941. 	}
  2942. 	if (hungry < 0 || hungry > 100) {
  2943. 		clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2944. 		return -1;
  2945. 	}
  2946. 	if (hungry == pd->pet.hungry) {
  2947. 		clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2948. 		return -1;
  2949. 	}
  2950.  
  2951. 	pd->pet.hungry = hungry;
  2952. 	clif_send_petstatus(sd);
  2953. 	clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2954.  
  2955. 	return 0;
  2956. }
  2957.  
  2958. /*==========================================
  2959.  *
  2960.  *------------------------------------------*/
  2961. ACMD_FUNC(petrename)
  2962. {
  2963. 	struct pet_data *pd;
  2964. 	nullpo_retr(-1, sd);
  2965. 	if (!sd->status.pet_id || !sd->pd) {
  2966. 		clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2967. 		return -1;
  2968. 	}
  2969. 	pd = sd->pd;
  2970. 	if (!pd->pet.rename_flag) {
  2971. 		clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2972. 		return -1;
  2973. 	}
  2974.  
  2975. 	pd->pet.rename_flag = 0;
  2976. 	intif_save_petdata(sd->status.account_id, &pd->pet);
  2977. 	clif_send_petstatus(sd);
  2978. 	clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2979.  
  2980. 	return 0;
  2981. }
  2982.  
  2983. /*==========================================
  2984.  *
  2985.  *------------------------------------------*/
  2986. ACMD_FUNC(recall) {
  2987. 	struct map_session_data *pl_sd = NULL;
  2988.  
  2989. 	nullpo_retr(-1, sd);
  2990.  
  2991. 	if (!message || !*message) {
  2992. 		clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2993. 		return -1;
  2994. 	}
  2995.  
  2996. 	if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2997. 	{
  2998. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2999. 		return -1;
  3000. 	}
  3001.  
  3002. 	if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3003. 	{
  3004. 		clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3005. 		return -1;
  3006. 	}
  3007.  
  3008. 	if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3009. 		clif_displaymessage(fd, "You are not authorised to warp someone to your actual map.");
  3010. 		return -1;
  3011. 	}
  3012. 	if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3013. 		clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3014. 		return -1;
  3015. 	}
  3016. 	pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3017. 	sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3018. 	clif_displaymessage(fd, atcmd_output);
  3019.  
  3020. 	return 0;
  3021. }
  3022.  
  3023. /*==========================================
  3024.  * charblock command (usage: charblock <player_name>)
  3025.  * This command do a definitiv ban on a player
  3026.  *------------------------------------------*/
  3027. ACMD_FUNC(char_block)
  3028. {
  3029. 	nullpo_retr(-1, sd);
  3030.  
  3031. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3032.  
  3033. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3034. 		clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3035. 		return -1;
  3036. 	}
  3037.  
  3038. 	chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3039. 	clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3040.  
  3041. 	return 0;
  3042. }
  3043.  
  3044. /*==========================================
  3045.  * charban command (usage: charban <time> <player_name>)
  3046.  * This command do a limited ban on a player
  3047.  * Time is done as follows:
  3048.  *   Adjustment value (-1, 1, +1, etc...)
  3049.  *   Modified element:
  3050.  *     a or y: year
  3051.  *     m:  month
  3052.  *     j or d: day
  3053.  *     h:  hour
  3054.  *     mn: minute
  3055.  *     s:  second
  3056.  * <example> @ban +1m-2mn1s-6y test_player
  3057.  *           this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3058.  *------------------------------------------*/
  3059. ACMD_FUNC(char_ban)
  3060. {
  3061. 	char * modif_p;
  3062. 	int year, month, day, hour, minute, second, value;
  3063. 	time_t timestamp;
  3064. 	struct tm *tmtime;
  3065. 	nullpo_retr(-1, sd);
  3066.  
  3067. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  3068. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3069.  
  3070. 	if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3071. 		clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3072. 		return -1;
  3073. 	}
  3074.  
  3075. 	atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3076.  
  3077. 	modif_p = atcmd_output;
  3078. 	year = month = day = hour = minute = second = 0;
  3079. 	while (modif_p[0] != '\0') {
  3080. 		value = atoi(modif_p);
  3081. 		if (value == 0)
  3082. 			modif_p++;
  3083. 		else {
  3084. 			if (modif_p[0] == '-' || modif_p[0] == '+')
  3085. 				modif_p++;
  3086. 			while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3087. 				modif_p++;
  3088. 			if (modif_p[0] == 's') {
  3089. 				second = value;
  3090. 				modif_p++;
  3091. 			} else if (modif_p[0] == 'n') {
  3092. 				minute = value;
  3093. 				modif_p++;
  3094. 			} else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3095. 				minute = value;
  3096. 				modif_p = modif_p + 2;
  3097. 			} else if (modif_p[0] == 'h') {
  3098. 				hour = value;
  3099. 				modif_p++;
  3100. 			} else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3101. 				day = value;
  3102. 				modif_p++;
  3103. 			} else if (modif_p[0] == 'm') {
  3104. 				month = value;
  3105. 				modif_p++;
  3106. 			} else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3107. 				year = value;
  3108. 				modif_p++;
  3109. 			} else if (modif_p[0] != '\0') {
  3110. 				modif_p++;
  3111. 			}
  3112. 		}
  3113. 	}
  3114. 	if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3115. 		clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3116. 		return -1;
  3117. 	}
  3118. 	/**
  3119. 	 * We now check if you can adjust the ban to negative (and if this is the case)
  3120. 	 **/
  3121. 	timestamp = time(NULL);
  3122. 	tmtime = localtime(&timestamp);
  3123. 	tmtime->tm_year = tmtime->tm_year + year;
  3124. 	tmtime->tm_mon  = tmtime->tm_mon + month;
  3125. 	tmtime->tm_mday = tmtime->tm_mday + day;
  3126. 	tmtime->tm_hour = tmtime->tm_hour + hour;
  3127. 	tmtime->tm_min  = tmtime->tm_min + minute;
  3128. 	tmtime->tm_sec  = tmtime->tm_sec + second;
  3129. 	timestamp = mktime(tmtime);
  3130. 	if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  3131. 		clif_displaymessage(fd,"You are not allowed to reduce the length of a ban");
  3132. 		return -1;
  3133. 	}
  3134.  
  3135. 	chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3136. 	clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3137.  
  3138. 	return 0;
  3139. }
  3140.  
  3141. /*==========================================
  3142.  * charunblock command (usage: charunblock <player_name>)
  3143.  *------------------------------------------*/
  3144. ACMD_FUNC(char_unblock)
  3145. {
  3146. 	nullpo_retr(-1, sd);
  3147.  
  3148. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3149.  
  3150. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3151. 		clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3152. 		return -1;
  3153. 	}
  3154.  
  3155. 	// send answer to login server via char-server
  3156. 	chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3157. 	clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3158.  
  3159. 	return 0;
  3160. }
  3161.  
  3162. /*==========================================
  3163.  * charunban command (usage: charunban <player_name>)
  3164.  *------------------------------------------*/
  3165. ACMD_FUNC(char_unban)
  3166. {
  3167. 	nullpo_retr(-1, sd);
  3168.  
  3169. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3170.  
  3171. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3172. 		clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3173. 		return -1;
  3174. 	}
  3175.  
  3176. 	// send answer to login server via char-server
  3177. 	chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3178. 	clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3179.  
  3180. 	return 0;
  3181. }
  3182.  
  3183. /*==========================================
  3184.  *
  3185.  *------------------------------------------*/
  3186. ACMD_FUNC(night)
  3187. {
  3188. 	nullpo_retr(-1, sd);
  3189.  
  3190. 	if (night_flag != 1) {
  3191. 		map_night_timer(night_timer_tid, 0, 0, 1);
  3192. 	} else {
  3193. 		clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3194. 		return -1;
  3195. 	}
  3196.  
  3197. 	return 0;
  3198. }
  3199.  
  3200. /*==========================================
  3201.  *
  3202.  *------------------------------------------*/
  3203. ACMD_FUNC(day)
  3204. {
  3205. 	nullpo_retr(-1, sd);
  3206.  
  3207. 	if (night_flag != 0) {
  3208. 		map_day_timer(day_timer_tid, 0, 0, 1);
  3209. 	} else {
  3210. 		clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3211. 		return -1;
  3212. 	}
  3213.  
  3214. 	return 0;
  3215. }
  3216.  
  3217. /*==========================================
  3218.  *
  3219.  *------------------------------------------*/
  3220. ACMD_FUNC(doom)
  3221. {
  3222. 	struct map_session_data* pl_sd;
  3223. 	struct s_mapiterator* iter;
  3224.  
  3225. 	nullpo_retr(-1, sd);
  3226.  
  3227. 	iter = mapit_getallusers();
  3228. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3229. 	{
  3230. 		if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3231. 		{
  3232. 			status_kill(&pl_sd->bl);
  3233. 			clif_specialeffect(&pl_sd->bl,450,AREA);
  3234. 			clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3235. 		}
  3236. 	}
  3237. 	mapit_free(iter);
  3238.  
  3239. 	clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3240.  
  3241. 	return 0;
  3242. }
  3243.  
  3244. /*==========================================
  3245.  *
  3246.  *------------------------------------------*/
  3247. ACMD_FUNC(doommap)
  3248. {
  3249. 	struct map_session_data* pl_sd;
  3250. 	struct s_mapiterator* iter;
  3251.  
  3252. 	nullpo_retr(-1, sd);
  3253.  
  3254. 	iter = mapit_getallusers();
  3255. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3256. 	{
  3257. 		if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3258. 		{
  3259. 			status_kill(&pl_sd->bl);
  3260. 			clif_specialeffect(&pl_sd->bl,450,AREA);
  3261. 			clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3262. 		}
  3263. 	}
  3264. 	mapit_free(iter);
  3265.  
  3266. 	clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3267.  
  3268. 	return 0;
  3269. }
  3270.  
  3271. /*==========================================
  3272.  *
  3273.  *------------------------------------------*/
  3274. static void atcommand_raise_sub(struct map_session_data* sd)
  3275. {
  3276. 	if (!status_isdead(&sd->bl))
  3277. 		return;
  3278.  
  3279. 	if(!status_revive(&sd->bl, 100, 100))
  3280. 		return;
  3281. 	clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3282. 	clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3283. }
  3284.  
  3285. /*==========================================
  3286.  *
  3287.  *------------------------------------------*/
  3288. ACMD_FUNC(raise)
  3289. {
  3290. 	struct map_session_data* pl_sd;
  3291. 	struct s_mapiterator* iter;
  3292.  
  3293. 	nullpo_retr(-1, sd);
  3294.  
  3295. 	iter = mapit_getallusers();
  3296. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3297. 		atcommand_raise_sub(pl_sd);
  3298. 	mapit_free(iter);
  3299.  
  3300. 	clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3301.  
  3302. 	return 0;
  3303. }
  3304.  
  3305. /*==========================================
  3306.  *
  3307.  *------------------------------------------*/
  3308. ACMD_FUNC(raisemap)
  3309. {
  3310. 	struct map_session_data* pl_sd;
  3311. 	struct s_mapiterator* iter;
  3312.  
  3313. 	nullpo_retr(-1, sd);
  3314.  
  3315. 	iter = mapit_getallusers();
  3316. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3317. 		if (sd->bl.m == pl_sd->bl.m)
  3318. 			atcommand_raise_sub(pl_sd);
  3319. 	mapit_free(iter);
  3320.  
  3321. 	clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3322.  
  3323. 	return 0;
  3324. }
  3325.  
  3326. /*==========================================
  3327.  *
  3328.  *------------------------------------------*/
  3329. ACMD_FUNC(kick)
  3330. {
  3331. 	struct map_session_data *pl_sd;
  3332. 	nullpo_retr(-1, sd);
  3333.  
  3334. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3335.  
  3336. 	if (!message || !*message) {
  3337. 		clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3338. 		return -1;
  3339. 	}
  3340.  
  3341. 	if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3342. 	{
  3343. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3344. 		return -1;
  3345. 	}
  3346.  
  3347. 	if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3348. 	{
  3349. 		clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3350. 		return -1;
  3351. 	}
  3352.  
  3353. 	clif_GM_kick(sd, pl_sd);
  3354.  
  3355. 	return 0;
  3356. }
  3357.  
  3358. /*==========================================
  3359.  *
  3360.  *------------------------------------------*/
  3361. ACMD_FUNC(kickall)
  3362. {
  3363. 	struct map_session_data* pl_sd;
  3364. 	struct s_mapiterator* iter;
  3365. 	nullpo_retr(-1, sd);
  3366.  
  3367. 	iter = mapit_getallusers();
  3368. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3369. 	{
  3370. 		if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3371. 			if (sd->status.account_id != pl_sd->status.account_id)
  3372. 				clif_GM_kick(NULL, pl_sd);
  3373. 		}
  3374. 	}
  3375. 	mapit_free(iter);
  3376.  
  3377. 	clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3378.  
  3379. 	return 0;
  3380. }
  3381.  
  3382. /*==========================================
  3383.  *
  3384.  *------------------------------------------*/
  3385. ACMD_FUNC(allskill)
  3386. {
  3387. 	nullpo_retr(-1, sd);
  3388. 	pc_allskillup(sd); // all skills
  3389. 	sd->status.skill_point = 0; // 0 skill points
  3390. 	clif_updatestatus(sd, SP_SKILLPOINT); // update
  3391. 	clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3392.  
  3393. 	return 0;
  3394. }
  3395.  
  3396. /*==========================================
  3397.  *
  3398.  *------------------------------------------*/
  3399. ACMD_FUNC(questskill)
  3400. {
  3401. 	int skill_id;
  3402. 	nullpo_retr(-1, sd);
  3403.  
  3404. 	if (!message || !*message || (skill_id = atoi(message)) < 0)
  3405. 	{// also send a list of skills applicable to this command
  3406. 		const char* text;
  3407.  
  3408. 		// attempt to find the text corresponding to this command
  3409. 		text = atcommand_help_string( command );
  3410.  
  3411. 		// send the error message as always
  3412. 		clif_displaymessage(fd, "Please enter a quest skill number.");
  3413.  
  3414. 		if( text )
  3415. 		{// send the skill ID list associated with this command
  3416. 			clif_displaymessage( fd, text );
  3417. 		}
  3418.  
  3419. 		return -1;
  3420. 	}
  3421. 	if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3422. 		clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3423. 		return -1;
  3424. 	}
  3425. 	if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3426. 		clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3427. 		return -1;
  3428. 	}
  3429. 	if (pc_checkskill(sd, skill_id) > 0) {
  3430. 		clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3431. 		return -1;
  3432. 	}
  3433.  
  3434. 	pc_skill(sd, skill_id, 1, 0);
  3435. 	clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3436.  
  3437. 	return 0;
  3438. }
  3439.  
  3440. /*==========================================
  3441.  *
  3442.  *------------------------------------------*/
  3443. ACMD_FUNC(lostskill)
  3444. {
  3445. 	int skill_id;
  3446. 	nullpo_retr(-1, sd);
  3447.  
  3448. 	if (!message || !*message || (skill_id = atoi(message)) < 0)
  3449. 	{// also send a list of skills applicable to this command
  3450. 		const char* text;
  3451.  
  3452. 		// attempt to find the text corresponding to this command
  3453. 		text = atcommand_help_string( command );
  3454.  
  3455. 		// send the error message as always
  3456. 		clif_displaymessage(fd, "Please enter a quest skill number.");
  3457.  
  3458. 		if( text )
  3459. 		{// send the skill ID list associated with this command
  3460. 			clif_displaymessage( fd, text );
  3461. 		}
  3462.  
  3463. 		return -1;
  3464. 	}
  3465. 	if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3466. 		clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3467. 		return -1;
  3468. 	}
  3469. 	if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3470. 		clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3471. 		return -1;
  3472. 	}
  3473. 	if (pc_checkskill(sd, skill_id) == 0) {
  3474. 		clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3475. 		return -1;
  3476. 	}
  3477.  
  3478. 	sd->status.skill[skill_id].lv = 0;
  3479. 	sd->status.skill[skill_id].flag = 0;
  3480. 	clif_deleteskill(sd,skill_id);
  3481. 	clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3482.  
  3483. 	return 0;
  3484. }
  3485.  
  3486. /*==========================================
  3487.  *
  3488.  *------------------------------------------*/
  3489. ACMD_FUNC(spiritball)
  3490. {
  3491. 	int max_spiritballs;
  3492. 	int number;
  3493. 	nullpo_retr(-1, sd);
  3494.  
  3495. 	max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3496.  
  3497. 	if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3498. 	{
  3499. 		char msg[CHAT_SIZE_MAX];
  3500. 		safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3501. 		clif_displaymessage(fd, msg);
  3502. 		return -1;
  3503. 	}
  3504.  
  3505. 	if( sd->spiritball > 0 )
  3506. 		pc_delspiritball(sd, sd->spiritball, 1);
  3507. 	sd->spiritball = number;
  3508. 	clif_spiritball(sd);
  3509. 	// no message, player can look the difference
  3510.  
  3511. 	return 0;
  3512. }
  3513.  
  3514. /*==========================================
  3515.  *
  3516.  *------------------------------------------*/
  3517. ACMD_FUNC(party)
  3518. {
  3519. 	char party[NAME_LENGTH];
  3520. 	nullpo_retr(-1, sd);
  3521.  
  3522. 	memset(party, '\0', sizeof(party));
  3523.  
  3524. 	if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3525. 		clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3526. 		return -1;
  3527. 	}
  3528.  
  3529. 	party_create(sd, party, 0, 0);
  3530.  
  3531. 	return 0;
  3532. }
  3533.  
  3534. /*==========================================
  3535.  *
  3536.  *------------------------------------------*/
  3537. ACMD_FUNC(guild)
  3538. {
  3539. 	char guild[NAME_LENGTH];
  3540. 	int prev;
  3541. 	nullpo_retr(-1, sd);
  3542.  
  3543. 	memset(guild, '\0', sizeof(guild));
  3544.  
  3545. 	if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3546. 		clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3547. 		return -1;
  3548. 	}
  3549.  
  3550. 	prev = battle_config.guild_emperium_check;
  3551. 	battle_config.guild_emperium_check = 0;
  3552. 	guild_create(sd, guild);
  3553. 	battle_config.guild_emperium_check = prev;
  3554.  
  3555. 	return 0;
  3556. }
  3557.  
  3558. /*==========================================
  3559.  *
  3560.  *------------------------------------------*/
  3561. ACMD_FUNC(agitstart)
  3562. {
  3563. 	nullpo_retr(-1, sd);
  3564. 	if (agit_flag == 1) {
  3565. 		clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3566. 		return -1;
  3567. 	}
  3568.  
  3569. 	agit_flag = 1;
  3570. 	guild_agit_start();
  3571. 	clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3572.  
  3573. 	return 0;
  3574. }
  3575.  
  3576. /*==========================================
  3577.  *
  3578.  *------------------------------------------*/
  3579. ACMD_FUNC(agitstart2)
  3580. {
  3581. 	nullpo_retr(-1, sd);
  3582. 	if (agit2_flag == 1) {
  3583. 		clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3584. 		return -1;
  3585. 	}
  3586.  
  3587. 	agit2_flag = 1;
  3588. 	guild_agit2_start();
  3589. 	clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3590.  
  3591. 	return 0;
  3592. }
  3593.  
  3594. /*==========================================
  3595.  *
  3596.  *------------------------------------------*/
  3597. ACMD_FUNC(agitend)
  3598. {
  3599. 	nullpo_retr(-1, sd);
  3600. 	if (agit_flag == 0) {
  3601. 		clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3602. 		return -1;
  3603. 	}
  3604.  
  3605. 	agit_flag = 0;
  3606. 	guild_agit_end();
  3607. 	clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3608.  
  3609. 	return 0;
  3610. }
  3611.  
  3612. /*==========================================
  3613.  *
  3614.  *------------------------------------------*/
  3615. ACMD_FUNC(agitend2)
  3616. {
  3617. 	nullpo_retr(-1, sd);
  3618. 	if (agit2_flag == 0) {
  3619. 		clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3620. 		return -1;
  3621. 	}
  3622.  
  3623. 	agit2_flag = 0;
  3624. 	guild_agit2_end();
  3625. 	clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3626.  
  3627. 	return 0;
  3628. }
  3629.  
  3630. /*==========================================
  3631.  * @mapexit - shuts down the map server
  3632.  *------------------------------------------*/
  3633. ACMD_FUNC(mapexit)
  3634. {
  3635. 	nullpo_retr(-1, sd);
  3636.  
  3637. 	do_shutdown();
  3638. 	return 0;
  3639. }
  3640.  
  3641. /*==========================================
  3642.  * idsearch <part_of_name>: revrited by [Yor]
  3643.  *------------------------------------------*/
  3644. ACMD_FUNC(idsearch)
  3645. {
  3646. 	char item_name[100];
  3647. 	unsigned int i, match;
  3648. 	struct item_data *item_array[MAX_SEARCH];
  3649. 	nullpo_retr(-1, sd);
  3650.  
  3651. 	memset(item_name, '\0', sizeof(item_name));
  3652. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  3653.  
  3654. 	if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3655. 		clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3656. 		return -1;
  3657. 	}
  3658.  
  3659. 	sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3660. 	clif_displaymessage(fd, atcmd_output);
  3661. 	match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3662. 	if (match > MAX_SEARCH) {
  3663. 		sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3664. 		clif_displaymessage(fd, atcmd_output);
  3665. 		match = MAX_SEARCH;
  3666. 	}
  3667. 	for(i = 0; i < match; i++) {
  3668. 		sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3669. 		clif_displaymessage(fd, atcmd_output);
  3670. 	}
  3671. 	sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3672. 	clif_displaymessage(fd, atcmd_output);
  3673.  
  3674. 	return 0;
  3675. }
  3676.  
  3677. /*==========================================
  3678.  * Recall All Characters Online To Your Location
  3679.  *------------------------------------------*/
  3680. ACMD_FUNC(recallall)
  3681. {
  3682. 	struct map_session_data* pl_sd;
  3683. 	struct s_mapiterator* iter;
  3684. 	int count;
  3685. 	nullpo_retr(-1, sd);
  3686.  
  3687. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  3688.  
  3689. 	if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3690. 		clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3691. 		return -1;
  3692. 	}
  3693.  
  3694. 	count = 0;
  3695. 	iter = mapit_getallusers();
  3696. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3697. 	{
  3698. 		if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3699. 		{
  3700. 			if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3701. 				count++;
  3702. 			else {
  3703. 				if (pc_isdead(pl_sd)) { //Wake them up
  3704. 					pc_setstand(pl_sd);
  3705. 					pc_setrestartvalue(pl_sd,1);
  3706. 				}
  3707. 				pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3708. 			}
  3709. 		}
  3710. 	}
  3711. 	mapit_free(iter);
  3712.  
  3713. 	clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3714. 	if (count) {
  3715. 		sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3716. 		clif_displaymessage(fd, atcmd_output);
  3717. 	}
  3718.  
  3719. 	return 0;
  3720. }
  3721.  
  3722. /*==========================================
  3723.  * Recall online characters of a guild to your location
  3724.  *------------------------------------------*/
  3725. ACMD_FUNC(guildrecall)
  3726. {
  3727. 	struct map_session_data* pl_sd;
  3728. 	struct s_mapiterator* iter;
  3729. 	int count;
  3730. 	char guild_name[NAME_LENGTH];
  3731. 	struct guild *g;
  3732. 	nullpo_retr(-1, sd);
  3733.  
  3734. 	memset(guild_name, '\0', sizeof(guild_name));
  3735. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  3736.  
  3737. 	if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3738. 		clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3739. 		return -1;
  3740. 	}
  3741.  
  3742. 	if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3743. 		clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3744. 		return -1;
  3745. 	}
  3746.  
  3747. 	if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3748. 	    (g = guild_search(atoi(message))) == NULL)
  3749. 	{
  3750. 		clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3751. 		return -1;
  3752. 	}
  3753.  
  3754. 	count = 0;
  3755.  
  3756. 	iter = mapit_getallusers();
  3757. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3758. 	{
  3759. 		if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3760. 		{
  3761. 			if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3762. 				continue; //Skip GMs greater than you.
  3763. 			if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3764. 				count++;
  3765. 			else
  3766. 				pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3767. 		}
  3768. 	}
  3769. 	mapit_free(iter);
  3770.  
  3771. 	sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3772. 	clif_displaymessage(fd, atcmd_output);
  3773. 	if (count) {
  3774. 		sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3775. 		clif_displaymessage(fd, atcmd_output);
  3776. 	}
  3777.  
  3778. 	return 0;
  3779. }
  3780.  
  3781. /*==========================================
  3782.  * Recall online characters of a party to your location
  3783.  *------------------------------------------*/
  3784. ACMD_FUNC(partyrecall)
  3785. {
  3786. 	struct map_session_data* pl_sd;
  3787. 	struct s_mapiterator* iter;
  3788. 	char party_name[NAME_LENGTH];
  3789. 	struct party_data *p;
  3790. 	int count;
  3791. 	nullpo_retr(-1, sd);
  3792.  
  3793. 	memset(party_name, '\0', sizeof(party_name));
  3794. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  3795.  
  3796. 	if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3797. 		clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3798. 		return -1;
  3799. 	}
  3800.  
  3801. 	if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3802. 		clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3803. 		return -1;
  3804. 	}
  3805.  
  3806. 	if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3807. 	    (p = party_search(atoi(message))) == NULL)
  3808. 	{
  3809. 		clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3810. 		return -1;
  3811. 	}
  3812.  
  3813. 	count = 0;
  3814.  
  3815. 	iter = mapit_getallusers();
  3816. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3817. 	{
  3818. 		if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3819. 		{
  3820. 			if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3821. 				continue; //Skip GMs greater than you.
  3822. 			if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3823. 				count++;
  3824. 			else
  3825. 				pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3826. 		}
  3827. 	}
  3828. 	mapit_free(iter);
  3829.  
  3830. 	sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3831. 	clif_displaymessage(fd, atcmd_output);
  3832. 	if (count) {
  3833. 		sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3834. 		clif_displaymessage(fd, atcmd_output);
  3835. 	}
  3836.  
  3837. 	return 0;
  3838. }
  3839.  
  3840. /*==========================================
  3841.  *
  3842.  *------------------------------------------*/
  3843. ACMD_FUNC(reloaditemdb)
  3844. {
  3845. 	nullpo_retr(-1, sd);
  3846. 	itemdb_reload();
  3847. 	clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3848.  
  3849. 	return 0;
  3850. }
  3851.  
  3852. /*==========================================
  3853.  *
  3854.  *------------------------------------------*/
  3855. ACMD_FUNC(reloadmobdb)
  3856. {
  3857. 	nullpo_retr(-1, sd);
  3858. 	mob_reload();
  3859. 	read_petdb();
  3860. 	merc_reload();
  3861. 	read_mercenarydb();
  3862. 	read_mercenary_skilldb();
  3863. 	reload_elementaldb();
  3864. 	clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3865.  
  3866. 	return 0;
  3867. }
  3868.  
  3869. /*==========================================
  3870.  *
  3871.  *------------------------------------------*/
  3872. ACMD_FUNC(reloadskilldb)
  3873. {
  3874. 	nullpo_retr(-1, sd);
  3875. 	skill_reload();
  3876. 	merc_skill_reload();
  3877. 	reload_elemental_skilldb();
  3878. 	read_mercenary_skilldb();
  3879. 	clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3880.  
  3881. 	return 0;
  3882. }
  3883.  
  3884. /*==========================================
  3885.  * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3886.  *------------------------------------------*/
  3887. void atcommand_doload();
  3888. ACMD_FUNC(reloadatcommand) {
  3889. 	config_t run_test;
  3890.  
  3891. 	if (conf_read_file(&run_test, "conf/groups.conf")) {
  3892. 		clif_displaymessage(fd, "Error reading groups.conf, can't reload");
  3893. 		return -1;
  3894. 	}
  3895.  
  3896. 	config_destroy(&run_test);
  3897.  
  3898. 	if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3899. 		clif_displaymessage(fd, "Error reading atcommand.conf, can't reload");
  3900. 		return -1;
  3901. 	}
  3902.  
  3903. 	config_destroy(&run_test);
  3904.  
  3905. 	atcommand_doload();
  3906. 	pc_groups_reload();
  3907. 	clif_displaymessage(fd, msg_txt(254));
  3908. 	return 0;
  3909. }
  3910. /*==========================================
  3911.  * @reloadbattleconf - reloads battle_athena.conf
  3912.  *------------------------------------------*/
  3913. ACMD_FUNC(reloadbattleconf)
  3914. {
  3915. 	struct Battle_Config prev_config;
  3916. 	memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3917.  
  3918. 	battle_config_read(BATTLE_CONF_FILENAME);
  3919.  
  3920. 	if( prev_config.item_rate_mvp          != battle_config.item_rate_mvp
  3921. 	||  prev_config.item_rate_common       != battle_config.item_rate_common
  3922. 	||  prev_config.item_rate_common_boss  != battle_config.item_rate_common_boss
  3923. 	||  prev_config.item_rate_card         != battle_config.item_rate_card
  3924. 	||  prev_config.item_rate_card_boss    != battle_config.item_rate_card_boss
  3925. 	||  prev_config.item_rate_equip        != battle_config.item_rate_equip
  3926. 	||  prev_config.item_rate_equip_boss   != battle_config.item_rate_equip_boss
  3927. 	||  prev_config.item_rate_heal         != battle_config.item_rate_heal
  3928. 	||  prev_config.item_rate_heal_boss    != battle_config.item_rate_heal_boss
  3929. 	||  prev_config.item_rate_use          != battle_config.item_rate_use
  3930. 	||  prev_config.item_rate_use_boss     != battle_config.item_rate_use_boss
  3931. 	||  prev_config.item_rate_treasure     != battle_config.item_rate_treasure
  3932. 	||  prev_config.item_rate_adddrop      != battle_config.item_rate_adddrop
  3933. 	||  prev_config.logarithmic_drops      != battle_config.logarithmic_drops
  3934. 	||  prev_config.item_drop_common_min   != battle_config.item_drop_common_min
  3935. 	||  prev_config.item_drop_common_max   != battle_config.item_drop_common_max
  3936. 	||  prev_config.item_drop_card_min     != battle_config.item_drop_card_min
  3937. 	||  prev_config.item_drop_card_max     != battle_config.item_drop_card_max
  3938. 	||  prev_config.item_drop_equip_min    != battle_config.item_drop_equip_min
  3939. 	||  prev_config.item_drop_equip_max    != battle_config.item_drop_equip_max
  3940. 	||  prev_config.item_drop_mvp_min      != battle_config.item_drop_mvp_min
  3941. 	||  prev_config.item_drop_mvp_max      != battle_config.item_drop_mvp_max
  3942. 	||  prev_config.item_drop_heal_min     != battle_config.item_drop_heal_min
  3943. 	||  prev_config.item_drop_heal_max     != battle_config.item_drop_heal_max
  3944. 	||  prev_config.item_drop_use_min      != battle_config.item_drop_use_min
  3945. 	||  prev_config.item_drop_use_max      != battle_config.item_drop_use_max
  3946. 	||  prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3947. 	||  prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3948. 	||  prev_config.base_exp_rate          != battle_config.base_exp_rate
  3949. 	||  prev_config.job_exp_rate           != battle_config.job_exp_rate
  3950. 	)
  3951.   	{	// Exp or Drop rates changed.
  3952. 		mob_reload(); //Needed as well so rate changes take effect.
  3953. 		chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3954. 	}
  3955. 	clif_displaymessage(fd, msg_txt(255));
  3956. 	return 0;
  3957. }
  3958. /*==========================================
  3959.  * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3960.  *------------------------------------------*/
  3961. ACMD_FUNC(reloadstatusdb)
  3962. {
  3963. 	status_readdb();
  3964. 	clif_displaymessage(fd, msg_txt(256));
  3965. 	return 0;
  3966. }
  3967. /*==========================================
  3968.  * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3969.  *------------------------------------------*/
  3970. ACMD_FUNC(reloadpcdb)
  3971. {
  3972. 	pc_readdb();
  3973. 	clif_displaymessage(fd, msg_txt(257));
  3974. 	return 0;
  3975. }
  3976.  
  3977. /*==========================================
  3978.  * @reloadmotd - reloads motd.txt
  3979.  *------------------------------------------*/
  3980. ACMD_FUNC(reloadmotd)
  3981. {
  3982. 	pc_read_motd();
  3983. 	clif_displaymessage(fd, msg_txt(268));
  3984. 	return 0;
  3985. }
  3986.  
  3987. /*==========================================
  3988.  * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3989.  *------------------------------------------*/
  3990. ACMD_FUNC(reloadscript)
  3991. {
  3992. 	nullpo_retr(-1, sd);
  3993. 	//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3994. 	//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3995.  
  3996. 	flush_fifos();
  3997. 	map_reloadnpc(true); // reload config files seeking for npcs
  3998. 	script_reload();
  3999. 	npc_reload();
  4000.  
  4001. 	clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  4002.  
  4003. 	return 0;
  4004. }
  4005.  
  4006. /*==========================================
  4007.  * @mapinfo [0-3] <map name> by MC_Cameri
  4008.  * => Shows information about the map [map name]
  4009.  * 0 = no additional information
  4010.  * 1 = Show users in that map and their location
  4011.  * 2 = Shows NPCs in that map
  4012.  * 3 = Shows the shops/chats in that map (not implemented)
  4013.  *------------------------------------------*/
  4014. ACMD_FUNC(mapinfo)
  4015. {
  4016. 	struct map_session_data* pl_sd;
  4017. 	struct s_mapiterator* iter;
  4018. 	struct npc_data *nd = NULL;
  4019. 	struct chat_data *cd = NULL;
  4020. 	char direction[12];
  4021. 	int i, m_id, chat_num, list = 0;
  4022. 	unsigned short m_index;
  4023. 	char mapname[24];
  4024.  
  4025. 	nullpo_retr(-1, sd);
  4026.  
  4027. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  4028. 	memset(mapname, '\0', sizeof(mapname));
  4029. 	memset(direction, '\0', sizeof(direction));
  4030.  
  4031. 	sscanf(message, "%d %23[^\n]", &list, mapname);
  4032.  
  4033. 	if (list < 0 || list > 3) {
  4034. 		clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4035. 		return -1;
  4036. 	}
  4037.  
  4038. 	if (mapname[0] == '\0') {
  4039. 		safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4040. 		m_id =  map_mapindex2mapid(sd->mapindex);
  4041. 	} else {
  4042. 		m_id = map_mapname2mapid(mapname);
  4043. 	}
  4044.  
  4045. 	if (m_id < 0) {
  4046. 		clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4047. 		return -1;
  4048. 	}
  4049. 	m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  4050.  
  4051. 	clif_displaymessage(fd, "------ Map Info ------");
  4052.  
  4053. 	// count chats (for initial message)
  4054. 	chat_num = 0;
  4055. 	iter = mapit_getallusers();
  4056. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4057. 		if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  4058. 			chat_num++;
  4059. 	mapit_free(iter);
  4060.  
  4061. 	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);
  4062. 	clif_displaymessage(fd, atcmd_output);
  4063. 	clif_displaymessage(fd, "------ Map Flags ------");
  4064. 	if (map[m_id].flag.town)
  4065. 		clif_displaymessage(fd, "Town Map");
  4066.  
  4067. 	if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  4068. 		clif_displaymessage(fd, "Autotrade Enabled");
  4069. 	else
  4070. 		clif_displaymessage(fd, "Autotrade Disabled");
  4071.  
  4072. 	if (map[m_id].flag.battleground)
  4073. 		clif_displaymessage(fd, "Battlegrounds ON");
  4074.  
  4075. 	strcpy(atcmd_output,"PvP Flags: ");
  4076. 	if (map[m_id].flag.pvp)
  4077. 		strcat(atcmd_output, "Pvp ON | ");
  4078. 	if (map[m_id].flag.pvp_noguild)
  4079. 		strcat(atcmd_output, "NoGuild | ");
  4080. 	if (map[m_id].flag.pvp_noparty)
  4081. 		strcat(atcmd_output, "NoParty | ");
  4082. 	if (map[m_id].flag.pvp_nightmaredrop)
  4083. 		strcat(atcmd_output, "NightmareDrop | ");
  4084. 	if (map[m_id].flag.pvp_nocalcrank)
  4085. 		strcat(atcmd_output, "NoCalcRank | ");
  4086. 	clif_displaymessage(fd, atcmd_output);
  4087.  
  4088. 	strcpy(atcmd_output,"GvG Flags: ");
  4089. 	if (map[m_id].flag.gvg)
  4090. 		strcat(atcmd_output, "GvG ON | ");
  4091. 	if (map[m_id].flag.gvg_dungeon)
  4092. 		strcat(atcmd_output, "GvG Dungeon | ");
  4093. 	if (map[m_id].flag.gvg_castle)
  4094. 		strcat(atcmd_output, "GvG Castle | ");
  4095. 	if (map[m_id].flag.gvg_noparty)
  4096. 		strcat(atcmd_output, "NoParty | ");
  4097. 	clif_displaymessage(fd, atcmd_output);
  4098.  
  4099. 	strcpy(atcmd_output,"Teleport Flags: ");
  4100. 	if (map[m_id].flag.noteleport)
  4101. 		strcat(atcmd_output, "NoTeleport | ");
  4102. 	if (map[m_id].flag.monster_noteleport)
  4103. 		strcat(atcmd_output, "Monster NoTeleport | ");
  4104. 	if (map[m_id].flag.nowarp)
  4105. 		strcat(atcmd_output, "NoWarp | ");
  4106. 	if (map[m_id].flag.nowarpto)
  4107. 		strcat(atcmd_output, "NoWarpTo | ");
  4108. 	if (map[m_id].flag.noreturn)
  4109. 		strcat(atcmd_output, "NoReturn | ");
  4110. 	if (map[m_id].flag.nogo)
  4111. 		strcat(atcmd_output, "NoGo | ");
  4112. 	if (map[m_id].flag.nomemo)
  4113. 		strcat(atcmd_output, "NoMemo | ");
  4114. 	clif_displaymessage(fd, atcmd_output);
  4115.  
  4116. 	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");
  4117. 	clif_displaymessage(fd, atcmd_output);
  4118.  
  4119. 	if (map[m_id].flag.nosave) {
  4120. 		if (!map[m_id].save.map)
  4121. 			sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4122. 		else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4123. 			sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4124. 		else
  4125. 			sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4126. 				mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4127. 		clif_displaymessage(fd, atcmd_output);
  4128. 	}
  4129.  
  4130. 	strcpy(atcmd_output,"Weather Flags: ");
  4131. 	if (map[m_id].flag.snow)
  4132. 		strcat(atcmd_output, "Snow | ");
  4133. 	if (map[m_id].flag.fog)
  4134. 		strcat(atcmd_output, "Fog | ");
  4135. 	if (map[m_id].flag.sakura)
  4136. 		strcat(atcmd_output, "Sakura | ");
  4137. 	if (map[m_id].flag.clouds)
  4138. 		strcat(atcmd_output, "Clouds | ");
  4139. 	if (map[m_id].flag.clouds2)
  4140. 		strcat(atcmd_output, "Clouds2 | ");
  4141. 	if (map[m_id].flag.fireworks)
  4142. 		strcat(atcmd_output, "Fireworks | ");
  4143. 	if (map[m_id].flag.leaves)
  4144. 		strcat(atcmd_output, "Leaves | ");
  4145. 	/**
  4146. 	 * No longer available, keeping here just in case it's back someday. [Ind]
  4147. 	 **/
  4148. 	//if (map[m_id].flag.rain)
  4149. 	//	strcat(atcmd_output, "Rain | ");
  4150. 	if (map[m_id].flag.nightenabled)
  4151. 		strcat(atcmd_output, "Displays Night | ");
  4152. 	clif_displaymessage(fd, atcmd_output);
  4153.  
  4154. 	strcpy(atcmd_output,"Other Flags: ");
  4155. 	if (map[m_id].flag.nobranch)
  4156. 		strcat(atcmd_output, "NoBranch | ");
  4157. 	if (map[m_id].flag.notrade)
  4158. 		strcat(atcmd_output, "NoTrade | ");
  4159. 	if (map[m_id].flag.novending)
  4160. 		strcat(atcmd_output, "NoVending | ");
  4161. 	if (map[m_id].flag.nodrop)
  4162. 		strcat(atcmd_output, "NoDrop | ");
  4163. 	if (map[m_id].flag.noskill)
  4164. 		strcat(atcmd_output, "NoSkill | ");
  4165. 	if (map[m_id].flag.noicewall)
  4166. 		strcat(atcmd_output, "NoIcewall | ");
  4167. 	if (map[m_id].flag.allowks)
  4168. 		strcat(atcmd_output, "AllowKS | ");
  4169. 	if (map[m_id].flag.reset)
  4170. 		strcat(atcmd_output, "Reset | ");
  4171. 	clif_displaymessage(fd, atcmd_output);
  4172.  
  4173. 	strcpy(atcmd_output,"Other Flags: ");
  4174. 	if (map[m_id].nocommand)
  4175. 		strcat(atcmd_output, "NoCommand | ");
  4176. 	if (map[m_id].flag.nobaseexp)
  4177. 		strcat(atcmd_output, "NoBaseEXP | ");
  4178. 	if (map[m_id].flag.nojobexp)
  4179. 		strcat(atcmd_output, "NoJobEXP | ");
  4180. 	if (map[m_id].flag.nomobloot)
  4181. 		strcat(atcmd_output, "NoMobLoot | ");
  4182. 	if (map[m_id].flag.nomvploot)
  4183. 		strcat(atcmd_output, "NoMVPLoot | ");
  4184. 	if (map[m_id].flag.partylock)
  4185. 		strcat(atcmd_output, "PartyLock | ");
  4186. 	if (map[m_id].flag.guildlock)
  4187. 		strcat(atcmd_output, "GuildLock | ");
  4188. 	clif_displaymessage(fd, atcmd_output);
  4189.  
  4190. 	switch (list) {
  4191. 	case 0:
  4192. 		// Do nothing. It's list 0, no additional display.
  4193. 		break;
  4194. 	case 1:
  4195. 		clif_displaymessage(fd, "----- Players in Map -----");
  4196. 		iter = mapit_getallusers();
  4197. 		for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4198. 		{
  4199. 			if (pl_sd->mapindex == m_index) {
  4200. 				sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4201. 				        pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4202. 				clif_displaymessage(fd, atcmd_output);
  4203. 			}
  4204. 		}
  4205. 		mapit_free(iter);
  4206. 		break;
  4207. 	case 2:
  4208. 		clif_displaymessage(fd, "----- NPCs in Map -----");
  4209. 		for (i = 0; i < map[m_id].npc_num;)
  4210. 		{
  4211. 			nd = map[m_id].npc[i];
  4212. 			switch(nd->ud.dir) {
  4213. 			case 0:  strcpy(direction, "North"); break;
  4214. 			case 1:  strcpy(direction, "North West"); break;
  4215. 			case 2:  strcpy(direction, "West"); break;
  4216. 			case 3:  strcpy(direction, "South West"); break;
  4217. 			case 4:  strcpy(direction, "South"); break;
  4218. 			case 5:  strcpy(direction, "South East"); break;
  4219. 			case 6:  strcpy(direction, "East"); break;
  4220. 			case 7:  strcpy(direction, "North East"); break;
  4221. 			case 9:  strcpy(direction, "North"); break;
  4222. 			default: strcpy(direction, "Unknown"); break;
  4223. 			}
  4224. 			if(strcmp(nd->name,nd->exname) == 0)
  4225. 				sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4226. 				    ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4227. 			else
  4228. 				sprintf(atcmd_output, "NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d",
  4229. 			        ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4230. 			clif_displaymessage(fd, atcmd_output);
  4231. 		}
  4232. 		break;
  4233. 	case 3:
  4234. 		clif_displaymessage(fd, "----- Chats in Map -----");
  4235. 		iter = mapit_getallusers();
  4236. 		for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4237. 		{
  4238. 			if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4239. 			    pl_sd->mapindex == m_index &&
  4240. 			    cd->usersd[0] == pl_sd)
  4241. 			{
  4242. 				sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4243. 				        cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4244. 				clif_displaymessage(fd, atcmd_output);
  4245. 				sprintf(atcmd_output, "   Users: %d/%d | Password: %s | Public: %s",
  4246. 				        cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4247. 				clif_displaymessage(fd, atcmd_output);
  4248. 			}
  4249. 		}
  4250. 		mapit_free(iter);
  4251. 		break;
  4252. 	default: // normally impossible to arrive here
  4253. 		clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4254. 		return -1;
  4255. 		break;
  4256. 	}
  4257.  
  4258. 	return 0;
  4259. }
  4260.  
  4261. /*==========================================
  4262.  *
  4263.  *------------------------------------------*/
  4264. ACMD_FUNC(mount_peco)
  4265. {
  4266. 	nullpo_retr(-1, sd);
  4267.  
  4268. 	if (sd->disguise) {
  4269. 		clif_displaymessage(fd, msg_txt(212)); // Cannot mount while in disguise.
  4270. 		return -1;
  4271. 	}
  4272.  
  4273. 	if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4274. 		if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4275. 			clif_displaymessage(sd->fd,"You have mounted your Dragon");
  4276. 			pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4277. 		} else {
  4278. 			clif_displaymessage(sd->fd,"You have released your Dragon");
  4279. 			pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4280. 		}
  4281. 		return 0;
  4282. 	}
  4283. 	if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  4284. 		if( !pc_isridingwug(sd) ) {
  4285. 			clif_displaymessage(sd->fd,"You have mounted your Wug");
  4286. 			pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4287. 		} else {
  4288. 			clif_displaymessage(sd->fd,"You have released your Wug");
  4289. 			pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4290. 		}
  4291. 		return 0;
  4292. 	}
  4293. 	if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4294. 		if( !pc_ismadogear(sd) ) {
  4295. 			clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  4296. 			pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4297. 		} else {
  4298. 			clif_displaymessage(sd->fd,"You have released your Mado Gear");
  4299. 			pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4300. 		}
  4301. 		return 0;
  4302. 	}
  4303. 	if (!pc_isriding(sd)) { // if actually no peco
  4304.  
  4305. 		if (!pc_checkskill(sd, KN_RIDING)) {
  4306. 			clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4307. 			return -1;
  4308. 		}
  4309.  
  4310. 		pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4311. 		clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4312. 	} else {//Dismount
  4313. 		pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4314. 		clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4315. 	}
  4316.  
  4317. 	return 0;
  4318. }
  4319.  
  4320. /*==========================================
  4321.  *Spy Commands by Syrus22
  4322.  *------------------------------------------*/
  4323. ACMD_FUNC(guildspy)
  4324. {
  4325. 	char guild_name[NAME_LENGTH];
  4326. 	struct guild *g;
  4327. 	nullpo_retr(-1, sd);
  4328.  
  4329. 	memset(guild_name, '\0', sizeof(guild_name));
  4330. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  4331.  
  4332. 	if (!enable_spy)
  4333. 	{
  4334. 		clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4335. 		return -1;
  4336. 	}
  4337. 	if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4338. 		clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4339. 		return -1;
  4340. 	}
  4341.  
  4342. 	if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4343. 	    (g = guild_search(atoi(message))) != NULL) {
  4344. 		if (sd->guildspy == g->guild_id) {
  4345. 			sd->guildspy = 0;
  4346. 			sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4347. 			clif_displaymessage(fd, atcmd_output);
  4348. 		} else {
  4349. 			sd->guildspy = g->guild_id;
  4350. 			sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4351. 			clif_displaymessage(fd, atcmd_output);
  4352. 		}
  4353. 	} else {
  4354. 		clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4355. 		return -1;
  4356. 	}
  4357.  
  4358. 	return 0;
  4359. }
  4360.  
  4361. /*==========================================
  4362.  *
  4363.  *------------------------------------------*/
  4364. ACMD_FUNC(partyspy)
  4365. {
  4366. 	char party_name[NAME_LENGTH];
  4367. 	struct party_data *p;
  4368. 	nullpo_retr(-1, sd);
  4369.  
  4370. 	memset(party_name, '\0', sizeof(party_name));
  4371. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  4372.  
  4373. 	if (!enable_spy)
  4374. 	{
  4375. 		clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4376. 		return -1;
  4377. 	}
  4378.  
  4379. 	if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4380. 		clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4381. 		return -1;
  4382. 	}
  4383.  
  4384. 	if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4385. 	    (p = party_search(atoi(message))) != NULL) {
  4386. 		if (sd->partyspy == p->party.party_id) {
  4387. 			sd->partyspy = 0;
  4388. 			sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4389. 			clif_displaymessage(fd, atcmd_output);
  4390. 		} else {
  4391. 			sd->partyspy = p->party.party_id;
  4392. 			sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4393. 			clif_displaymessage(fd, atcmd_output);
  4394. 		}
  4395. 	} else {
  4396. 		clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4397. 		return -1;
  4398. 	}
  4399.  
  4400. 	return 0;
  4401. }
  4402.  
  4403. /*==========================================
  4404.  * @repairall [Valaris]
  4405.  *------------------------------------------*/
  4406. ACMD_FUNC(repairall)
  4407. {
  4408. 	int count, i;
  4409. 	nullpo_retr(-1, sd);
  4410.  
  4411. 	count = 0;
  4412. 	for (i = 0; i < MAX_INVENTORY; i++) {
  4413. 		if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4414. 			sd->status.inventory[i].attribute = 0;
  4415. 			clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4416. 			count++;
  4417. 		}
  4418. 	}
  4419.  
  4420. 	if (count > 0) {
  4421. 		clif_misceffect(&sd->bl, 3);
  4422. 		clif_equiplist(sd);
  4423. 		clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4424. 	} else {
  4425. 		clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4426. 		return -1;
  4427. 	}
  4428.  
  4429. 	return 0;
  4430. }
  4431.  
  4432. /*==========================================
  4433.  * @nuke [Valaris]
  4434.  *------------------------------------------*/
  4435. ACMD_FUNC(nuke)
  4436. {
  4437. 	struct map_session_data *pl_sd;
  4438. 	nullpo_retr(-1, sd);
  4439.  
  4440. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4441.  
  4442. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4443. 		clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4444. 		return -1;
  4445. 	}
  4446.  
  4447. 	if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4448. 		if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4449. 			skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4450. 			clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4451. 		} else {
  4452. 			clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4453. 			return -1;
  4454. 		}
  4455. 	} else {
  4456. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4457. 		return -1;
  4458. 	}
  4459.  
  4460. 	return 0;
  4461. }
  4462.  
  4463. /*==========================================
  4464.  * @tonpc
  4465.  *------------------------------------------*/
  4466. ACMD_FUNC(tonpc)
  4467. {
  4468. 	char npcname[NAME_LENGTH+1];
  4469. 	struct npc_data *nd;
  4470.  
  4471. 	nullpo_retr(-1, sd);
  4472.  
  4473. 	memset(npcname, 0, sizeof(npcname));
  4474.  
  4475. 	if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4476. 		clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4477. 		return -1;
  4478. 	}
  4479.  
  4480. 	if ((nd = npc_name2id(npcname)) != NULL) {
  4481. 		if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4482. 			clif_displaymessage(fd, msg_txt(0)); // Warped.
  4483. 		else
  4484. 			return -1;
  4485. 	} else {
  4486. 		clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4487. 		return -1;
  4488. 	}
  4489.  
  4490. 	return 0;
  4491. }
  4492.  
  4493. /*==========================================
  4494.  *
  4495.  *------------------------------------------*/
  4496. ACMD_FUNC(shownpc)
  4497. {
  4498. 	char NPCname[NAME_LENGTH+1];
  4499. 	nullpo_retr(-1, sd);
  4500.  
  4501. 	memset(NPCname, '\0', sizeof(NPCname));
  4502.  
  4503. 	if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4504. 		clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4505. 		return -1;
  4506. 	}
  4507.  
  4508. 	if (npc_name2id(NPCname) != NULL) {
  4509. 		npc_enable(NPCname, 1);
  4510. 		clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4511. 	} else {
  4512. 		clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4513. 		return -1;
  4514. 	}
  4515.  
  4516. 	return 0;
  4517. }
  4518.  
  4519. /*==========================================
  4520.  *
  4521.  *------------------------------------------*/
  4522. ACMD_FUNC(hidenpc)
  4523. {
  4524. 	char NPCname[NAME_LENGTH+1];
  4525. 	nullpo_retr(-1, sd);
  4526.  
  4527. 	memset(NPCname, '\0', sizeof(NPCname));
  4528.  
  4529. 	if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4530. 		clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4531. 		return -1;
  4532. 	}
  4533.  
  4534. 	if (npc_name2id(NPCname) == NULL) {
  4535. 		clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4536. 		return -1;
  4537. 	}
  4538.  
  4539. 	npc_enable(NPCname, 0);
  4540. 	clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4541. 	return 0;
  4542. }
  4543.  
  4544. ACMD_FUNC(loadnpc)
  4545. {
  4546. 	FILE *fp;
  4547.  
  4548. 	if (!message || !*message) {
  4549. 		clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4550. 		return -1;
  4551. 	}
  4552.  
  4553. 	// check if script file exists
  4554. 	if ((fp = fopen(message, "r")) == NULL) {
  4555. 		clif_displaymessage(fd, msg_txt(261));
  4556. 		return -1;
  4557. 	}
  4558. 	fclose(fp);
  4559.  
  4560. 	// add to list of script sources and run it
  4561. 	npc_addsrcfile(message);
  4562. 	npc_parsesrcfile(message,true);
  4563. 	npc_read_event_script();
  4564.  
  4565. 	clif_displaymessage(fd, msg_txt(262));
  4566.  
  4567. 	return 0;
  4568. }
  4569.  
  4570. ACMD_FUNC(unloadnpc)
  4571. {
  4572. 	struct npc_data *nd;
  4573. 	char NPCname[NAME_LENGTH+1];
  4574. 	nullpo_retr(-1, sd);
  4575.  
  4576. 	memset(NPCname, '\0', sizeof(NPCname));
  4577.  
  4578. 	if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4579. 		clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4580. 		return -1;
  4581. 	}
  4582.  
  4583. 	if ((nd = npc_name2id(NPCname)) == NULL) {
  4584. 		clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4585. 		return -1;
  4586. 	}
  4587.  
  4588. 	npc_unload_duplicates(nd);
  4589. 	npc_unload(nd,true);
  4590. 	npc_read_event_script();
  4591. 	clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4592. 	return 0;
  4593. }
  4594.  
  4595. /*==========================================
  4596.  * time in txt for time command (by [Yor])
  4597.  *------------------------------------------*/
  4598. char* txt_time(unsigned int duration)
  4599. {
  4600. 	int days, hours, minutes, seconds;
  4601. 	char temp[CHAT_SIZE_MAX];
  4602. 	static char temp1[CHAT_SIZE_MAX];
  4603.  
  4604. 	memset(temp, '\0', sizeof(temp));
  4605. 	memset(temp1, '\0', sizeof(temp1));
  4606.  
  4607. 	days = duration / (60 * 60 * 24);
  4608. 	duration = duration - (60 * 60 * 24 * days);
  4609. 	hours = duration / (60 * 60);
  4610. 	duration = duration - (60 * 60 * hours);
  4611. 	minutes = duration / 60;
  4612. 	seconds = duration - (60 * minutes);
  4613.  
  4614. 	if (days < 2)
  4615. 		sprintf(temp, msg_txt(219), days); // %d day
  4616. 	else
  4617. 		sprintf(temp, msg_txt(220), days); // %d days
  4618. 	if (hours < 2)
  4619. 		sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4620. 	else
  4621. 		sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4622. 	if (minutes < 2)
  4623. 		sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4624. 	else
  4625. 		sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4626. 	if (seconds < 2)
  4627. 		sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4628. 	else
  4629. 		sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4630.  
  4631. 	return temp1;
  4632. }
  4633.  
  4634. /*==========================================
  4635.  * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4636.  * Calculation management of GM modification (@day/@night GM commands) is done
  4637.  *------------------------------------------*/
  4638. ACMD_FUNC(servertime)
  4639. {
  4640. 	const struct TimerData * timer_data;
  4641. 	const struct TimerData * timer_data2;
  4642. 	time_t time_server;  // variable for number of seconds (used with time() function)
  4643. 	struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4644. 	char temp[CHAT_SIZE_MAX];
  4645. 	nullpo_retr(-1, sd);
  4646.  
  4647. 	memset(temp, '\0', sizeof(temp));
  4648.  
  4649. 	time(&time_server);  // get time in seconds since 1/1/1970
  4650. 	datetime = localtime(&time_server); // convert seconds in structure
  4651. 	// like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4652. 	strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4653. 	clif_displaymessage(fd, temp);
  4654.  
  4655. 	if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4656. 		if (night_flag == 0)
  4657. 			clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4658. 		else
  4659. 			clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4660. 	} else if (battle_config.night_duration == 0)
  4661. 		if (night_flag == 1) { // we start with night
  4662. 			timer_data = get_timer(day_timer_tid);
  4663. 			sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4664. 			clif_displaymessage(fd, temp);
  4665. 			clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4666. 		} else
  4667. 			clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4668. 	else if (battle_config.day_duration == 0)
  4669. 		if (night_flag == 0) { // we start with day
  4670. 			timer_data = get_timer(night_timer_tid);
  4671. 			sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4672. 			clif_displaymessage(fd, temp);
  4673. 			clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4674. 		} else
  4675. 			clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4676. 	else {
  4677. 		if (night_flag == 0) {
  4678. 			timer_data = get_timer(night_timer_tid);
  4679. 			timer_data2 = get_timer(day_timer_tid);
  4680. 			sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4681. 			clif_displaymessage(fd, temp);
  4682. 			if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4683. 				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.
  4684. 			else
  4685. 				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.
  4686. 			clif_displaymessage(fd, temp);
  4687. 			sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4688. 			clif_displaymessage(fd, temp);
  4689. 		} else {
  4690. 			timer_data = get_timer(day_timer_tid);
  4691. 			timer_data2 = get_timer(night_timer_tid);
  4692. 			sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4693. 			clif_displaymessage(fd, temp);
  4694. 			if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4695. 				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.
  4696. 			else
  4697. 				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.
  4698. 			clif_displaymessage(fd, temp);
  4699. 			sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4700. 			clif_displaymessage(fd, temp);
  4701. 		}
  4702. 	}
  4703.  
  4704. 	return 0;
  4705. }
  4706.  
  4707. //Added by Coltaro
  4708. //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...).
  4709. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4710. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4711. {
  4712. 	const int factor_year = 518400; //12*30*24*60 = 518400
  4713. 	const int factor_month = 43200; //30*24*60 = 43200
  4714. 	const int factor_day = 1440; //24*60 = 1440
  4715. 	const int factor_hour = 60;
  4716.  
  4717. 	*year = jailtime/factor_year;
  4718. 	jailtime -= *year*factor_year;
  4719. 	*month = jailtime/factor_month;
  4720. 	jailtime -= *month*factor_month;
  4721. 	*day = jailtime/factor_day;
  4722. 	jailtime -= *day*factor_day;
  4723. 	*hour = jailtime/factor_hour;
  4724. 	jailtime -= *hour*factor_hour;
  4725. 	*minute = jailtime;
  4726.  
  4727. 	*year = *year > 0? *year : 0;
  4728. 	*month = *month > 0? *month : 0;
  4729. 	*day = *day > 0? *day : 0;
  4730. 	*hour = *hour > 0? *hour : 0;
  4731. 	*minute = *minute > 0? *minute : 0;
  4732. 	return;
  4733. }
  4734.  
  4735. /*==========================================
  4736.  * @jail <char_name> by [Yor]
  4737.  * Special warp! No check with nowarp and nowarpto flag
  4738.  *------------------------------------------*/
  4739. ACMD_FUNC(jail)
  4740. {
  4741. 	struct map_session_data *pl_sd;
  4742. 	int x, y;
  4743. 	unsigned short m_index;
  4744. 	nullpo_retr(-1, sd);
  4745.  
  4746. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4747.  
  4748. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4749. 		clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4750. 		return -1;
  4751. 	}
  4752.  
  4753. 	if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4754. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4755. 		return -1;
  4756. 	}
  4757.  
  4758. 	if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4759.   	{ // you can jail only lower or same GM
  4760. 		clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4761. 		return -1;
  4762. 	}
  4763.  
  4764. 	if (pl_sd->sc.data[SC_JAILED])
  4765. 	{
  4766. 		clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4767. 		return -1;
  4768. 	}
  4769.  
  4770. 	switch(rnd() % 2) { //Jail Locations
  4771. 	case 0:
  4772. 		m_index = mapindex_name2id(MAP_JAIL);
  4773. 		x = 24;
  4774. 		y = 75;
  4775. 		break;
  4776. 	default:
  4777. 		m_index = mapindex_name2id(MAP_JAIL);
  4778. 		x = 49;
  4779. 		y = 75;
  4780. 		break;
  4781. 	}
  4782.  
  4783. 	//Duration of INT_MAX to specify infinity.
  4784. 	sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4785. 	clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4786. 	clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4787. 	return 0;
  4788. }
  4789.  
  4790. /*==========================================
  4791.  * @unjail/@discharge <char_name> by [Yor]
  4792.  * Special warp! No check with nowarp and nowarpto flag
  4793.  *------------------------------------------*/
  4794. ACMD_FUNC(unjail)
  4795. {
  4796. 	struct map_session_data *pl_sd;
  4797.  
  4798. 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4799.  
  4800. 	if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4801. 		clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4802. 		return -1;
  4803. 	}
  4804.  
  4805. 	if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4806. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4807. 		return -1;
  4808. 	}
  4809.  
  4810. 	if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4811.  
  4812. 		clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4813. 		return -1;
  4814. 	}
  4815.  
  4816. 	if (!pl_sd->sc.data[SC_JAILED])
  4817. 	{
  4818. 		clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4819. 		return -1;
  4820. 	}
  4821.  
  4822. 	//Reset jail time to 1 sec.
  4823. 	sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4824. 	clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4825. 	clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4826. 	return 0;
  4827. }
  4828.  
  4829. ACMD_FUNC(jailfor)
  4830. {
  4831. 	struct map_session_data *pl_sd = NULL;
  4832. 	int year, month, day, hour, minute, value;
  4833. 	char * modif_p;
  4834. 	int jailtime = 0,x,y;
  4835. 	short m_index = 0;
  4836. 	nullpo_retr(-1, sd);
  4837.  
  4838. 	if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4839. 		clif_displaymessage(fd, msg_txt(400));	//Usage: @jailfor <time> <character name>
  4840. 		return -1;
  4841. 	}
  4842.  
  4843. 	atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4844.  
  4845. 	modif_p = atcmd_output;
  4846. 	year = month = day = hour = minute = 0;
  4847. 	while (modif_p[0] != '\0') {
  4848. 		value = atoi(modif_p);
  4849. 		if (value == 0)
  4850. 			modif_p++;
  4851. 		else {
  4852. 			if (modif_p[0] == '-' || modif_p[0] == '+')
  4853. 				modif_p++;
  4854. 			while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4855. 				modif_p++;
  4856. 			if (modif_p[0] == 'n') {
  4857. 				minute = value;
  4858. 				modif_p++;
  4859. 			} else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4860. 				minute = value;
  4861. 				modif_p = modif_p + 2;
  4862. 			} else if (modif_p[0] == 'h') {
  4863. 				hour = value;
  4864. 				modif_p++;
  4865. 			} else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4866. 				day = value;
  4867. 				modif_p++;
  4868. 			} else if (modif_p[0] == 'm') {
  4869. 				month = value;
  4870. 				modif_p++;
  4871. 			} else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4872. 				year = value;
  4873. 				modif_p++;
  4874. 			} else if (modif_p[0] != '\0') {
  4875. 				modif_p++;
  4876. 			}
  4877. 		}
  4878. 	}
  4879.  
  4880. 	if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4881. 		clif_displaymessage(fd, "Invalid time for jail command.");
  4882. 		return -1;
  4883. 	}
  4884.  
  4885. 	if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4886. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4887. 		return -1;
  4888. 	}
  4889.  
  4890. 	if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4891. 		clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4892. 		return -1;
  4893. 	}
  4894.  
  4895. 	jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute;	//In minutes
  4896.  
  4897. 	if(jailtime==0) {
  4898. 		clif_displaymessage(fd, "Invalid time for jail command.");
  4899. 		return -1;
  4900. 	}
  4901.  
  4902. 	//Added by Coltaro
  4903. 	if(pl_sd->sc.data[SC_JAILED] && 
  4904. 		pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4905.   	{	//Update the player's jail time
  4906. 		jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4907. 		if (jailtime <= 0) {
  4908. 			jailtime = 0;
  4909. 			clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4910. 			clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4911. 		} else {
  4912. 			get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4913. 			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
  4914. 	 		clif_displaymessage(pl_sd->fd, atcmd_output);
  4915. 			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
  4916. 	 		clif_displaymessage(fd, atcmd_output);
  4917. 		}
  4918. 	} else if (jailtime < 0) {
  4919. 		clif_displaymessage(fd, "Invalid time for jail command.");
  4920. 		return -1;
  4921. 	}
  4922.  
  4923. 	//Jail locations, add more as you wish.
  4924. 	switch(rnd()%2)
  4925. 	{
  4926. 		case 1: //Jail #1
  4927. 			m_index = mapindex_name2id(MAP_JAIL);
  4928. 			x = 49; y = 75;
  4929. 			break;
  4930. 		default: //Default Jail
  4931. 			m_index = mapindex_name2id(MAP_JAIL);
  4932. 			x = 24; y = 75;
  4933. 			break;
  4934. 	}
  4935.  
  4936. 	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).
  4937. 	return 0;
  4938. }
  4939.  
  4940.  
  4941. //By Coltaro
  4942. ACMD_FUNC(jailtime)
  4943. {
  4944. 	int year, month, day, hour, minute;
  4945.  
  4946. 	nullpo_retr(-1, sd);
  4947.  
  4948. 	if (!sd->sc.data[SC_JAILED]) {
  4949. 		clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4950. 		return -1;
  4951. 	}
  4952.  
  4953. 	if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4954. 		clif_displaymessage(fd, "You have been jailed indefinitely.");
  4955. 		return 0;
  4956. 	}
  4957.  
  4958. 	if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4959. 		clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4960. 		return -1;
  4961. 	}
  4962.  
  4963. 	//Get remaining jail time
  4964. 	get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4965. 	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
  4966.  
  4967. 	clif_displaymessage(fd, atcmd_output);
  4968.  
  4969. 	return 0;
  4970. }
  4971.  
  4972. /*==========================================
  4973.  * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4974.  *------------------------------------------*/
  4975. ACMD_FUNC(disguise)
  4976. {
  4977. 	int id = 0;
  4978. 	nullpo_retr(-1, sd);
  4979.  
  4980. 	if (!message || !*message) {
  4981. 		clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4982. 		return -1;
  4983. 	}
  4984.  
  4985. 	if ((id = atoi(message)) > 0)
  4986. 	{	//Acquired an ID
  4987. 		if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4988. 			id = 0; //Invalid id for either mobs or npcs.
  4989. 	}	else	{ //Acquired a Name
  4990. 		if ((id = mobdb_searchname(message)) == 0)
  4991. 		{
  4992. 			struct npc_data* nd = npc_name2id(message);
  4993. 			if (nd != NULL)
  4994. 				id = nd->class_;
  4995. 		}
  4996. 	}
  4997.  
  4998. 	if (id == 0)
  4999. 	{
  5000. 		clif_displaymessage(fd, msg_txt(123));	// Invalid Monster/NPC name/ID specified.
  5001. 		return -1;
  5002. 	}
  5003.  
  5004. 	if(pc_isriding(sd))
  5005. 	{
  5006. 		//FIXME: wrong message [ultramage]
  5007. 		//clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  5008. 		return -1;
  5009. 	}
  5010.  
  5011. 	pc_disguise(sd, id);
  5012. 	clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5013.  
  5014. 	return 0;
  5015. }
  5016.  
  5017. /*==========================================
  5018.  * DisguiseAll
  5019.  *------------------------------------------*/
  5020. ACMD_FUNC(disguiseall)
  5021. {
  5022. 	int mob_id=0;
  5023. 	struct map_session_data *pl_sd;
  5024. 	struct s_mapiterator* iter;
  5025. 	nullpo_retr(-1, sd);
  5026.  
  5027. 	if (!message || !*message) {
  5028. 		clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  5029. 		return -1;
  5030. 	}
  5031.  
  5032. 	if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5033. 		mob_id = atoi(message);
  5034.  
  5035. 	if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  5036. 		clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  5037. 		return -1;
  5038. 	}
  5039.  
  5040. 	iter = mapit_getallusers();
  5041. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  5042. 		pc_disguise(pl_sd, mob_id);
  5043. 	mapit_free(iter);
  5044.  
  5045. 	clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5046. 	return 0;
  5047. }
  5048.  
  5049. /*==========================================
  5050.  * @undisguise by [Yor]
  5051.  *------------------------------------------*/
  5052. ACMD_FUNC(undisguise)
  5053. {
  5054. 	nullpo_retr(-1, sd);
  5055. 	if (sd->disguise) {
  5056. 		pc_disguise(sd, 0);
  5057. 		clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5058. 	} else {
  5059. 		clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5060. 		return -1;
  5061. 	}
  5062.  
  5063. 	return 0;
  5064. }
  5065.  
  5066. /*==========================================
  5067.  * UndisguiseAll
  5068.  *------------------------------------------*/
  5069. ACMD_FUNC(undisguiseall)
  5070. {
  5071. 	struct map_session_data *pl_sd;
  5072. 	struct s_mapiterator* iter;
  5073. 	nullpo_retr(-1, sd);
  5074.  
  5075. 	iter = mapit_getallusers();
  5076. 	for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  5077. 		if( pl_sd->disguise )
  5078. 			pc_disguise(pl_sd, 0);
  5079. 	mapit_free(iter);
  5080.  
  5081. 	clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5082.  
  5083. 	return 0;
  5084. }
  5085.  
  5086. /*==========================================
  5087.  * @exp by [Skotlex]
  5088.  *------------------------------------------*/
  5089. ACMD_FUNC(exp)
  5090. {
  5091. 	char output[CHAT_SIZE_MAX];
  5092. 	double nextb, nextj;
  5093. 	nullpo_retr(-1, sd);
  5094. 	memset(output, '\0', sizeof(output));
  5095.  
  5096. 	nextb = pc_nextbaseexp(sd);
  5097. 	if (nextb)
  5098. 		nextb = sd->status.base_exp*100.0/nextb;
  5099.  
  5100. 	nextj = pc_nextjobexp(sd);
  5101. 	if (nextj)
  5102. 		nextj = sd->status.job_exp*100.0/nextj;
  5103.  
  5104. 	sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5105. 	clif_displaymessage(fd, output);
  5106. 	return 0;
  5107. }
  5108.  
  5109.  
  5110. /*==========================================
  5111.  * @broadcast by [Valaris]
  5112.  *------------------------------------------*/
  5113. ACMD_FUNC(broadcast)
  5114. {
  5115. 	nullpo_retr(-1, sd);
  5116.  
  5117. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  5118.  
  5119. 	if (!message || !*message) {
  5120. 		clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5121. 		return -1;
  5122. 	}
  5123.  
  5124. 	sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5125. 	intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  5126.  
  5127. 	return 0;
  5128. }
  5129.  
  5130. /*==========================================
  5131.  * @localbroadcast by [Valaris]
  5132.  *------------------------------------------*/
  5133. ACMD_FUNC(localbroadcast)
  5134. {
  5135. 	nullpo_retr(-1, sd);
  5136.  
  5137. 	memset(atcmd_output, '\0', sizeof(atcmd_output));
  5138.  
  5139. 	if (!message || !*message) {
  5140. 		clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5141. 		return -1;
  5142. 	}
  5143.  
  5144. 	sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5145.  
  5146. 	clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  5147.  
  5148. 	return 0;
  5149. }
  5150.  
  5151. /*==========================================
  5152.  * @email <actual@email> <new@email> by [Yor]
  5153.  *------------------------------------------*/
  5154. ACMD_FUNC(email)
  5155. {
  5156. 	char actual_email[100];
  5157. 	char new_email[100];
  5158. 	nullpo_retr(-1, sd);
  5159.  
  5160. 	memset(actual_email, '\0', sizeof(actual_email));
  5161. 	memset(new_email, '\0', sizeof(new_email));
  5162.  
  5163. 	if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5164. 		clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5165. 		return -1;
  5166. 	}
  5167.  
  5168. 	if (e_mail_check(actual_email) == 0) {
  5169. 		clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give [email protected].
  5170. 		return -1;
  5171. 	} else if (e_mail_check(new_email) == 0) {
  5172. 		clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5173. 		return -1;
  5174. 	} else if (strcmpi(new_email, "[email protected]") == 0) {
  5175. 		clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5176. 		return -1;
  5177. 	} else if (strcmpi(actual_email, new_email) == 0) {
  5178. 		clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5179. 		return -1;
  5180. 	}
  5181.  
  5182. 	chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5183. 	clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5184. 	return 0;
  5185. }
  5186.  
  5187. /*==========================================
  5188.  *@effect
  5189.  *------------------------------------------*/
  5190. ACMD_FUNC(effect)
  5191. {
  5192. 	int type = 0, flag = 0;
  5193. 	nullpo_retr(-1, sd);
  5194.  
  5195. 	if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  5196. 		clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  5197. 		return -1;
  5198. 	}
  5199.  
  5200. 	clif_specialeffect(&sd->bl, type, (send_target)flag);
  5201. 	clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5202. 	return 0;
  5203. }
  5204.  
  5205. /*==========================================
  5206.  * @killer by MouseJstr
  5207.  * enable killing players even when not in pvp
  5208.  *------------------------------------------*/
  5209. ACMD_FUNC(killer)
  5210. {
  5211. 	nullpo_retr(-1, sd);
  5212. 	sd->state.killer = !sd->state.killer;
  5213.  
  5214. 	if(sd->state.killer)
  5215. 		clif_displaymessage(fd, msg_txt(241));
  5216. 	else {
  5217. 		clif_displaymessage(fd, msg_txt(287));
  5218. 		pc_stop_attack(sd);
  5219. 	}
  5220. 	return 0;
  5221. }
  5222.  
  5223. /*==========================================
  5224.  * @killable by MouseJstr
  5225.  * enable other people killing you
  5226.  *------------------------------------------*/
  5227. ACMD_FUNC(killable)
  5228. {
  5229. 	nullpo_retr(-1, sd);
  5230. 	sd->state.killable = !sd->state.killable;
  5231.  
  5232. 	if(sd->state.killable)
  5233. 		clif_displaymessage(fd, msg_txt(242));
  5234. 	else {
  5235. 		clif_displaymessage(fd, msg_txt(288));
  5236. 		map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  5237. 	}
  5238. 	return 0;
  5239. }
  5240.  
  5241. /*==========================================
  5242.  * @skillon by MouseJstr
  5243.  * turn skills on for the map
  5244.  *------------------------------------------*/
  5245. ACMD_FUNC(skillon)
  5246. {
  5247. 	nullpo_retr(-1, sd);
  5248. 	map[sd->bl.m].flag.noskill = 0;
  5249. 	clif_displaymessage(fd, msg_txt(244));
  5250. 	return 0;
  5251. }
  5252.  
  5253. /*==========================================
  5254.  * @skilloff by MouseJstr
  5255.  * Turn skills off on the map
  5256.  *------------------------------------------*/
  5257. ACMD_FUNC(skilloff)
  5258. {
  5259. 	nullpo_retr(-1, sd);
  5260. 	map[sd->bl.m].flag.noskill = 1;
  5261. 	clif_displaymessage(fd, msg_txt(243));
  5262. 	return 0;
  5263. }
  5264.  
  5265. /*==========================================
  5266.  * @npcmove by MouseJstr
  5267.  * move a npc
  5268.  *------------------------------------------*/
  5269. ACMD_FUNC(npcmove)
  5270. {
  5271. 	int x = 0, y = 0, m;
  5272. 	struct npc_data *nd = 0;
  5273. 	nullpo_retr(-1, sd);
  5274. 	memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  5275.  
  5276. 	if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  5277. 		clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  5278. 		return -1;
  5279. 	}
  5280.  
  5281. 	if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  5282. 	{
  5283. 		clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5284. 		return -1;
  5285. 	}
  5286.  
  5287. 	if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  5288. 	{
  5289. 		clif_displaymessage(fd, "NPC is not on this map.");
  5290. 		return -1;	//Not on a map.
  5291. 	}
  5292.  
  5293. 	x = cap_value(x, 0, map[m].xs-1);
  5294. 	y = cap_value(y, 0, map[m].ys-1);
  5295. 	map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5296. 	map_moveblock(&nd->bl, x, y, gettick());
  5297. 	map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5298. 	clif_displaymessage(fd, "NPC moved.");
  5299.  
  5300. 	return 0;
  5301. }
  5302.  
  5303. /*==========================================
  5304.  * @addwarp by MouseJstr
  5305.  * Create a new static warp point.
  5306.  *------------------------------------------*/
  5307. ACMD_FUNC(addwarp)
  5308. {
  5309. 	char mapname[32];
  5310. 	int x,y;
  5311. 	unsigned short m;
  5312. 	struct npc_data* nd;
  5313.  
  5314. 	nullpo_retr(-1, sd);
  5315.  
  5316. 	if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  5317. 		clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  5318. 		return -1;
  5319. 	}
  5320.  
  5321. 	m = mapindex_name2id(mapname);
  5322. 	if( m == 0 )
  5323. 	{
  5324. 		sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  5325. 		clif_displaymessage(fd, atcmd_output);
  5326. 		return -1;
  5327. 	}
  5328.  
  5329. 	nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5330. 	if( nd == NULL )
  5331. 		return -1;
  5332.  
  5333. 	sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  5334. 	clif_displaymessage(fd, atcmd_output);
  5335. 	return 0;
  5336. }
  5337.  
  5338. /*==========================================
  5339.  * @follow by [MouseJstr]
  5340.  * Follow a player .. staying no more then 5 spaces away
  5341.  *------------------------------------------*/
  5342. ACMD_FUNC(follow)
  5343. {
  5344. 	struct map_session_data *pl_sd = NULL;
  5345. 	nullpo_retr(-1, sd);
  5346.  
  5347. 	if (!message || !*message) {
  5348. 		if (sd->followtarget == -1)
  5349. 			return -1;
  5350.  
  5351. 		pc_stop_following (sd);
  5352. 		clif_displaymessage(fd, "Follow mode OFF.");
  5353. 		return 0;
  5354. 	}
  5355.  
  5356. 	if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5357. 	{
  5358. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5359. 		return -1;
  5360. 	}
  5361.  
  5362. 	if (sd->followtarget == pl_sd->bl.id) {
  5363. 		pc_stop_following (sd);
  5364. 		clif_displaymessage(fd, "Follow mode OFF.");
  5365. 	} else {
  5366. 		pc_follow(sd, pl_sd->bl.id);
  5367. 		clif_displaymessage(fd, "Follow mode ON.");
  5368. 	}
  5369.  
  5370. 	return 0;
  5371. }
  5372.  
  5373.  
  5374. /*==========================================
  5375.  * @dropall by [MouseJstr]
  5376.  * Drop all your possession on the ground
  5377.  *------------------------------------------*/
  5378. ACMD_FUNC(dropall)
  5379. {
  5380. 	int i;
  5381. 	nullpo_retr(-1, sd);
  5382. 	for (i = 0; i < MAX_INVENTORY; i++) {
  5383. 	if (sd->status.inventory[i].amount) {
  5384. 		if(sd->status.inventory[i].equip != 0)
  5385. 			pc_unequipitem(sd, i, 3);
  5386. 			pc_dropitem(sd,  i, sd->status.inventory[i].amount);
  5387. 		}
  5388. 	}
  5389. 	return 0;
  5390. }
  5391.  
  5392. /*==========================================
  5393.  * @storeall by [MouseJstr]
  5394.  * Put everything into storage
  5395.  *------------------------------------------*/
  5396. ACMD_FUNC(storeall)
  5397. {
  5398. 	int i;
  5399. 	nullpo_retr(-1, sd);
  5400.  
  5401. 	if (sd->state.storage_flag != 1)
  5402.   	{	//Open storage.
  5403. 		if( storage_storageopen(sd) == 1 ) {
  5404. 			clif_displaymessage(fd, "You can't open the storage currently.");
  5405. 			return -1;
  5406. 		}
  5407. 	}
  5408.  
  5409. 	for (i = 0; i < MAX_INVENTORY; i++) {
  5410. 		if (sd->status.inventory[i].amount) {
  5411. 			if(sd->status.inventory[i].equip != 0)
  5412. 				pc_unequipitem(sd, i, 3);
  5413. 			storage_storageadd(sd,  i, sd->status.inventory[i].amount);
  5414. 		}
  5415. 	}
  5416. 	storage_storageclose(sd);
  5417.  
  5418. 	clif_displaymessage(fd, "It is done");
  5419. 	return 0;
  5420. }
  5421.  
  5422. /*==========================================
  5423.  * @skillid by [MouseJstr]
  5424.  * lookup a skill by name
  5425.  *------------------------------------------*/
  5426. ACMD_FUNC(skillid)
  5427. {
  5428. 	int skillen, idx;
  5429. 	nullpo_retr(-1, sd);
  5430.  
  5431. 	if (!message || !*message)
  5432. 	{
  5433. 		clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5434. 		return -1;
  5435. 	}
  5436.  
  5437. 	skillen = strlen(message);
  5438.  
  5439. 	for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5440. 		if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5441. 		{
  5442. 			sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5443. 			clif_displaymessage(fd, atcmd_output);
  5444. 		}
  5445. 	}
  5446.  
  5447. 	return 0;
  5448. }
  5449.  
  5450. /*==========================================
  5451.  * @useskill by [MouseJstr]
  5452.  * A way of using skills without having to find them in the skills menu
  5453.  *------------------------------------------*/
  5454. ACMD_FUNC(useskill)
  5455. {
  5456. 	struct map_session_data *pl_sd = NULL;
  5457. 	struct block_list *bl;
  5458. 	int skillnum;
  5459. 	int skilllv;
  5460. 	char target[100];
  5461. 	nullpo_retr(-1, sd);
  5462.  
  5463. 	if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5464. 		clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5465. 		return -1;
  5466. 	}
  5467.  
  5468. 	if ( (pl_sd = map_nick2sd(target)) == NULL )
  5469. 	{
  5470. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5471. 		return -1;
  5472. 	}
  5473.  
  5474. 	if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5475. 	{
  5476. 		clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5477. 		return -1;
  5478. 	}
  5479.  
  5480. 	if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5481. 		&& sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5482. 		bl = &sd->hd->bl;
  5483. 	else
  5484. 		bl = &sd->bl;
  5485.  
  5486. 	if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5487. 		unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5488. 	else
  5489. 		unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5490.  
  5491. 	return 0;
  5492. }
  5493.  
  5494. /*==========================================
  5495.  * @displayskill by [Skotlex]
  5496.  *  Debug command to locate new skill IDs. It sends the
  5497.  *  three possible skill-effect packets to the area.
  5498.  *------------------------------------------*/
  5499. ACMD_FUNC(displayskill)
  5500. {
  5501. 	struct status_data * status;
  5502. 	unsigned int tick;
  5503. 	int skillnum;
  5504. 	int skilllv = 1;
  5505. 	nullpo_retr(-1, sd);
  5506.  
  5507. 	if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5508. 	{
  5509. 		clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5510. 		return -1;
  5511. 	}
  5512. 	status = status_get_status_data(&sd->bl);
  5513. 	tick = gettick();
  5514. 	clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5515. 	clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5516. 	clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5517. 	return 0;
  5518. }
  5519.  
  5520. /*==========================================
  5521.  * @skilltree by [MouseJstr]
  5522.  * prints the skill tree for a player required to get to a skill
  5523.  *------------------------------------------*/
  5524. ACMD_FUNC(skilltree)
  5525. {
  5526. 	struct map_session_data *pl_sd = NULL;
  5527. 	int skillnum;
  5528. 	int meets, j, c=0;
  5529. 	char target[NAME_LENGTH];
  5530. 	struct skill_tree_entry *ent;
  5531. 	nullpo_retr(-1, sd);
  5532.  
  5533. 	if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5534. 		clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5535. 		return -1;
  5536. 	}
  5537.  
  5538. 	if ( (pl_sd = map_nick2sd(target)) == NULL )
  5539. 	{
  5540. 		clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5541. 		return -1;
  5542. 	}
  5543.  
  5544. 	c = pc_calc_skilltree_normalize_job(pl_sd);
  5545. 	c = pc_mapid2jobid(c, pl_sd->status.sex);
  5546.  
  5547. 	sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, NV_BASIC));
  5548. 	clif_displaymessage(fd, atcmd_output);
  5549.  
  5550. 	ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5551. 	if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5552. 	{
  5553. 		sprintf(atcmd_output, "I do not believe the player can use that skill");
  5554. 		clif_displaymessage(fd, atcmd_output);
  5555. 		return 0;
  5556. 	}
  5557.  
  5558. 	ent = &skill_tree[c][j];
  5559.  
  5560. 	meets = 1;
  5561. 	for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5562. 	{
  5563. 		if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5564. 		{
  5565. 			sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5566. 			clif_displaymessage(fd, atcmd_output);
  5567. 			meets = 0;
  5568. 		}
  5569. 	}
  5570. 	if (meets == 1) {
  5571. 		sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5572. 		clif_displaymessage(fd, atcmd_output);
  5573. 	}
  5574.  
  5575. 	return 0;
  5576. }
  5577.  
  5578. // Hand a ring with partners name on it to this char
  5579. void getring (struct map_session_data* sd)
  5580. {
  5581. 	int flag, item_id;
  5582. 	struct item item_tmp;
  5583. 	item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5584.  
  5585. 	memset(&item_tmp, 0, sizeof(item_tmp));
  5586. 	item_tmp.nameid = item_id;
  5587. 	item_tmp.identify = 1;
  5588. 	item_tmp.card[0] = 255;
  5589. 	item_tmp.card[2] = sd->status.partner_id;
  5590. 	item_tmp.card[3] = sd->status.partner_id >> 16;
  5591.  
  5592. 	if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5593. 		clif_additem(sd,0,0,flag);
  5594. 		map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5595. 	}
  5596. }
  5597.  
  5598. /*==========================================
  5599.  * @marry by [MouseJstr], fixed by Lupus
  5600.  * Marry two players
  5601.  *------------------------------------------*/
  5602. ACMD_FUNC(marry)
  5603. {
  5604. 	struct map_session_data *pl_sd = NULL;
  5605. 	char player_name[NAME_LENGTH] = "";
  5606.  
  5607. 	nullpo_retr(-1, sd);
  5608.  
  5609. 	if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  5610. 		clif_displaymessage(fd, "Usage: @marry <player name>");
  5611. 		return -1;
  5612. 	}
  5613.  
  5614. 	if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  5615. 		clif_displaymessage(fd, msg_txt(3));
  5616. 		return -1;
  5617. 	}
  5618.  
  5619. 	if (pc_marriage(sd, pl_sd) == 0) {
  5620. 		clif_displaymessage(fd, "They are married.. wish them well.");
  5621. 		clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5622. 		getring(sd); // Auto-give named rings (Aru)
  5623. 		getring(pl_sd);
  5624. 		return 0;
  5625. 	}
  5626.  
  5627. 	clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5628. 	return -1;
  5629. }
  5630.  
  5631. /*==========================================
  5632.  * @divorce by [MouseJstr], fixed by [Lupus]
  5633.  * divorce two players
  5634.  *------------------------------------------*/
  5635. ACMD_FUNC(divorce)
  5636. {
  5637. 	nullpo_retr(-1, sd);
  5638.  
  5639. 	if (pc_divorce(sd) != 0) {
  5640. 		sprintf(atcmd_output, "'%s' is not married.", sd->status.name);
  5641. 		clif_displaymessage(fd, atcmd_output);
  5642. 		return -1;
  5643. 	}
  5644.  
  5645. 	sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", sd->status.name);
  5646. 	clif_displaymessage(fd, atcmd_output);
  5647. 	return 0;
  5648. }
  5649.  
  5650. /*==========================================
  5651.  * @changelook by [Celest]
  5652.  *------------------------------------------*/
  5653. ACMD_FUNC(changelook)
  5654. {
  5655. 	int i, j = 0, k = 0;
  5656. 	int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  5657.  
  5658. 	if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5659. 		clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5660. 		clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe");
  5661. 		return -1;
  5662. 	} else if ( i == 2 ) {
  5663. 		if (j < 1 || j > 7)
  5664. 			j = 1;
  5665. 		j = pos[j - 1];
  5666. 	} else if( i == 1 ) {	// position not defined, use HEAD_TOP as default
  5667. 		k = j;	// swap
  5668. 		j = LOOK_HEAD_TOP;
  5669. 	}
  5670.  
  5671. 	clif_changelook(&sd->bl,j,k);
  5672.  
  5673. 	return 0;
  5674. }
  5675.  
  5676. /*==========================================
  5677.  * @autotrade by durf [Lupus] [Paradox924X]
  5678.  * Turns on/off Autotrade for a specific player
  5679.  *------------------------------------------*/
  5680. ACMD_FUNC(autotrade)
  5681. {
  5682. 	nullpo_retr(-1, sd);
  5683.  
  5684. 	if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5685. 		clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5686. 		return -1;
  5687. 	}
  5688.  
  5689. 	if( pc_isdead(sd) ) {
  5690. 		clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5691. 		return -1;
  5692. 	}
  5693.  
  5694. 	if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5695. 		clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5696. 		return -1;
  5697. 	}
  5698.  
  5699. 	sd->state.autotrade = 1;
  5700. 	if( battle_config.at_timeout )
  5701. 	{
  5702. 		int timeout = atoi(message);
  5703. 		status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5704. 	}
  5705. 	clif_authfail_fd(fd, 15);
  5706.  
  5707. 	return 0;
  5708. }
  5709.  
  5710. /*==========================================
  5711.  * @changegm by durf (changed by Lupus)
  5712.  * Changes Master of your Guild to a specified guild member
  5713.  *------------------------------------------*/
  5714. ACMD_FUNC(changegm)
  5715. {
  5716. 	struct guild *g;
  5717. 	struct map_session_data *pl_sd;
  5718. 	nullpo_retr(-1, sd);
  5719.  
  5720. 	if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp