Embedded colour codes with format();
#1

Hi all,

I've been looking all over for how to do this, but cant seem to find anything anywhere to help me crack it. I'm trying to embed colour codes into a string using format. My code is below:

Код:
#define EMBED_WHITE "{FFFFFF}"
#define EMBED_WHITESMOKE "{F5F5FF}"

format(string, sizeof(string), "%x%s: %x%s",EMBED_WHITE, fullName(playerid, false), EMBED_WHITESMOKE, text);
However, unfortunately it's just outputting like below:



Any ideas? Thanks
Reply
#2

Код:
format(string, sizeof (string), ""EMBED_WHITE"%s: "EMBEND_WHITESMOKE"%s", fullName(playerid, false), text);
Reply
#3

change %x -> %s
Reply
#4

format(string, sizeof(string), ""#EMBED_WHITE"%s: "#EMBED_WHITESMOKE"%s", fullName(playerid, false), text);
Reply
#5

Just add your colors like this example
Quote:

new string[128];
format(string, sizeof string, "{00ff00}Hello %s" , pName(playerid));

So it will send a message saying hello to player with color lime green.
Hope I helped you.
Reply
#6

Thanks very much, repped
Reply
#7

Hi again all,

I now have a further issue relating to this. In my chatlog (so what will be the player's chatlog) you can see the colour codes. How do I get rid of this? It currently shows:

Код:
[19:32:16] {FFFFFF}Joe Bloggs: {F5F5FF}Test
[19:32:18] {A3A3A3}(([0] Joe Bloggs: Test))
Reply
#8

You can't.
Reply
#9

If you want to read it in the chat log, you'll need to format the string again without the colour brackets, and print ( ) it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)