Chat HEX colors - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Chat HEX colors (
/showthread.php?tid=368439)
Chat HEX colors -
Shredmaster - 13.08.2012
Hey.
I wanna know how to enable hex colors in chat.
So basically I want to write in chat: {FF0000} Hello world.
To get:
Hello world.
I really hope you can help me.
Re: Chat HEX colors -
MeDaKewlDude - 13.08.2012
this was made by Y-Less.
put this above OnPlayerText
pawn Код:
ReColor(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] = '}';
}
}
}
and this at the begenning of OnPlayerText:
although now, you use (FF0000) instead of {FF0000}
Re: Chat HEX colors -
Shredmaster - 13.08.2012
Hmm, I didn't quite understand this.
Can you explain it to me a little? Where should I put this ReColor(text); ?
Re: Chat HEX colors -
MeDaKewlDude - 13.08.2012
if you have the callback "OnPlayerText(playerid,text[])" then in there. otherwise, add
pawn Код:
public OnPlayerText(playerid, text[])
{
ReColor(text);
return 1;
}
you can put the function anywhere in the script, but its easiest to find above OnPlayerText
Re: Chat HEX colors -
Shredmaster - 13.08.2012
Now it's working, thanks a lot.