diff options
author | Philipp Sehmisch <mana@crushnet.org> | 2010-08-29 14:54:14 +0200 |
---|---|---|
committer | Freeyorp <Freeyorp101@hotmail.com> | 2010-08-30 02:12:54 +1200 |
commit | 64432a11e3135d82c37c65b6c8560312091453cd (patch) | |
tree | 41dee6e861ab321357e8e36ae32cae7e03ad1dfc /src/game-server/commandhandler.cpp | |
parent | 7fc50c2d31e1d289e9d2a950271c6d399fe0896a (diff) | |
download | manaserv-64432a11e3135d82c37c65b6c8560312091453cd.tar.gz manaserv-64432a11e3135d82c37c65b6c8560312091453cd.tar.bz2 manaserv-64432a11e3135d82c37c65b6c8560312091453cd.tar.xz manaserv-64432a11e3135d82c37c65b6c8560312091453cd.zip |
Added @mute chat command.
The @mute command stops another character from talking in the
public chat for a specified amount of seconds. It doesn't survive
a reconnect of the client, but I don't think that this is necessary
because a mute by a GM is usually intended as a slap on the wrist
with more severe consequences to follow (like @ban).
Diffstat (limited to 'src/game-server/commandhandler.cpp')
-rw-r--r-- | src/game-server/commandhandler.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index cf5673ba..eb894b5c 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -32,6 +32,7 @@ #include "game-server/monstermanager.hpp" #include "game-server/state.hpp" +#include "common/configuration.hpp" #include "common/permissionmanager.hpp" #include "common/transaction.hpp" @@ -63,6 +64,7 @@ static void handleGivePermission(Character*, std::string&); static void handleTakePermission(Character*, std::string&); static void handleAnnounce(Character*, std::string&); static void handleHistory(Character*, std::string&); +static void handleMute(Character*, std::string&); static CmdRef const cmdRef[] = { @@ -102,6 +104,8 @@ static CmdRef const cmdRef[] = "Sends a chat message to all characters in the game", &handleAnnounce}, {"history", "<number of transactions>", "Shows the last transactions", &handleHistory}, + {"mute","<character> <length in seconds>", + "Prevents the character from talking for the specified number of seconds. Use 0 seconds to unmute.", &handleMute}, {NULL, NULL, NULL, NULL} }; @@ -923,6 +927,54 @@ static void handleHistory(Character *player, std::string &args) } +static void handleMute(Character *player, std::string &args) +{ Character *other; + int length; + + // get arguments + std::string character = getArgument(args); + std::string valuestr = getArgument(args); + + + // check for valid player + other = getPlayer(character); + if (!other) + { + say("Invalid character", player); + return; + } + + // change the length to an integer + if (valuestr.empty()) + { + length = Configuration::getValue("defaultMuteLength", 60); + } else { + length = utils::stringToInt(valuestr); + } + if (length < 0) + { + say("Invalid length, using default", player); + length = Configuration::getValue("defaultMuteLength", 60); + } + + // mute the player + other->mute(length); + + // feedback + std::stringstream targetMsg; + std::stringstream userMsg; + if (length > 0) + { + targetMsg << player->getName() << " muted you for " << length << " seconds."; + userMsg << "You muted " << other->getName() << " for " << length << " seconds."; + } else { + targetMsg << player->getName() << " unmuted you."; + userMsg << "You unmuted " << other->getName() << "."; + } + GameState::sayTo(other, NULL, targetMsg.str()); + GameState::sayTo(player, NULL, userMsg.str()); +} + void CommandHandler::handleCommand(Character *player, const std::string &command) { |