Posts: 1,047
Threads: 23
Joined: Jun 2009
Quote:
Originally Posted by GaByM
How can I format coloured strings?
PHP Code:
public OnPlayerText(playerid,text[])
{
new s[144];
format(s,144,"{%x}%s{FFFFFF}: %s",u[playerid][pcolor],name[playerid],text);
SendClientMessageToAll(-1,s);
return 0;
}
This will show the color instead of coloring the name.
|
I think you should make it in the {RRGGBB} format
PHP Code:
public OnPlayerText(playerid,text[])
{
new s[144];
format(s,144,"{%06X}%s{FFFFFF}: %s",u[playerid][pcolor],name[playerid],text);
SendClientMessageToAll(-1,s);
return 0;
}
I don't know if upper/lowercase matters, probably not but if I'm correct then %X (uppercase X) should produce a 000000 to FFFFFF. if your u[playerid][pcolor] variable has alpha like 0x112233AA then you should make that line into:
PHP Code:
format(s,144,"{%06X}%s{FFFFFF}: %s",u[playerid][pcolor] >> 8 & 0xFFFFFF,name[playerid],text);
Correct me if I'm wrong but I tried this in C before posting haha:
http://ideone.com/GeDKb2 (which isn't PAWN but the behaviour shouldn't be that much different for these things).