From 39e8b5c44689ba92303be9b36a30d0ad08ddde45 Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Tue, 21 Dec 2004 20:52:27 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@708 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/charcommand.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'src/map/charcommand.c') diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 2db2c8e84..893266396 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -47,6 +47,7 @@ CCMD_FUNC(itemlist); CCMD_FUNC(effect); CCMD_FUNC(storagelist); CCMD_FUNC(item); +CCMD_FUNC(warp); #ifdef TXT_ONLY /* TXT_ONLY */ @@ -80,6 +81,9 @@ static CharCommandInfo charcommand_info[] = { { CharCommandEffect, "#effect", 40, charcommand_effect }, { CharCommandStorageList, "#storagelist", 40, charcommand_storagelist }, { CharCommandItem, "#item", 60, charcommand_item }, + { CharCommandWarp, "#warp", 60, charcommand_warp }, + { CharCommandWarp, "#rura", 60, charcommand_warp }, + { CharCommandWarp, "#rura+", 60, charcommand_warp }, #ifdef TXT_ONLY /* TXT_ONLY */ @@ -1061,3 +1065,69 @@ int charcommand_item( return 0; } + +/*========================================== + * #warp/#rura/#rura+ + *------------------------------------------ + */ +int charcommand_warp( + const int fd, struct map_session_data* sd, + const char* command, const char* message) +{ + char map_name[100]; + char character[100]; + int x = 0, y = 0; + struct map_session_data *pl_sd; + int m; + + nullpo_retr(-1, sd); + + memset(map_name, '\0', sizeof(map_name)); + memset(character, '\0', sizeof(character)); + + if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4) { + clif_displaymessage(fd, "Usage: #warp/#rura/#rura+ "); + return -1; + } + + if (x <= 0) + x = rand() % 399 + 1; + if (y <= 0) + y = rand() % 399 + 1; + if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat) + strcat(map_name, ".gat"); + + if ((pl_sd = map_nick2sd(character)) != NULL) { + if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level + if (x > 0 && x < 400 && y > 0 && y < 400) { + m = map_mapname2mapid(map_name); + if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { + clif_displaymessage(fd, "You are not authorised to warp someone to this map."); + return -1; + } + if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { + clif_displaymessage(fd, "You are not authorised to warp this player from its actual map."); + return -1; + } + if (pc_setpos(pl_sd, map_name, x, y, 3) == 0) { + clif_displaymessage(pl_sd->fd, msg_table[0]); // Warped. + clif_displaymessage(fd, msg_table[15]); // Player warped (message sends to player too). + } else { + clif_displaymessage(fd, msg_table[1]); // Map not found. + return -1; + } + } else { + clif_displaymessage(fd, msg_table[2]); // Coordinates out of range. + return -1; + } + } else { + clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + return -1; + } + } else { + clif_displaymessage(fd, msg_table[3]); // Character not found. + return -1; + } + + return 0; +} -- cgit v1.2.3-60-g2f50