Skip to content

Commit c3d6ff6

Browse files
committed
2 parents 5910791 + 5f4774c commit c3d6ff6

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

data/libs/systems/features.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Features = {
33
ChainSystem = "chainSystem",
44
EmoteSpells = "emoteSpells",
55
SpellNameInsteadOfWords = "spellNameInsteadOfWords",
6+
MutePlayer = "mutePlayer",
67
}
78

89
local function validateFeature(feature)

data/scripts/talkactions/god/mute.lua

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
local mute = TalkAction("/mute")
2+
3+
function mute.onSay(player, words, param)
4+
-- create log
5+
logCommand(player, words, param)
6+
7+
if param == "" then
8+
player:sendCancelMessage("You must specify a player. Usage: /mute playerName.")
9+
return true
10+
end
11+
12+
local split = param:split(",")
13+
local targetName = split[1]:trim()
14+
local target = Player(targetName)
15+
16+
if not target then
17+
player:sendCancelMessage("A player with that name is not online.")
18+
return true
19+
end
20+
21+
if target:getGroup():getId() >= GROUP_TYPE_GAMEMASTER then
22+
player:sendCancelMessage("You cannot mute this character.")
23+
return true
24+
end
25+
26+
target:setFeature(Features.MutePlayer, true)
27+
player:popupFYI(target:getName() .. " has been muted.")
28+
return true
29+
end
30+
31+
mute:separator(" ")
32+
mute:groupType("god")
33+
mute:register()
34+
35+
---------------- // ----------------
36+
local unmute = TalkAction("/unmute")
37+
38+
function unmute.onSay(player, words, param)
39+
-- create log
40+
logCommand(player, words, param)
41+
42+
if param == "" then
43+
player:sendCancelMessage("You must specify a player. Usage: /unmute playerName.")
44+
return true
45+
end
46+
47+
local targetName = param:trim()
48+
local target = Player(targetName)
49+
50+
if not target then
51+
player:sendCancelMessage("A player with that name is not online.")
52+
return true
53+
end
54+
55+
target:setFeature(Features.MutePlayer, false)
56+
player:popupFYI(target:getName() .. " has been unmuted.")
57+
return true
58+
end
59+
60+
unmute:separator(" ")
61+
unmute:groupType("god")
62+
unmute:register()

markdowns/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Added new flags: `CanMoveFromFar`, `HasFullLight`, `AllowIdle`, `CanWearAllMounts`, and `NotGainUnjustified`. ([Tryller](https://github.com/jprzimba))
1111
- Added Vibrancy imbuement. ([pennaor](https://github.com/pennaor))
1212
- Added Soul Pit arena/animus mastery/soul core. ([FelipePaluco](https://github.com/FelipePaluco))
13+
- Added a new command `/mute`, which will mute a player until unmuted by `/unmute`. ([Tryller](https://github.com/jprzimba))
1314
- Cyclopedia House Auction system. ([murilo09](https://github.com/murilo09))
1415
- Updated name change functionality to save old player names in a database table called `player_oldnames`. ([Tryller](https://github.com/jprzimba))
1516

src/creatures/players/player.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,6 +5278,20 @@ bool Player::checkSpellNameInsteadOfWords() const {
52785278
return false;
52795279
}
52805280

5281+
bool Player::checkMute() const {
5282+
auto featureKV = kv()->scoped("features")->get("mutePlayer");
5283+
if (featureKV.has_value()) {
5284+
auto value = featureKV->get<bool>();
5285+
if (value) {
5286+
return true;
5287+
} else {
5288+
return false;
5289+
}
5290+
}
5291+
5292+
return false;
5293+
}
5294+
52815295
QuickLootFilter_t Player::getQuickLootFilter() const {
52825296
return quickLootFilter;
52835297
}

src/creatures/players/player.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
12441244
bool checkChainSystem() const;
12451245
bool checkEmoteSpells() const;
12461246
bool checkSpellNameInsteadOfWords() const;
1247+
bool checkMute() const;
12471248

12481249
QuickLootFilter_t getQuickLootFilter() const;
12491250

src/game/game.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6234,6 +6234,13 @@ void Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, c
62346234
return;
62356235
}
62366236

6237+
if (player->checkMute()) {
6238+
std::ostringstream ss;
6239+
ss << "- You have been forbidden to speak.";
6240+
player->sendTextMessage(MESSAGE_FAILURE, ss.str());
6241+
return;
6242+
}
6243+
62376244
uint32_t muteTime = player->isMuted();
62386245
if (muteTime > 0) {
62396246
std::ostringstream ss;

0 commit comments

Comments
 (0)