Add /mute chat command
This commit is contained in:
1 parent
0df5ef996c
commit
ca34b0c8d6
3 files changed
+40
-1
No files matched your search
@@ -90,9 +90,12 @@ char motd[254], server_context[8]; // Message of the Day, Unique Context (even w
|
||||
plrinfo playerinfo[MAXPLAYERS];
|
||||
SINT8 joinnode = 0; // used for CL_VIEWSERVER
|
||||
|
||||
boolean player_muted[MAXPLAYERS] = {0};
|
||||
|
||||
// Server specific vars
|
||||
UINT8 playernode[MAXPLAYERS];
|
||||
|
||||
|
||||
// Minimum timeout for sending the savegame
|
||||
// The actual timeout will be longer depending on the savegame length
|
||||
tic_t jointimeout = (3*TICRATE);
|
||||
@@ -3488,6 +3491,8 @@ void CL_Reset(void)
|
||||
#endif
|
||||
G_ResetAllDeviceRumbles();
|
||||
|
||||
memset(player_muted, 0, sizeof(player_muted));
|
||||
|
||||
// D_StartTitle should get done now, but the calling function will handle it
|
||||
}
|
||||
|
||||
|
||||
@@ -671,6 +671,8 @@ SINT8 nametonum(const char *name);
|
||||
extern char motd[254], server_context[8];
|
||||
extern UINT8 playernode[MAXPLAYERS];
|
||||
|
||||
extern boolean player_muted[MAXPLAYERS];
|
||||
|
||||
INT32 D_NumPlayers(void);
|
||||
|
||||
void D_ResetTiccmds(void);
|
||||
|
||||
+33
-1
@@ -949,6 +949,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||
else
|
||||
stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you?
|
||||
|
||||
if (player_muted[playernum])
|
||||
spam_eatmsg = 1; // Let lua know we're skipping this message
|
||||
|
||||
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
|
||||
|
||||
if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
|
||||
@@ -1179,6 +1182,23 @@ static boolean HU_clearChatSpaces(void)
|
||||
return nothingbutspaces;
|
||||
}
|
||||
|
||||
static void DoMute(const char *name)
|
||||
{
|
||||
INT32 pnum = D_LookupPlayer(name);
|
||||
|
||||
if (pnum < 0)
|
||||
{
|
||||
HU_AddChatText("\x85""ERROR: \x80Player not found.", false);
|
||||
return;
|
||||
}
|
||||
|
||||
player_muted[pnum] = !player_muted[pnum];
|
||||
|
||||
HU_AddChatText(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false);
|
||||
if (player_muted[pnum])
|
||||
HU_AddChatText("Use same command to unmute them.", false);
|
||||
}
|
||||
|
||||
static void HU_SendChatMessage(void)
|
||||
{
|
||||
char buf[2 + HU_MAXMSGLEN + 1];
|
||||
@@ -1205,7 +1225,19 @@ static void HU_SendChatMessage(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
||||
size_t len = strlen(msg);
|
||||
|
||||
if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute
|
||||
{
|
||||
if (len > 6)
|
||||
DoMute(msg+6);
|
||||
else
|
||||
HU_AddChatText("\x82NOTICE: \x80Usage: /mute <name|node>", false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
||||
{
|
||||
INT32 spc = 1; // used if nodenum[1] is a space.
|
||||
char *nodenum = (char*) malloc(3);
|
||||
|
||||
Reference in new issue
Block a user