diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2011-08-31 17:48:11 +0800 |
---|---|---|
committer | Yohann Ferreira <yohann.ferreira@orange.fr> | 2011-09-01 04:35:33 +0800 |
commit | 23bb714fe1447d0e51a7e61786a1fd9f7e031abf (patch) | |
tree | b4cd8d0837fc3ec3af966fad620ebac2eaa6b9ef /src/game-server/commandhandler.cpp | |
parent | 4f0ebc30c5a5d35226931ec8cc463dac13d979e5 (diff) | |
download | manaserv-23bb714fe1447d0e51a7e61786a1fd9f7e031abf.tar.gz manaserv-23bb714fe1447d0e51a7e61786a1fd9f7e031abf.tar.bz2 manaserv-23bb714fe1447d0e51a7e61786a1fd9f7e031abf.tar.xz manaserv-23bb714fe1447d0e51a7e61786a1fd9f7e031abf.zip |
Added chatcommand to get position of a character.
Add chatcommand @getpos <character> which return the mapid and location of the character.
Part of: Mana-Mantis: #385.
Diffstat (limited to 'src/game-server/commandhandler.cpp')
-rw-r--r-- | src/game-server/commandhandler.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index 189da538..0cde9891 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -76,6 +76,7 @@ static void handleLog(Character*, std::string&); static void handleLogsay(Character*, std::string&); static void handleKillMonsters(Character*, std::string&); static void handleCraft(Character*, std::string&); +static void handleGetPos(Character*, std::string&); static CmdRef const cmdRef[] = { @@ -133,6 +134,8 @@ static CmdRef const cmdRef[] = "Kills all monsters on the map.", &handleKillMonsters}, {"craft", "{ <item> <amount> }", "Crafts something.", &handleCraft}, + {"getpos", "<character>", + "Gets the position of a character.", &handleGetPos}, {NULL, NULL, NULL, NULL} }; @@ -1377,6 +1380,36 @@ static void handleCraft(Character *player, std::string &args) } } +static void handleGetPos(Character *player, std::string &args) +{ + std::string character = getArgument(args); + if (character.empty()) + { + say("Invalid amount of arguments given.", player); + say("Usage: @getpos <character>", player); + return; + } + Character *other; + other = getPlayer(character); + if (!other) + { + say("Invalid character, or they are offline.", player); + return; + } + const Point &pos = other->getPosition(); + std::stringstream str; + str << "The current location of " + << character + << " is map " + << other->getMapId() + << " [" + << pos.x + << ":" + << pos.y + << "]"; + say(str.str(), player); +} + void CommandHandler::handleCommand(Character *player, const std::string &command) { |