From e0911b7ab1254d80a6fed5c3c5fe63dd6d8bad7b Mon Sep 17 00:00:00 2001 From: Jessica James Date: Tue, 22 Oct 2019 18:06:09 -0500 Subject: [PATCH] Added MuteGamecommand --- .../RenX/RenX.Commands/RenX_Commands.cpp | 46 +++++++++++++++++++ .../RenX/RenX.Commands/RenX_Commands.h | 1 + 2 files changed, 47 insertions(+) diff --git a/src/Plugins/RenX/RenX.Commands/RenX_Commands.cpp b/src/Plugins/RenX/RenX.Commands/RenX_Commands.cpp index dfd4df5..d3c0eb6 100644 --- a/src/Plugins/RenX/RenX.Commands/RenX_Commands.cpp +++ b/src/Plugins/RenX/RenX.Commands/RenX_Commands.cpp @@ -3517,6 +3517,52 @@ const Jupiter::ReadableString &KickGameCommand::getHelp(const Jupiter::ReadableS GAME_COMMAND_INIT(KickGameCommand) +// Mute Game Command + +void MuteGameCommand::create() +{ + this->addTrigger(STRING_LITERAL_AS_REFERENCE("mute")); + this->setAccessLevel(1); +} + +void MuteGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString ¶meters) +{ + if (parameters.isNotEmpty()) + { + Jupiter::StringS name = Jupiter::StringS::getWord(parameters, 0, WHITESPACE); + Jupiter::StringS reason; + if (parameters.wordCount(WHITESPACE) > 1) { + reason = Jupiter::StringS::gotoWord(parameters, 1, WHITESPACE); + } + else { + reason = STRING_LITERAL_AS_REFERENCE("No reason"); + } + RenX::PlayerInfo *target = source->getPlayerByPartName(name); + if (target == nullptr) + source->sendMessage(*player, "Error: Player not found."_jrs); + else if (player == target) + source->sendMessage(*player, "Error: You cannot mute yourself."_jrs); + else if (target->access >= player->access) + source->sendMessage(*player, "Error: You can not mute higher level "_jrs + pluginInstance.getStaffTitle() + "s."_jrs); + else + { + source->mute(*target); + source->sendMessage(*target, "You have been muted for: "_jrs + reason); + source->sendMessage(*player, "Player has been muted from chat."_jrs); + } + } + else + source->sendMessage(*player, "Error: Too few parameters. Syntax: mute [Reason]"_jrs); +} + +const Jupiter::ReadableString &MuteGameCommand::getHelp(const Jupiter::ReadableString &) +{ + static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Mutes a player from chat. Syntax: mute [Reason]"); + return defaultHelp; +} + +GAME_COMMAND_INIT(MuteGameCommand) + // TempBan Game Command void TempBanGameCommand::create() diff --git a/src/Plugins/RenX/RenX.Commands/RenX_Commands.h b/src/Plugins/RenX/RenX.Commands/RenX_Commands.h index 470537e..8cbd3e3 100644 --- a/src/Plugins/RenX/RenX.Commands/RenX_Commands.h +++ b/src/Plugins/RenX/RenX.Commands/RenX_Commands.h @@ -112,6 +112,7 @@ GENERIC_GAME_COMMAND(DisarmC4GameCommand) GENERIC_GAME_COMMAND(DisarmBeaconGameCommand) GENERIC_GAME_COMMAND(MineBanGameCommand) GENERIC_GAME_COMMAND(KickGameCommand) +GENERIC_GAME_COMMAND(MuteGameCommand) GENERIC_GAME_COMMAND(TempBanGameCommand) GENERIC_GAME_COMMAND(TempChatBanGameCommand) GENERIC_GAME_COMMAND(KickBanGameCommand)