Permalink
Browse files

Implement a /showreport command

Basically "/show report" with an automated two-minute mute.
  • Loading branch information...
RussellLVP committed Oct 24, 2016
1 parent 068db32 commit d7b35b5dd90644988618b5538fbafe50020097d3
@@ -1088,6 +1088,9 @@ lvp_p(playerId, params[]) {
return 1;
}
#define REPORT_MESSAGE "Report cheaters using /report [suspected id/name] [cheat/reason]"
lvp_show(playerId, params[]) {
if (Command->parameterCount(params) != 1)
goto ShowHelp;
@@ -1112,7 +1115,7 @@ lvp_show(playerId, params[]) {
else if (!strcmp(showParameter, "report", true, 6)) {
showInfo = true;
format(g_message, sizeof(g_message), "Report cheaters using /report [suspected id/name] [cheat/reason]");
format(g_message, sizeof(g_message), REPORT_MESSAGE);
}
else if (!strcmp(showParameter, "caps", true, 4)) {
@@ -1183,6 +1186,42 @@ ShowHelp:
return 1;
}
lvp_showreport(playerId, params[]) {
if (Command->parameterCount(params) == 0) {
SendClientMessage(playerId, Color::Information, "Usage: /showreport [player]");
return 1;
}
new subjectId = Command->playerParameter(params, 0, playerId);
if (subjectId == Player::InvalidId)
return 1;
SendClientMessage(subjectId, Color::Red, "-------------------");
SendClientMessage(subjectId, Color::Warning, REPORT_MESSAGE);
// Inform the mutee.
format(g_message, sizeof(g_message), "You have been muted for two minutes by %s (Id: %d).",
Player(playerId)->nicknameString(), playerId);
SendClientMessage(subjectId, Color::Error, g_message);
SendClientMessage(subjectId, Color::Red, "-------------------");
// Apply the mute. Make it silent.
MuteManager->mutePlayer(subjectId, 2, true /* silent */);
// Inform other administrators.
format(g_message, sizeof(g_message), "%s (Id:%d) muted %s (Id:%d) for two minutes.",
Player(playerId)->nicknameString(), playerId, Player(subjectId)->nicknameString(), subjectId);
Admin(playerId, g_message);
// Inform the muter.
format(g_message, sizeof(g_message), "%s (Id: %d) has been warned and muted for two minutes.",
Player(subjectId)->nicknameString(), subjectId);
SendClientMessage(playerId, Color::Success, g_message);
return 1;
}
lvp_hs(playerId, params[]) {
if (PlayerSettings(playerId)->isPlayerHitSoundEnabled()) {
SendClientMessage(playerId, Color::Success, "You have disabled your hit sound.");
@@ -23,12 +23,16 @@ class MuteManager {
*
* @param playerId Id of the player who needs to get muted.
* @param duration Amount of minutes to mute the player, where 0 means permanently.
* @param silent Whether the |playerId| should NOT be informed of the mute.
*/
public mutePlayer(playerId, duration) {
public mutePlayer(playerId, duration, bool: silent = false) {
m_isMuted[playerId] = true;
m_muteDuration[playerId] = duration;
m_holdMuteTimestamp[playerId] = Time->currentTime();
if (silent)
return;
new message[128];
if (duration == -1) {
SendClientMessage(playerId, Color::Error, "An administrator has muted you permanently.");
@@ -551,6 +551,7 @@ public OnPlayerCommandText(playerid, cmdtext[]) {
// Commands for administrators:
lvp_command(clear, 5, AdministratorLevel);
lvp_command(show, 4, AdministratorLevel);
lvp_command(showreport, 10, AdministratorLevel);
lvp_command(p, 1, AdministratorLevel);
lvp_command(t, 1, AdministratorLevel);
lvp_command(announce, 8, AdministratorLevel);

0 comments on commit d7b35b5

Please sign in to comment.