Converting colors from 'normal' to embed -
Mean - 27.08.2013
Is there a function, that for example, converts 0xFFFFFFFF to FFFFFF?
Re : Converting colors from 'normal' to embed -
Matnix - 27.08.2013
pawn Код:
0xFFFFFFFF =
0x
FFFFFF // the embded code
FF // color power
I always use this methods, but I hope you will found a converter It's will help me too. ahah.
Re: Converting colors from 'normal' to embed -
Vule. - 27.08.2013
You can use this
https://sampforum.blast.hk/showthread.php?tid=387690
Re: Converting colors from 'normal' to embed -
Luis- - 27.08.2013
You know what, i'm going to attempt to make a converter tomorrow. I could do with one as well.
Re: Converting colors from 'normal' to embed -
Mean - 27.08.2013
Quote:
Originally Posted by Luis-
You know what, i'm going to attempt to make a converter tomorrow. I could do with one as well.
|
I'd need a function, converting the color manually is easy, you just remove the 0x and the last 2 characters (opacity), but I'd need a PAWN function that would automatically do that.
Re: Converting colors from 'normal' to embed -
Luis- - 28.08.2013
Okay! Something like 'HEX2RGB(colour)' & 'RGB2HEX(colour)'.
Re: Converting colors from 'normal' to embed -
Mean - 28.08.2013
Wrote my own function.
pawn Код:
stock ColorToEmbed(const color[]) {
new finalclr[7];
format(finalclr, sizeof finalclr, "%s", color[2]);
return finalclr;
}
CMD:embed(playerid, params) {
new str[128], col[7];
col = ColorToEmbed("0xFFFFFFFF");
format(str, sizeof str, "Hi {%s}there.", col);
SendClientMessage(playerid, 0xFF0000FF, str);
return 1;
}
You need to input your color as a string into ColorToEmbed and it will return a color string without 0x and the last 2 characters. Works like charm.
Re: Converting colors from 'normal' to embed -
Luis- - 28.08.2013
Ah, fair enough! How does it remove the 0x and FF though?
Re: Converting colors from 'normal' to embed -
Squash - 28.08.2013
Quote:
Originally Posted by Luis-
Ah, fair enough! How does it remove the 0x and FF though?
|
The trick is in the size of the strings. A string is basically an array with a value for each character and a final value of
NUL to signify the end of string. Keep in mind that array keys start at zero. Mean sets the size of
finalchr to seven, meaning that only a string six characters in length can fit inside of it. He then formats the string using
color[2], which returns the value of
color starting from the third character. The first two characters are therefore omitted, leaving us with the "FFFFFFFF". This is eight characters long and so when it tries to fit in to
finalchr, the last two characters are omitted to make room, leaving us with "FFFFFF".
Re: Converting colors from 'normal' to embed -
Vince - 28.08.2013
Shifting to the right is the only thing you need to do. You can then format using %06x.
pawn Код:
new embedColor = originalColor >>> 8;