summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/serverdata/permissions.xml1
-rw-r--r--src/game-server/commandhandler.cpp33
2 files changed, 34 insertions, 0 deletions
diff --git a/example/serverdata/permissions.xml b/example/serverdata/permissions.xml
index c07bfae2..6ad941d6 100644
--- a/example/serverdata/permissions.xml
+++ b/example/serverdata/permissions.xml
@@ -22,6 +22,7 @@
<allow>@attribute</allow>
<allow>@charwarp</allow>
<allow>@killmonsters</allow>
+ <allow>@getpos</allow>
</class>
<class level="4">
<alias>gm</alias>
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)
{