ColorLib is built as a replacement for Colors, it uses a a less naive approach to formatting messages to improve the performance of C* functions.
Why?
The reason for this is that Colors and More Colors both make heavy use of many ReplaceString operations each one looping through the buffer being formatted, whereas this could be avoided by writing a single pass formatter as used here and was done for ColorVariables.
And to why replace ColorVariables? it also adds extra overhead with forwards and allowing for more "dynamic" colors, which isnt always needed.
So ColorLib was created.
Performance:
ColorLib is currently twice over twice as fast as MultiColors when using CPrintToChat, further and improved benchmarks will be availible at the
GitHub Repository
Example:
Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <colorlib>
public void OnPluginStart()
{
RegConsoleCmd("sm_colorlib", Command_ColorLib);
}
public Action Command_ColorLib(int client, int args)
{
CPrintToChat(client, "CPrintToChat - {darkblue}%s - {darkred}%s", "Test", "Test");
CPrintToChatAll("CPrintToChatAll - {darkblue}%s - {darkred}%s", "Test", "Test");
CPrintToChatEx(client, client, "CPrintToChatEx - {darkblue}%s - {darkred}%s", "Test", "Test");
CPrintToChatAllEx(client, "CPrintToChatAllEx - {darkblue}%s - {darkred}%s", "Test", "Test");
CReplyToCommand(client, "CReplyToCommand - {darkblue}%s - {darkred}%s", "Test", "Test");
CReplyToCommandEx(client, client, "CReplyToCommandEx - {darkblue}%s - {darkred}%s", "Test", "Test");
CPrintToServer("CPrintToServer - {darkblue}%s - {darkred}%s", "Test", "Test");
}
More info and download at the
GitHub Repository