From ded43087337ac6d10932e99a0b3d5b98ed94cb34 Mon Sep 17 00:00:00 2001 From: zaCade Date: Thu, 14 Jun 2018 16:21:36 +0200 Subject: [PATCH] ChatColors: Add a message forward. Allows to block message per client. --- .../scripting/custom-chatcolors.sp | 24 +++++++++++++++---- custom-chatcolors/scripting/include/ccc.inc | 6 ++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/custom-chatcolors/scripting/custom-chatcolors.sp b/custom-chatcolors/scripting/custom-chatcolors.sp index 363e9eaa..cf5283fd 100644 --- a/custom-chatcolors/scripting/custom-chatcolors.sp +++ b/custom-chatcolors/scripting/custom-chatcolors.sp @@ -24,7 +24,7 @@ public Plugin myinfo = //Handle nameForward; //Handle tagForward; //Handle applicationForward; -//Handle messageForward; +Handle messageForward; Handle preLoadedForward; Handle loadedForward; Handle configReloadedForward; @@ -145,7 +145,7 @@ public void OnPluginStart() //nameForward = CreateGlobalForward("CCC_OnNameColor", ET_Event, Param_Cell); //tagForward = CreateGlobalForward("CCC_OnTagApplied", ET_Event, Param_Cell); //applicationForward = CreateGlobalForward("CCC_OnColor", ET_Event, Param_Cell, Param_String, Param_Cell); - //messageForward = CreateGlobalForward("CCC_OnChatMessage", ET_Ignore, Param_Cell, Param_String, Param_Cell); + messageForward = CreateGlobalForward("CCC_OnChatMessage", ET_Ignore, Param_Cell, Param_Cell, Param_String); preLoadedForward = CreateGlobalForward("CCC_OnUserConfigPreLoaded", ET_Event, Param_Cell); loadedForward = CreateGlobalForward("CCC_OnUserConfigLoaded", ET_Ignore, Param_Cell); configReloadedForward = CreateGlobalForward("CCC_OnConfigReloaded", ET_Ignore); @@ -2707,7 +2707,7 @@ public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcas { if (IsClientInGame(client) && GetClientTeam(client) == team) { - if(!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor]) + if(!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor] || MessageForward(client, g_msgAuthor, g_msgText)) players[playersNum++] = client; } } @@ -2718,7 +2718,7 @@ public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcas { if (IsClientInGame(client)) { - if(!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor]) + if(!g_Ignored[client * (MAXPLAYERS + 1) + g_msgAuthor] || MessageForward(client, g_msgAuthor, g_msgText)) players[playersNum++] = client; } } @@ -2839,6 +2839,22 @@ stock bool ConfigForward(int client) return true; } +stock bool MessageForward(int client, int author, char[] message) +{ + Action result = Plugin_Continue; + + Call_StartForward(messageForward); + Call_PushCell(client); + Call_PushCell(author); + Call_PushString(message); + Call_Finish(result); + + if (result >= Plugin_Handled) + return false; + + return true; +} + public int Native_GetColor(Handle plugin, int numParams) { int client = GetNativeCell(1); diff --git a/custom-chatcolors/scripting/include/ccc.inc b/custom-chatcolors/scripting/include/ccc.inc index 780ccd66..e59c6533 100644 --- a/custom-chatcolors/scripting/include/ccc.inc +++ b/custom-chatcolors/scripting/include/ccc.inc @@ -134,12 +134,12 @@ native int CCC_ResetTag(int client); /** * Called when a message has been fully colored and will be sent, unless further plugins modify it through Simple Chat Processor * + * @param client Recieving client index * @param author Author client index * @param message Message - * @param maxlen Maximum length of message buffer - * @noreturn + * @return Plugin_Handled to block message, Plugin_Continue to allow message */ -//forward CCC_OnChatMessage(author, String:message[], maxlen); +forward Action CCC_OnChatMessage(int client, int author, const char[] message); /** * Called when a client's colors and tag are about to be loaded from the config file