Added global pre and post forwards for client chat (bug 5394, r=psychonic).

This commit is contained in:
Kyle Sanderson
2013-08-05 11:46:29 -04:00
parent 37316fed84
commit 5d76ffef88
5 changed files with 144 additions and 55 deletions
+2 -5
View File
@@ -81,9 +81,6 @@ public OnPluginStart()
g_Cvar_Deadtalk = CreateConVar("sm_deadtalk", "0", "Controls how dead communicate. 0 - Off. 1 - Dead players ignore teams. 2 - Dead players talk to living teammates.", 0, true, 0.0, true, 2.0);
g_Cvar_Alltalk = FindConVar("sv_alltalk");
AddCommandListener(Command_Say, "say");
AddCommandListener(Command_Say, "say_team");
RegAdminCmd("sm_mute", Command_Mute, ADMFLAG_CHAT, "sm_mute <player> - Removes a player's ability to use voice.");
RegAdminCmd("sm_gag", Command_Gag, ADMFLAG_CHAT, "sm_gag <player> - Removes a player's ability to use chat.");
RegAdminCmd("sm_silence", Command_Silence, ADMFLAG_CHAT, "sm_silence <player> - Removes a player's ability to use voice or chat.");
@@ -154,13 +151,13 @@ public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
return true;
}
public Action:Command_Say(client, const String:command[], args)
public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[])
{
if (client)
{
if (g_Gagged[client])
{
return Plugin_Handled;
return Plugin_Stop;
}
}
+6 -12
View File
@@ -75,10 +75,6 @@ public OnPluginStart()
g_Cvar_TimeleftInterval = CreateConVar("sm_timeleft_interval", "0.0", "Display timeleft every x seconds. Default 0.", 0, true, 0.0, true, 1800.0);
g_Cvar_FriendlyFire = FindConVar("mp_friendlyfire");
AddCommandListener(Command_Say, "say");
AddCommandListener(Command_Say, "say2");
AddCommandListener(Command_Say, "say_team");
RegConsoleCmd("timeleft", Command_Timeleft);
RegConsoleCmd("nextmap", Command_Nextmap);
RegConsoleCmd("motd", Command_Motd);
@@ -236,22 +232,22 @@ public Action:Command_Motd(client, args)
return Plugin_Handled;
}
public Action:Command_Say(client, const String:command[], argc)
public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[])
{
decl String:text[192];
new startidx = 0;
if (GetCmdArgString(text, sizeof(text)) < 1)
if (strcopy(text, sizeof(text), sArgs) < 1)
{
return Plugin_Continue;
return;
}
if (text[strlen(text)-1] == '"')
if (text[0] == '"')
{
text[strlen(text)-1] = '\0';
startidx = 1;
}
if (strcmp(command, "say2", false) == 0)
if ((strcmp(command, "say2", false) == 0) && strlen(sArgs) >= 4)
startidx += 4;
if (strcmp(text[startidx], "timeleft", false) == 0)
@@ -342,8 +338,6 @@ public Action:Command_Say(client, const String:command[], argc)
{
ShowMOTDPanel(client, "Message Of The Day", "motd", MOTDPANEL_TYPE_INDEX);
}
return Plugin_Continue;
}
ShowTimeLeft(client, who)
+21
View File
@@ -938,3 +938,24 @@ native bool:AddCommandListener(CommandListener:callback, const String:command[]=
*/
native RemoveCommandListener(CommandListener:callback, const String:command[]="");
/**
* Global listener for the chat commands.
*
* @param client Client index.
* @param command Command name.
* @param sArgs Chat argument string.
*
* @return An Action value. Returning Plugin_Handled bypasses the game function call.
Returning Plugin_Stop bypasses the post hook as well as the game function.
*/
forward Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]);
/**
* Global post listener for the chat commands.
*
* @param client Client index.
* @param command Command name.
* @param sArgs Chat argument string.
*
*/
forward OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]);