[Suggestion] Color embedding
#1

Isn't it possible instead of the {FFFFF} to be able to put {COLOR_YELLOW} since we already have them defined in our script. Redefining everything would be awful.

I would suggest this format:
pawn Код:
format(str,sizeof(str),"{%d}Hello, I am {%d}scottyishere",COLOR_YELLOW,COLOR_GREEN);
Also there's a little problem, the color embedding things are taking string space.
Like if I have a str[128] string and my chars are 127, if I add color embedding the last letters won't be seen. I need to make the string bigger which costs a lot of memory.
Can this be fixed anyhow?
Reply
#2

You can insert hex in format using %x
Reply
#3

Ow... yeah your right! Didn't knew that.

Thanks, but the second problem still remains.
Reply
#4

Or this ?

pawn Код:
SendClientMessage(playerid, COLOR_WHITE, "{" #COLOR_YELLOW "}Hello, {" #COLOR_WHITE "} this is my server.");
Reply
#5

You put the color code into the string like any other text, and samp comverts it later. So no, there is no other way than increasing the string size.
Reply
#6

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
You can insert hex in format using %x
An example?
Reply
#7

pawn Код:
format(str,sizeof(str),"%xHello, I am %xscottyishere",COLOR_YELLOW,COLOR_GREEN);
Reply
#8

I have this code:

pawn Код:
SendFormattedMessage(playerid,COLOR_WHITE,">> Vehicle engine: %xOFF",COLOR_ERROR);
This is the SendFormattedMessage function:

pawn Код:
#define SendFormattedMessage(%0,%1,%2) do{new _str[128]; format(_str,128,%2); SendClientMessage(%0,%1,_str);}while(FALSE)
and it doesn't display any modified colors. Just some random text where the %x is.

Any ideas?
Reply
#9

Unfortunately the %x is not working:

pawn Код:
#define COLOR_RED 0xCD000000
pawn Код:
format(str,128,"Hello, I like %xcheese",COLOR_RED);
SendClientMessage(playerid,COLOR_WHITE,str);
The output is a random characters where the %x is. Also if I add { } between the %x = {%x} it returns a different color from the defined one.

Any ideas?
Reply
#10

The values for chat colors are without alpha; therefore, 0x00FF00FF should be 0x00FF00.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)