Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions addons/sourcemod/scripting/CustomChatColors.sp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ char g_msgText[MAX_CHAT_LENGTH];
char g_msgFinal[255];
bool g_msgIsTeammate;

bool g_Ignored[(MAXPLAYERS + 1) * (MAXPLAYERS + 1)] = {false, ...};
bool g_Ignored[MAXPLAYERS + 1][MAXPLAYERS + 1];

int g_bSQLSelectReplaceRetry = 0;
int g_bSQLInsertReplaceRetry[MAXPLAYERS + 1] = { 0, ... };
Expand Down Expand Up @@ -164,7 +164,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("CCC_ResetColor", Native_ResetColor);
CreateNative("CCC_ResetTag", Native_ResetTag);

CreateNative("CCC_UpdateIgnoredArray", Native_UpdateIgnoredArray);
CreateNative("CCC_SetIgnored", Native_SetIgnored);
CreateNative("CCC_IsClientEnabled", Native_IsClientEnabled);

RegPluginLibrary("ccc");
Expand Down Expand Up @@ -4299,7 +4299,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][g_msgAuthor])
players[playersNum++] = client;
}
}
Expand All @@ -4310,7 +4310,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][g_msgAuthor])
players[playersNum++] = client;
}
}
Expand Down Expand Up @@ -4751,10 +4751,26 @@ public int Native_ResetTag(Handle plugin, int numParams)
return 1;
}

public int Native_UpdateIgnoredArray(Handle plugin, int numParams)
public int Native_SetIgnored(Handle plugin, int numParams)
{
GetNativeArray(1, g_Ignored, sizeof(g_Ignored));

int client = GetNativeCell(1);

if (!client || client > MaxClients)
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation logic !client will reject client index 0, but in SourceMod, client index 0 typically represents the server console which might be a valid use case for ignore functionality. Consider using client < 1 instead of !client if console should be excluded, or client < 0 if console should be allowed.

Copilot uses AI. Check for mistakes.

{
ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game");
return 0;
}
Comment on lines +4758 to +4762
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message mentions 'client is not in game' but the validation only checks if the client index is valid, not if the client is actually in game. Consider using IsClientInGame(client) for the validation or update the error message to 'Invalid client index'.

Copilot uses AI. Check for mistakes.


int target = GetNativeCell(2);

if (!target || target > MaxClients)
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation logic !client will reject client index 0, but in SourceMod, client index 0 typically represents the server console which might be a valid use case for ignore functionality. Consider using client < 1 instead of !client if console should be excluded, or client < 0 if console should be allowed.

Suggested change
if (!target || target > MaxClients)
if (target < 0 || target > MaxClients)

Copilot uses AI. Check for mistakes.

{
ThrowNativeError(SP_ERROR_PARAM, "Invalid target or target is not in game");
return 0;
}
Comment on lines +4766 to +4770
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message mentions 'target is not in game' but the validation only checks if the target index is valid, not if the target is actually in game. Consider using IsClientInGame(target) for the validation or update the error message to 'Invalid target index'.

Copilot uses AI. Check for mistakes.


bool value = view_as<bool>(GetNativeCell(3));
g_Ignored[client][target] = value;
return 1;
}

Expand Down
18 changes: 14 additions & 4 deletions addons/sourcemod/scripting/include/ccc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#define CCC_V_MAJOR "7"
#define CCC_V_MINOR "4"
#define CCC_V_PATCH "21"
#define CCC_V_PATCH "22"

#define CCC_VERSION CCC_V_MAJOR..."."...CCC_V_MINOR..."."...CCC_V_PATCH

Expand Down Expand Up @@ -223,7 +223,17 @@ forward void CCC_OnUserConfigLoaded(int client);
*/
forward void CCC_OnConfigReloaded();

native int CCC_UpdateIgnoredArray(bool IgnoredArray[(MAXPLAYERS + 1) * (MAXPLAYERS + 1)]);
/**
* Sets Ignored value of a specific client to a specific target, this will ignore chat messages.
*
* @param client The client index
* @param target The target index
* @param ignored The ignorance value, true/false
* @noreturn
*
* On error/errors: Client or target is invalid
*/
native void CCC_SetIgnored(int client, int target, bool ignored);

public SharedPlugin __pl_ccc =
{
Expand All @@ -246,7 +256,7 @@ public __pl_ccc_SetNTVOptional() {
MarkNativeAsOptional("CCC_ResetTag");
MarkNativeAsOptional("CCC_ResetColor");
MarkNativeAsOptional("CCC_ResetTag");
MarkNativeAsOptional("CCC_UpdateIgnoredArray");
MarkNativeAsOptional("CCC_SetIgnored");
MarkNativeAsOptional("CCC_IsClientEnabled");
}
#endif
#endif