Add /toggleadverts

This commit is contained in:
MangosArentLiterature 2021-04-17 15:20:28 -05:00
parent 388ad345a5
commit e52d85c01a
2 changed files with 25 additions and 1 deletions

View File

@ -254,6 +254,11 @@ class AOClient : public QObject {
*/
bool pm_mute = false;
/**
* @brief If true, the client will recieve advertisements.
*/
bool advert_enabled = true;
/**
* @brief Timer for tracking user interaction. Automatically restarted whenever a user interacts (i.e. sends any packet besides CH)
*/
@ -1450,6 +1455,13 @@ class AOClient : public QObject {
*/
void cmdMutePM(int argc, QStringList argv);
/**
* @brief Toggles whether a client will recieve @ref cmdNeed "advertisement" messages.
*
* @details No arguments.
*/
void cmdToggleAdverts(int argc, QStringList argv);
///@}
/**
@ -1863,6 +1875,7 @@ class AOClient : public QObject {
{"allow_iniswap", {ACLFlags.value("CM"), 0, &AOClient::cmdAllowIniswap}},
{"afk", {ACLFlags.value("NONE"), 0, &AOClient::cmdAfk}},
{"mutepm", {ACLFlags.value("NONE"), 0, &AOClient::cmdMutePM}},
{"toggleadverts", {ACLFlags.value("NONE"), 0, &AOClient::cmdToggleAdverts}},
};
/**

View File

@ -77,7 +77,11 @@ void AOClient::cmdNeed(int argc, QStringList argv)
{
QString sender_area = server->area_names.value(current_area);
QString sender_message = argv.join(" ");
sendServerBroadcast({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."});
for (AOClient* client : server->clients) {
if (client->advert_enabled) {
client->sendServerMessage({"=== Advert ===\n[" + sender_area + "] needs " + sender_message+ "."});
}
}
}
void AOClient::cmdSwitch(int argc, QStringList argv)
@ -285,3 +289,10 @@ void AOClient::cmdMutePM(int argc, QStringList argv)
QString str_en = pm_mute ? "muted" : "unmuted";
sendServerMessage("PM's are now " + str_en);
}
void AOClient::cmdToggleAdverts(int argc, QStringList argv)
{
advert_enabled = !advert_enabled;
QString str_en = advert_enabled ? "on" : "off";
sendServerMessage("Advertisements turned " + str_en);
}