batch remove trailing spaces and convert windows \r\n line endings to linux \n

i don't want to have to do this again, fix your shitty code editors @commiters !!!
This commit is contained in:
BotoX
2018-08-09 19:35:44 +02:00
parent ff970b8d5f
commit eefb23882b
30 changed files with 1992 additions and 1992 deletions
+104 -104
View File
@@ -5,13 +5,13 @@
* Version: 2.0.0-MC *
* *
**************************************************************************/
#if defined _colors_included
#endinput
#endif
#define _colors_included
#define MAX_MESSAGE_LENGTH 250
#define MAX_COLORS 18
@@ -62,27 +62,27 @@ static Handle sm_show_activity = null;
* @param client Client index.
* @param szMessage Message (formatting rules).
* @return No return
*
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock void C_PrintToChat(int client, const char[] szMessage, any ...)
{
if (client <= 0 || client > MaxClients)
ThrowError("Invalid client index %d", client);
if (!IsClientInGame(client))
ThrowError("Client %d is not in game", client);
char szBuffer[MAX_MESSAGE_LENGTH];
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
VFormat(szCMessage, sizeof(szCMessage), szBuffer, 3);
int index = C_Format(szCMessage, sizeof(szCMessage));
if (index == NO_INDEX)
PrintToChat(client, "%s", szCMessage);
else
@@ -98,7 +98,7 @@ stock void C_PrintToChat(int client, const char[] szMessage, any ...)
* @param szMessage Formatting rules.
* @param ... Variable number of format parameters.
* @return No return
*
*
* On error/Errors: If the client is not connected or invalid.
*/
stock void C_ReplyToCommand(int client, const char[] szMessage, any ...)
@@ -106,7 +106,7 @@ stock void C_ReplyToCommand(int client, const char[] szMessage, any ...)
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(szCMessage, sizeof(szCMessage), szMessage, 3);
if (client == 0)
{
C_RemoveTags(szCMessage, sizeof(szCMessage));
@@ -133,7 +133,7 @@ stock void C_ReplyToCommand(int client, const char[] szMessage, any ...)
* @param szMessage Formatting rules.
* @param ... Variable number of format parameters.
* @return No return
*
*
* On error/Errors: If the client is not connected or invalid.
*/
stock void C_ReplyToCommandEx(int client, int author, const char[] szMessage, any ...)
@@ -141,7 +141,7 @@ stock void C_ReplyToCommandEx(int client, int author, const char[] szMessage, an
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(szCMessage, sizeof(szCMessage), szMessage, 4);
if (client == 0)
{
C_RemoveTags(szCMessage, sizeof(szCMessage));
@@ -169,17 +169,17 @@ stock void C_ReplyToCommandEx(int client, int author, const char[] szMessage, an
stock void C_PrintToChatAll(const char[] szMessage, any ...)
{
char szBuffer[MAX_MESSAGE_LENGTH];
MuCo_LoopClients(i)
{
if (i > 0 && IsClientInGame(i) && !IsFakeClient(i) && !C_SkipList[i])
{
SetGlobalTransTarget(i);
VFormat(szBuffer, sizeof(szBuffer), szMessage, 2);
C_PrintToChat(i, "%s", szBuffer);
}
C_SkipList[i] = false;
}
}
@@ -192,30 +192,30 @@ stock void C_PrintToChatAll(const char[] szMessage, any ...)
* @param author Author index whose color will be used for teamcolor tag.
* @param szMessage Message (formatting rules).
* @return No return
*
*
* On error/Errors: If the client or author are not connected an error will be thrown.
*/
stock void C_PrintToChatEx(int client, int author, const char[] szMessage, any ...)
{
if (client <= 0 || client > MaxClients)
ThrowError("Invalid client index %d", client);
if (!IsClientInGame(client))
ThrowError("Client %d is not in game", client);
if (author < 0 || author > MaxClients)
ThrowError("Invalid client index %d", author);
char szBuffer[MAX_MESSAGE_LENGTH];
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
VFormat(szCMessage, sizeof(szCMessage), szBuffer, 4);
int index = C_Format(szCMessage, sizeof(szCMessage), author);
if (index == NO_INDEX)
PrintToChat(client, "%s", szCMessage);
else
@@ -229,29 +229,29 @@ stock void C_PrintToChatEx(int client, int author, const char[] szMessage, any .
* @param author Author index whos color will be used for teamcolor tag.
* @param szMessage Message (formatting rules).
* @return No return
*
*
* On error/Errors: If the author is not connected an error will be thrown.
*/
stock void C_PrintToChatAllEx(int author, const char[] szMessage, any ...)
{
if (author < 0 || author > MaxClients)
ThrowError("Invalid client index %d", author);
if (!IsClientInGame(author))
ThrowError("Client %d is not in game", author);
char szBuffer[MAX_MESSAGE_LENGTH];
MuCo_LoopClients(i)
{
if (i > 0 && IsClientInGame(i) && !IsFakeClient(i) && !C_SkipList[i])
{
SetGlobalTransTarget(i);
VFormat(szBuffer, sizeof(szBuffer), szMessage, 3);
C_PrintToChatEx(i, author, "%s", szBuffer);
}
C_SkipList[i] = false;
}
}
@@ -266,7 +266,7 @@ stock void C_RemoveTags(char[] szMessage, int maxlength)
{
for (int i = 0; i < MAX_COLORS; i++)
ReplaceString(szMessage, maxlength, C_Tag[i], "", false);
ReplaceString(szMessage, maxlength, "{teamcolor}", "", false);
}
@@ -281,10 +281,10 @@ stock bool C_ColorAllowed(C_Colors color)
if (!C_EventIsHooked)
{
C_SetupProfile();
C_EventIsHooked = true;
}
return C_Profile_Colors[color];
}
@@ -301,13 +301,13 @@ stock void C_ReplaceColor(C_Colors color, C_Colors newColor)
if (!C_EventIsHooked)
{
C_SetupProfile();
C_EventIsHooked = true;
}
C_Profile_Colors[color] = C_Profile_Colors[newColor];
C_Profile_TeamIndex[color] = C_Profile_TeamIndex[newColor];
C_TagReqSayText2[color] = C_TagReqSayText2[newColor];
Format(C_TagCode[color], sizeof(C_TagCode[]), C_TagCode[newColor]);
}
@@ -318,7 +318,7 @@ stock void C_ReplaceColor(C_Colors color, C_Colors newColor)
* to those funcions to skip specified client when printing
* message to all clients. After message is printed client will
* no more be skipped.
*
*
* @param client Client index
* @return No return
*/
@@ -326,7 +326,7 @@ stock void C_SkipNextClient(int client)
{
if (client <= 0 || client > MaxClients)
ThrowError("Invalid client index %d", client);
C_SkipList[client] = true;
}
@@ -336,7 +336,7 @@ stock void C_SkipNextClient(int client)
* @param szMessage String.
* @param maxlength Maximum length of the string buffer.
* @return Client index that can be used for SayText2 author index
*
*
* On error/Errors: If there is more then one team color is used an error will be thrown.
*/
stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX)
@@ -346,25 +346,25 @@ stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX)
{
C_SetupProfile();
HookEvent("server_spawn", C_Event_MapStart, EventHookMode_PostNoCopy);
C_EventIsHooked = true;
}
int iRandomPlayer = NO_INDEX;
// On CS:GO set invisible precolor
if (GetEngineVersion() == Engine_CSGO)
if (GetEngineVersion() == Engine_CSGO)
{
Format(szMessage, maxlength, " %s", szMessage);
}
/* If author was specified replace {teamcolor} tag */
if (author != NO_INDEX)
{
if (C_Profile_SayText2)
{
ReplaceString(szMessage, maxlength, "{teamcolor}", "\x03", false);
iRandomPlayer = author;
}
/* If saytext2 is not supported by game replace {teamcolor} with green tag */
@@ -373,18 +373,18 @@ stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX)
}
else
ReplaceString(szMessage, maxlength, "{teamcolor}", "", false);
/* For other color tags we need a loop */
for (int i = 0; i < MAX_COLORS; i++)
{
/* If tag not found - skip */
if (StrContains(szMessage, C_Tag[i], false) == -1)
continue;
/* If tag is not supported by game replace it with green tag */
else if (!C_Profile_Colors[i])
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[Color_Green], false);
/* If tag doesn't need saytext2 simply replace */
else if (!C_TagReqSayText2[i])
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[i], false);
@@ -395,16 +395,16 @@ stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX)
/* If saytext2 is not supported by game replace tag with green tag */
if (!C_Profile_SayText2)
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[Color_Green], false);
/* Game supports saytext2 */
else
else
{
/* If random player for tag wasn't specified replace tag and find player */
if (iRandomPlayer == NO_INDEX)
{
/* Searching for valid client for tag */
iRandomPlayer = C_FindRandomPlayerByTeam(C_Profile_TeamIndex[i]);
/* If player not found replace tag with green color tag */
if (iRandomPlayer == NO_PLAYER)
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[Color_Green], false);
@@ -412,7 +412,7 @@ stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX)
/* If player was found simply replace */
else
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[i], false);
}
/* If found another team color tag throw error */
else
@@ -421,10 +421,10 @@ stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX)
ThrowError("Using two team colors in one message is not allowed");
}
}
}
}
return iRandomPlayer;
}
@@ -444,7 +444,7 @@ stock int C_FindRandomPlayerByTeam(int color_team)
{
if (i > 0 && IsClientInGame(i) && GetClientTeam(i) == color_team)
return i;
}
}
}
return NO_PLAYER;
@@ -461,8 +461,8 @@ stock int C_FindRandomPlayerByTeam(int color_team)
stock void C_SayText2(int client, int author, const char[] szMessage)
{
Handle hBuffer = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
PbSetInt(hBuffer, "ent_idx", author);
PbSetBool(hBuffer, "chat", true);
@@ -478,12 +478,12 @@ stock void C_SayText2(int client, int author, const char[] szMessage)
BfWriteByte(hBuffer, true);
BfWriteString(hBuffer, szMessage);
}
EndMessage();
}
/**
* Creates game color profile
* Creates game color profile
* This function must be edited if you want to add more games support
*
* @return No return.
@@ -491,7 +491,7 @@ stock void C_SayText2(int client, int author, const char[] szMessage)
stock void C_SetupProfile()
{
EngineVersion engine = GetEngineVersion();
if (engine == Engine_CSS)
{
C_Profile_Colors[Color_Lightgreen] = true;
@@ -540,7 +540,7 @@ stock void C_SetupProfile()
C_Profile_Colors[Color_Lightgreen] = true;
C_Profile_Colors[Color_Red] = true;
C_Profile_Colors[Color_Blue] = true;
C_Profile_Colors[Color_Olive] = true;
C_Profile_Colors[Color_Olive] = true;
C_Profile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
C_Profile_TeamIndex[Color_Red] = 3;
C_Profile_TeamIndex[Color_Blue] = 2;
@@ -590,18 +590,18 @@ stock void C_SetupProfile()
public Action C_Event_MapStart(Event event, const char[] name, bool dontBroadcast)
{
C_SetupProfile();
MuCo_LoopClients(i)
C_SkipList[i] = false;
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* C_ShowActivity2() is slightly more useful.
* Supports color tags.
*
@@ -615,14 +615,14 @@ stock int C_ShowActivity(int client, const char[] format, any ...)
{
if (sm_show_activity == null)
sm_show_activity = FindConVar("sm_show_activity");
char tag[] = "[SM] ";
char szBuffer[MAX_MESSAGE_LENGTH];
//char szCMessage[MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
@@ -630,7 +630,7 @@ stock int C_ShowActivity(int client, const char[] format, any ...)
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@@ -638,13 +638,13 @@ stock int C_ShowActivity(int client, const char[] format, any ...)
{
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE)
{
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
@@ -654,16 +654,16 @@ stock int C_ShowActivity(int client, const char[] format, any ...)
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@@ -688,7 +688,7 @@ stock int C_ShowActivity(int client, const char[] format, any ...)
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@@ -707,12 +707,12 @@ stock int C_ShowActivity(int client, const char[] format, any ...)
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
@@ -731,12 +731,12 @@ stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, an
{
if (sm_show_activity == null)
sm_show_activity = FindConVar("sm_show_activity");
char szBuffer[MAX_MESSAGE_LENGTH];
//char szCMessage[MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
@@ -744,7 +744,7 @@ stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, an
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@@ -752,13 +752,13 @@ stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, an
{
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE)
{
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
@@ -768,16 +768,16 @@ stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, an
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@@ -802,7 +802,7 @@ stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, an
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@@ -821,18 +821,18 @@ stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, an
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
@@ -847,19 +847,19 @@ stock int C_ShowActivity2(int client, const char[] tag, const char[] format, any
{
if (sm_show_activity == null)
sm_show_activity = FindConVar("sm_show_activity");
char szBuffer[MAX_MESSAGE_LENGTH];
//char szCMessage[MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
// ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
if (client != 0)
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@@ -867,30 +867,30 @@ stock int C_ShowActivity2(int client, const char[] tag, const char[] format, any
{
sign = "PLAYER";
}
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
* twice.
*/
*/
C_PrintToChatEx(client, client, "%s%s", tag, szBuffer);
}
else
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@@ -915,7 +915,7 @@ stock int C_ShowActivity2(int client, const char[] tag, const char[] format, any
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@@ -934,11 +934,11 @@ stock int C_ShowActivity2(int client, const char[] tag, const char[] format, any
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
return 1;
}
+64 -64
View File
@@ -29,11 +29,11 @@ static Handle sm_show_activity = INVALID_HANDLE;
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
*
* @param client Client index.
* @param message Message (formatting rules).
* @noreturn
*
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock void MC_PrintToChat(int client, const char[] message, any ...) {
@@ -55,7 +55,7 @@ stock void MC_PrintToChat(int client, const char[] message, any ...) {
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
*
* @param client Client index.
* @param message Message (formatting rules).
* @noreturn
@@ -79,12 +79,12 @@ stock void MC_PrintToChatAll(const char[] message, any ...) {
/**
* Prints a message to a specific client in the chat area.
* Supports color tags and teamcolor tag.
*
*
* @param client Client index.
* @param author Author index whose color will be used for teamcolor tag.
* @param message Message (formatting rules).
* @noreturn
*
*
* On error/Errors: If the client or author are not connected an error will be thrown
*/
stock void MC_PrintToChatEx(int client, int author, const char[] message, any ...) {
@@ -116,7 +116,7 @@ stock void MC_PrintToChatEx(int client, int author, const char[] message, any ..
* @param author Author index whose color will be used for teamcolor tag.
* @param message Message (formatting rules).
* @noreturn
*
*
* On error/Errors: If the author is not connected an error will be thrown.
*/
stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) {
@@ -143,7 +143,7 @@ stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) {
/**
* Sends a SayText2 usermessage
*
*
* @param client Client to send usermessage to
* @param message Message to send
* @noreturn
@@ -191,7 +191,7 @@ stock void MC_SendMessage(int client, const char[] message, int author = 0) {
* MC_PrintToChatAll or MC_PrintToChatAllEx. It causes those functions
* to skip the specified client when printing the message.
* After printing the message, the client will no longer be skipped.
*
*
* @param client Client index
* @noreturn
*/
@@ -204,7 +204,7 @@ stock void MC_SkipNextClient(int client) {
/**
* Checks if the colors trie is initialized and initializes it if it's not (used internally)
*
*
* @return No return
*/
stock void MC_CheckTrie() {
@@ -221,7 +221,7 @@ stock void MC_CheckTrie() {
* @param removeTags Optional boolean value to determine whether we're replacing tags with colors, or just removing tags, used by MC_RemoveTags
* @param maxlen Optional value for max buffer length, used by MC_RemoveTags
* @noreturn
*
*
* On error/Errors: If the client index passed for author is invalid or not in game.
*/
stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = false, int maxlen = MAX_BUFFER_LENGTH) {
@@ -243,12 +243,12 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
}
int cursor = 0;
int value;
char tag[32], buff[32];
char tag[32], buff[32];
char[] output = new char[maxlen];
strcopy(output, maxlen, buffer);
// Since the string's size is going to be changing, output will hold the replaced string and we'll search buffer
Handle regex = CompileRegex("{[a-zA-Z0-9]+}");
for(int i = 0; i < 1000; i++) { // The RegEx extension is quite flaky, so we have to loop here :/. This loop is supposed to be infinite and broken by return, but conditions have been added to be safe.
if(MatchRegex(regex, buffer[cursor]) < 1) {
@@ -262,11 +262,11 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
strcopy(buff, sizeof(buff), tag);
ReplaceString(buff, sizeof(buff), "{", "");
ReplaceString(buff, sizeof(buff), "}", "");
if(!GetTrieValue(MC_Trie, buff, value)) {
continue;
}
if(removeTags) {
ReplaceString(output, maxlen, tag, "", false);
} else {
@@ -279,7 +279,7 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
/**
* Gets a part of a string
*
*
* @param input String to get the part from
* @param output Buffer to write to
* @param maxlen Max length of output buffer
@@ -301,7 +301,7 @@ stock void CSubString(const char[] input, char[] output, int maxlen, int start,
/**
* Converts a string to lowercase
*
*
* @param buffer String to convert
* @noreturn
*/
@@ -334,7 +334,7 @@ stock bool MC_AddColor(const char[] name, int color) {
/**
* Removes color tags from a message
*
*
* @param message Message to remove tags from
* @param maxlen Maximum buffer length
* @noreturn
@@ -345,7 +345,7 @@ stock void MC_RemoveTags(char[] message, int maxlen) {
/**
* Replies to a command with colors
*
*
* @param client Client to reply to
* @param message Message (formatting rules)
* @noreturn
@@ -364,7 +364,7 @@ stock void MC_ReplyToCommand(int client, const char[] message, any ...) {
/**
* Replies to a command with colors
*
*
* @param client Client to reply to
* @param author Client to use for {teamcolor}
* @param message Message (formatting rules)
@@ -383,12 +383,12 @@ stock void MC_ReplyToCommandEx(int client, int author, const char[] message, any
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* MC_ShowActivity2() is slightly more useful.
* Supports color tags.
*
@@ -402,14 +402,14 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
if (sm_show_activity == INVALID_HANDLE)
sm_show_activity = FindConVar("sm_show_activity");
char tag[] = "[SM] ";
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
@@ -417,7 +417,7 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@@ -425,13 +425,13 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE)
{
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
@@ -441,16 +441,16 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@@ -475,7 +475,7 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@@ -494,12 +494,12 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
@@ -518,12 +518,12 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
if (sm_show_activity == INVALID_HANDLE)
sm_show_activity = FindConVar("sm_show_activity");
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
@@ -531,7 +531,7 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@@ -539,13 +539,13 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE)
{
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
@@ -555,16 +555,16 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@@ -589,7 +589,7 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@@ -608,18 +608,18 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
@@ -634,19 +634,19 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
{
if (sm_show_activity == INVALID_HANDLE)
sm_show_activity = FindConVar("sm_show_activity");
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
// ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
if (client != 0)
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@@ -654,12 +654,12 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
{
sign = "PLAYER";
}
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
* twice.
*/
MC_PrintToChatEx(client, client, "%s%s", tag, szBuffer);
@@ -668,16 +668,16 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@@ -702,7 +702,7 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@@ -721,18 +721,18 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
return 1;
}
/**
* Determines whether a color name exists
*
*
* @param color The color name to check
* @return True if the color exists, false otherwise
*/