Permalink
Browse files

Make it possible to disable automated announcements

Fixes #389. Through `/settings infomsg [on/off]`
  • Loading branch information...
RussellLVP committed Jan 8, 2017
1 parent bcaeb63 commit b2d54abd4e21155fbb9230a8b89b76dba45cedd4
@@ -1132,9 +1132,19 @@ lvp_show(playerId, params[]) {
}
if (showInfo == true) {
- SendClientMessageToAllEx(Color::Red, "-------------------");
- SendClientMessageToAllEx(Color::Warning, g_message);
- SendClientMessageToAllEx(Color::Red, "-------------------");
+ new const bool: automated = !!IsPlayerNPC(playerId);
+
+ for (new receiverId = 0; receiverId <= PlayerManager->highestPlayerId(); ++receiverId) {
+ if (Player(receiverId)->isConnected() == false || IsPlayerInMinigame(receiverId))
+ continue;
+
+ if (automated && PlayerSettings(receiverId)->areAutomatedAnnouncementsDisabled())
+ continue;
+
+ SendClientMessage(receiverId, Color::Red, "-------------------");
+ SendClientMessage(receiverId, Color::Warning, g_message);
+ SendClientMessage(receiverId, Color::Red, "-------------------");
+ }
format(g_message, sizeof(g_message), "%s (Id:%d) has done /show %s.",
Player(playerId)->nicknameString(), playerId, showParameter);
@@ -148,7 +148,7 @@ lvp_settings(playerId, params[])
// Do we have any parameters passed on?
if (!strlen(paramOption)) {
- SendClientMessage(playerId, Color::Information, "Usage: /settings [newsmsg/showmsg] [on/off]");
+ SendClientMessage(playerId, Color::Information, "Usage: /settings [infomsg/newsmsg/showmsg] [on/off]");
return 1;
}
@@ -188,5 +188,34 @@ lvp_settings(playerId, params[])
return 1;
}
+ // For automated announcements (i.e. those by Gunther)
+ if (!strcmp(paramOption, "infomsg", true, 7)) {
+ param_shift(optionToggle);
+
+ new message[128];
+
+ if (Command->parameterCount(optionToggle) == 0) {
+ format(message, sizeof(message), "Showing info announcements to you currently is %s{FFFFFF}.",
+ (PlayerSettings(playerId)->areAutomatedAnnouncementsDisabled() ?
+ "{DC143C}disabled" :
+ "{33AA33}enabled"));
+
+ SendClientMessage(playerId, Color::Information, message);
+ SendClientMessage(playerId, Color::Information, "Usage: /settings infomsg [on/off]" );
+ return 1;
+ }
+
+ new const bool: enabled = Command->booleanParameter(optionToggle, 0);
+ PlayerSettings(playerId)->setAutomatedAnnouncementsDisabled(!enabled);
+
+ format(message, sizeof(message), "Showing info announcements to you is now %s{33AA33}.",
+ (PlayerSettings(playerId)->areAutomatedAnnouncementsDisabled() ?
+ "{DC143C}disabled" :
+ "{33AA33}enabled"));
+
+ SendClientMessage(playerId, Color::Success, message);
+ return 1;
+ }
+
return 1;
}
@@ -16,7 +16,8 @@ enum _: PlayerSettingKey {
EarningsToBankAccountDisabledSettingKey = 3,
AllVirtualWorldChatEnabledSettingKey = 5,
PlayerInfoEnabledSettingKey = 6,
- PlayerHitSoundEnabledSettingKey = 7
+ PlayerHitSoundEnabledSettingKey = 7,
+ PlayerDisableAutomatedAnnouncementsKey = 8,
};
// Assert that we don't put more than 32 items in the PlayerSettingKey enum.
@@ -203,5 +204,13 @@ class PlayerSettings <playerId (MAX_PLAYERS)> {
this->toggleSetting(PlayerHitSoundEnabledSettingKey, !!enabled);
}
+ public bool: areAutomatedAnnouncementsDisabled() {
+ return this->hasSetting(PlayerDisableAutomatedAnnouncementsKey);
+ }
+
+ public setAutomatedAnnouncementsDisabled(bool: disabled) {
+ this->toggleSetting(PlayerDisableAutomatedAnnouncementsKey, !!disabled);
+ }
+
// TODO: Implement other settings.
};

0 comments on commit b2d54ab

Please sign in to comment.