diff --git a/data/libs/systems/features.lua b/data/libs/systems/features.lua index b6e25b24..87860a68 100644 --- a/data/libs/systems/features.lua +++ b/data/libs/systems/features.lua @@ -3,6 +3,7 @@ Features = { ChainSystem = "chainSystem", EmoteSpells = "emoteSpells", SpellNameInsteadOfWords = "spellNameInsteadOfWords", + MutePlayer = "mutePlayer", } local function validateFeature(feature) diff --git a/data/scripts/talkactions/god/mute.lua b/data/scripts/talkactions/god/mute.lua new file mode 100644 index 00000000..b3f4db23 --- /dev/null +++ b/data/scripts/talkactions/god/mute.lua @@ -0,0 +1,62 @@ +local mute = TalkAction("/mute") + +function mute.onSay(player, words, param) + -- create log + logCommand(player, words, param) + + if param == "" then + player:sendCancelMessage("You must specify a player. Usage: /mute playerName.") + return true + end + + local split = param:split(",") + local targetName = split[1]:trim() + local target = Player(targetName) + + if not target then + player:sendCancelMessage("A player with that name is not online.") + return true + end + + if target:getGroup():getId() >= GROUP_TYPE_GAMEMASTER then + player:sendCancelMessage("You cannot mute this character.") + return true + end + + target:setFeature(Features.MutePlayer, 1) + player:popupFYI(target:getName() .. " has been muted.") + return true +end + +mute:separator(" ") +mute:groupType("god") +mute:register() + +-- Unmute player +local unmute = TalkAction("/unmute") + +function unmute.onSay(player, words, param) + -- create log + logCommand(player, words, param) + + if param == "" then + player:sendCancelMessage("You must specify a player. Usage: /unmute playerName.") + return true + end + + local targetName = param:trim() + local target = Player(targetName) + + if not target then + player:sendCancelMessage("A player with that name is not online.") + return true + end + + target:setFeature(Features.MutePlayer, 0) + player:popupFYI(target:getName() .. " has been unmuted.") + return true +end + +unmute:separator(" ") +unmute:groupType("god") +unmute:register() \ No newline at end of file diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 93449872..fced405e 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -5242,6 +5242,20 @@ bool Player::checkSpellNameInsteadOfWords() const { return false; } +bool Player::checkMute() const { + auto featureKV = kv()->scoped("features")->get("mutePlayer"); + if (featureKV.has_value()) { + auto value = featureKV->getNumber(); + if (value == 1) { + return true; + } else if (value == 0) { + return false; + } + } + + return false; +} + QuickLootFilter_t Player::getQuickLootFilter() const { return quickLootFilter; } diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index be8370d7..74f154a6 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -1227,6 +1227,7 @@ class Player final : public Creature, public Cylinder, public Bankable { bool checkChainSystem() const; bool checkEmoteSpells() const; bool checkSpellNameInsteadOfWords() const; + bool checkMute() const; QuickLootFilter_t getQuickLootFilter() const; diff --git a/src/game/game.cpp b/src/game/game.cpp index c9332144..df984cb8 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -6223,6 +6223,13 @@ void Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, c return; } + if (player->checkMute()) { + std::ostringstream ss; + ss << "You are unable to talk."; + player->sendTextMessage(MESSAGE_FAILURE, ss.str()); + return; + } + uint32_t muteTime = player->isMuted(); if (muteTime > 0) { std::ostringstream ss;