Liberty Unleashed

Scripting => Script Snippets => Topic started by: Windlord on January 11, 2011, 03:13:14 pm

Title: IRC Colours stripping
Post by: Windlord on January 11, 2011, 03:13:14 pm
Code: (squirrel) [Select]
// This function strips the IRC colours off of a string
// Good to use with the IRC echo
function StripCol ( text )
{
local a, z = text.len(), l;
local coltrig = false, comtrig = false, num = 0, output = "";
for ( a = 0; a < z; a++ )
{
l = text[ a ];
if ( l == 3 ) { coltrig = !coltrig; num = 0; comtrig = false; }
else if ( coltrig && num < 2 && l < 58 && 47 < l ) { num++; }
else if ( coltrig && !comtrig && l == 44 ) { comtrig = true; num = 0; }
else { num = 2; comtrig = false; output += l.tochar(); }
}
return output;
}