All pastes #2091673 Raw Edit

coloured chat text

public text v1 · immutable
#2091673 ·published 2011-10-20 03:06 UTC
rendered paste body
#include <a_samp>

ReColour(text[])
{
	new
		pos = -1;
	while ((pos = strfind(text, "(", false, pos + 1)) != -1)
	{
		new
			c = pos + 1,
			n = 0,
			ch;
		// Note that the order of these is important!
		while ((ch = text[c]) && n != 6)
		{
			if (!('a' <= ch <= 'f' || 'A' <= ch <= 'F' || '0' <= ch <= '9'))
			{
				break;
			}
			++c;
			++n;
		}
		if (n == 6 && ch == ')')
		{
			text[pos] = '{';
			text[c] = '}';
		}
	}
}

public OnPlayerText(playerid, text[])
{
	// Recolour the text
	ReColour(text);
	return 1;
}