Commits

DarthNinja committed 88218ee Draft

Code optimizations
Fixed a handle leak
Removed the test command

  • Participants
  • Parent commits 1badcb4

Comments (0)

Files changed (1)

File ColourChat.sp

 #include <regex>
 #include <scp>
-new const String:PLUGIN_VERSION[10] = "1.0.0.SCP";
+new const String:PLUGIN_VERSION[10] = "1.1.0.SCP";
+new Handle:hRegex = INVALID_HANDLE;
 
 public Plugin:myinfo =
 {
 public OnPluginStart()
 {
 	LoadTranslations("common.phrases");
-	RegAdminCmd("cc", TestCommand, ADMFLAG_ROOT, "How bout some colours");
 	CreateConVar("chatcolours_version", PLUGIN_VERSION, "Plugin Version", FCVAR_PLUGIN|FCVAR_NOTIFY);
-}
-
-public Action:TestCommand(client, args)
-{
-	new String:Text[256];
-	GetCmdArgString(Text, sizeof(Text));
-
-	decl String:matchedTag[64];
-	decl String:Copy[64];
-	new Handle:hRegex = CompileRegex("(#[A-Fa-f0-9]{6})");
-	while (MatchRegex(hRegex, Text) > 0)
-	{
-		GetRegexSubString(hRegex, 0, matchedTag, sizeof(matchedTag));
-		new location = StrContains(Text, matchedTag);
-		if (location == -1)
-			break; // Something bad happened, run away!
-
-		strcopy(Copy, sizeof(Copy), matchedTag);
-		ReplaceStringEx(Copy, sizeof(Copy), "#", " \x07");
-		ReplaceStringEx(Text, sizeof(Text), matchedTag, Copy);
-		PrintToChatAll("Replaced %s with %s.  Text = %s", matchedTag, Copy, Text);
-	}
-
-	PrintToChatAll("%s", Text);
-	return Plugin_Handled;
+	
+	hRegex = CompileRegex("(#[A-Fa-f0-9]{6})");
 }
 
 //Using Simple Chat Processor
 		
 	decl String:matchedTag[64];
 	decl String:Copy[64];
-	new Handle:hRegex = CompileRegex("(#[A-Fa-f0-9]{6})");
 	while (MatchRegex(hRegex, message) > 0)
 	{
 		GetRegexSubString(hRegex, 0, matchedTag, sizeof(matchedTag));
 		ReplaceStringEx(message, MAXLENGTH_MESSAGE, matchedTag, Copy);
 	}
 	return Plugin_Changed;
-}
+}