Skip to content

Commit

Permalink
Merge pull request #32 from jprzimba/feature-mute
Browse files Browse the repository at this point in the history
[FEATURE] Command /mute and /unmute
  • Loading branch information
jprzimba authored Jan 30, 2025
2 parents 7c4017a + fed60a5 commit 5f4774c
Showing 6 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/libs/systems/features.lua
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ Features = {
ChainSystem = "chainSystem",
EmoteSpells = "emoteSpells",
SpellNameInsteadOfWords = "spellNameInsteadOfWords",
MutePlayer = "mutePlayer",
}

local function validateFeature(feature)
62 changes: 62 additions & 0 deletions data/scripts/talkactions/god/mute.lua
Original file line number Diff line number Diff line change
@@ -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, true)
player:popupFYI(target:getName() .. " has been muted.")
return true
end

mute:separator(" ")
mute:groupType("god")
mute:register()

---------------- // ----------------
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, false)
player:popupFYI(target:getName() .. " has been unmuted.")
return true
end

unmute:separator(" ")
unmute:groupType("god")
unmute:register()
1 change: 1 addition & 0 deletions markdowns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
- Added new flags: `CanMoveFromFar`, `HasFullLight`, `AllowIdle`, `CanWearAllMounts`, and `NotGainUnjustified`. ([Tryller](https://github.com/jprzimba))
- Added Vibrancy imbuement. ([pennaor](https://github.com/pennaor))
- Added Soul Pit arena/animus mastery/soul core. ([FelipePaluco](https://github.com/FelipePaluco))
- Added a new command `/mute`, which will mute a player until unmuted by `/unmute`. ([Tryller](https://github.com/jprzimba))
- Cyclopedia House Auction system. ([murilo09](https://github.com/murilo09))
- Updated name change functionality to save old player names in a database table called `player_oldnames`. ([Tryller](https://github.com/jprzimba))

14 changes: 14 additions & 0 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
@@ -5278,6 +5278,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->get<bool>();
if (value) {
return true;
} else {
return false;
}
}

return false;
}

QuickLootFilter_t Player::getQuickLootFilter() const {
return quickLootFilter;
}
1 change: 1 addition & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
@@ -1244,6 +1244,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;

7 changes: 7 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
@@ -6234,6 +6234,13 @@ void Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, c
return;
}

if (player->checkMute()) {
std::ostringstream ss;
ss << "- You have been forbidden to speak.";
player->sendTextMessage(MESSAGE_FAILURE, ss.str());
return;
}

uint32_t muteTime = player->isMuted();
if (muteTime > 0) {
std::ostringstream ss;

0 comments on commit 5f4774c

Please sign in to comment.