summaryrefslogtreecommitdiff
path: root/npc/commands/mute.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/commands/mute.txt')
-rwxr-xr-xnpc/commands/mute.txt92
1 files changed, 92 insertions, 0 deletions
diff --git a/npc/commands/mute.txt b/npc/commands/mute.txt
new file mode 100755
index 00000000..555fa724
--- /dev/null
+++ b/npc/commands/mute.txt
@@ -0,0 +1,92 @@
+- script @mute NPC32767,{
+ callfunc "argv_splitter";
+ if (GM < CMD_MUTE && GM < G_SYSOP) goto L_GM;
+ if (@argv$[1] == "") goto L_Failed;
+
+ .@target_id = getcharid(3, @argv$[1]);
+ if (.@target_id < 1 || !(isloggedin(.@target_id))) goto L_Failed;
+
+ if (@argv[0] > 120)
+ set @argv[0], 120; // max 2 hours
+
+ gmlog "@mute " + @args$;
+ if (@argv[0] == 0) goto L_UnMute;
+
+ message strcharinfo(0, .@target_id), "Server : ##BYou have been muted by a GM for "+@argv[0]+" minutes.";
+ MUTE_GLOBAL = 1, .@target_id;
+ #MUTE_UNTIL = (gettimetick(2) + (@argv[0] * 60)), .@target_id;
+ addtimer (@argv[0] * 60000) + 100, strnpcinfo(0) + "::OnCheckMute", .@target_id;
+ message strcharinfo(0), "mute : Player `"+strcharinfo(0, .@target_id)+"` has been muted for "+@argv[0]+" minutes.";
+ end;
+
+OnSTFU:
+ if (GM < CMD_MUTE && GM < G_SYSOP) goto L_GM;
+ callfunc "argv_splitter";
+ if (@argv[0] < 1) set @argv[0], 1;
+ if (@argv[0] > 10) set @argv[0], 10;
+ gmlog "@stfu " + @argv[0];
+ @stfu_nr = 0;
+ foreach 0, getmapname(), (POS_X - .range), (POS_Y - .range), (POS_X + .range), (POS_Y + .range), strnpcinfo(0)+"::OnSTFUPC";
+ message strcharinfo(0), "mute : Every player within "+.range+" tiles have been muted for "+@argv[0]+" minutes. ["+@stfu_nr+"]";
+ @stfu_nr = 0;
+ end;
+
+OnSTFUPC:
+ if (@target_id == BL_ID) end;
+ .@future = (gettimetick(2) + (@argv[0] * 60));
+ if (get(#MUTE_UNTIL, @target_id) > .@future) end; // if player already has a mute, don't reduce it
+ MUTE_GLOBAL = 1, @target_id;
+ #MUTE_UNTIL = .@future, @target_id;
+ addtimer (@argv[0] * 60000) + 100, strnpcinfo(0) + "::OnCheckMute", @target_id;
+ @stfu_nr = @stfu_nr + 1;
+ end;
+
+OnPCLoginEvent:
+ if (#MUTE_UNTIL < 1) end;
+ .@s = (#MUTE_UNTIL - gettimetick(2));
+ if (.@s < 5) goto L_ClearMute;
+ .@m = .@s / 60;
+ message strcharinfo(0), "Server : ##BYou have been muted for "+ max(1, .@m) +" minutes.";
+ MUTE_GLOBAL = 1;
+ addtimer (.@s * 1000) + 100, strnpcinfo(0) + "::OnCheckMute";
+ end;
+
+L_ClearMute:
+ message strcharinfo(0), "Server : ##BYour mute has expired while you were away. You have been automatically unmuted.";
+ if ((#MUTE_UNTIL - gettimetick(2)) >= (0 - 900))
+ wgm "=> Player `"+ strcharinfo(0) +"` has been automatically unmuted."; // only send if unmuted 15 minutes ago or less
+ #MUTE_UNTIL = 0;
+ end;
+
+OnCheckMute:
+ if (#MUTE_UNTIL < 1) end;
+ if (gettimetick(2) - #MUTE_UNTIL < 0) end;
+ message strcharinfo(0), "Server : ##BYou have been automatically unmuted.";
+ wgm "=> Player `"+ strcharinfo(0) +"` has been automatically unmuted.";
+ MUTE_GLOBAL = 0;
+ #MUTE_UNTIL = 0;
+ end;
+
+L_UnMute:
+ if (get(MUTE_GLOBAL, .@target_id))
+ message strcharinfo(0, .@target_id), "Server : ##BYou have been unmuted by a GM.";
+ MUTE_GLOBAL = 0, .@target_id;
+ #MUTE_UNTIL = 0, .@target_id;
+ message strcharinfo(0), "mute : Player `"+strcharinfo(0, .@target_id)+"` has been unmuted.";
+ end;
+
+L_Failed:
+ message strcharinfo(0), "mute : Impossible to attach to the target player. Did you try putting the name in \"quotation marks\"?";
+ end;
+
+L_GM:
+ message strcharinfo(0), "mute : GM command is level "+ CMD_MUTE +", but you are level " + GM;
+ end;
+
+OnInit:
+ set .range, 14; // FIXME: this should be a const
+ registercmd chr(ATCMD_SYMBOL) + "mute", strnpcinfo(0);
+ registercmd chr(ATCMD_SYMBOL) + "stfu", strnpcinfo(0) + "::OnSTFU";
+ registercmd chr(ATCMD_SYMBOL) + "areamute", strnpcinfo(0) + "::OnSTFU"; // alias of STFU
+ end;
+}