summaryrefslogtreecommitdiff
path: root/src/game-server/commandhandler.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-12-27 18:11:27 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-12-27 18:11:27 +0100
commitd1ac4d5cd3b605526f2b1a3caa3339718962d415 (patch)
tree2b8e43ae739eed4583d9a82c7d9613fd781a930f /src/game-server/commandhandler.cpp
parenta1514113093733b65e36224dad81f6867edcb93c (diff)
downloadmanaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.tar.gz
manaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.tar.bz2
manaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.tar.xz
manaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.zip
Added @kick and @kill commands.
@kick disconnects the client connection of a character. The new error- code 11 (ERRMSG_ADMINISTRATIVE_LOGOFF) is not supported by the client yet. It will show a generic "The connection to server was lost" message instead. @kill kills the character by setting its HP to 0. Added @kick transaction code I forgot in last commit. Considering that this was just minutes ago I think that noone updated his database yet. So I don't think that a new database version is justified for this. Reviewed-by: Bertram
Diffstat (limited to 'src/game-server/commandhandler.cpp')
-rw-r--r--src/game-server/commandhandler.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 5fbcb211..ef0b6017 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -68,6 +68,8 @@ static void handleAnnounce(Character*, std::string&);
static void handleHistory(Character*, std::string&);
static void handleMute(Character*, std::string&);
static void handleDie(Character*, std::string&);
+static void handleKill(Character*, std::string&);
+static void handleKick(Character*, std::string&);
static CmdRef const cmdRef[] =
{
@@ -113,6 +115,10 @@ static CmdRef const cmdRef[] =
"Prevents the character from talking for the specified number of seconds. Use 0 seconds to unmute.", &handleMute},
{"die", "",
"Kills you.", &handleDie},
+ {"kill", "<character>",
+ "Kills the character.", &handleKill},
+ {"kick", "<character>",
+ "Disconnects the client of character.", &handleKick},
{NULL, NULL, NULL, NULL}
};
@@ -1119,6 +1125,71 @@ static void handleDie(Character *player, std::string &args)
say("You've killed yourself.", player);
}
+static void handleKill(Character *player, std::string &args)
+{
+ Character *other;
+
+ // get arguments
+ std::string character = getArgument(args);
+
+ // check for valid player
+ other = getPlayer(character);
+ if (!other)
+ {
+ say("Invalid character", player);
+ return;
+ }
+
+ // kill the player
+ player->setAttribute(ATTR_HP, 0);
+
+ // feedback
+ std::stringstream targetMsg;
+ std::stringstream userMsg;
+ targetMsg << "You were killed by server command from "<< player->getName() << ".";
+ userMsg << "You killed " << other->getName() << ".";
+ say(targetMsg.str(), other);
+ say(userMsg.str(), player);
+
+ // log transaction
+ std::stringstream logMsg;
+ logMsg << "User killed " << other->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_KILL, logMsg.str());
+}
+
+static void handleKick(Character *player, std::string &args)
+{
+ Character *other;
+
+ // get arguments
+ std::string character = getArgument(args);
+
+ // check for valid player
+ other = getPlayer(character);
+ if (!other)
+ {
+ say("Invalid character", player);
+ return;
+ }
+
+ // send feedback
+ std::stringstream userMsg;
+ userMsg << "You kicked " << other->getName() << ".";
+ say(userMsg.str(), player);
+
+ // disconnect the client
+ MessageOut msg(GPMSG_CONNECT_RESPONSE);
+ msg.writeInt8(ERRMSG_ADMINISTRATIVE_LOGOFF);
+ other->getClient()->disconnect(msg);
+
+ // log transaction
+ std::stringstream logMsg;
+ logMsg << "User kicked " << other->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_KICK, logMsg.str());
+}
+
+
+
void CommandHandler::handleCommand(Character *player,
const std::string &command)
{