Hexadecimal colors in my script? (and DB)
#9

Quote:
Originally Posted by Voldemort
Посмотреть сообщение
This will help you
pawn Код:
forward RGBAToHex(r, g, b, a); //By Betamaster
forward HexToRGBA(colour, &r, &g, &b, &a); //By Betamaster

public RGBAToHex(r, g, b, a) //By Betamaster
{
    return (r<<24 | g<<16 | b<<8 | a);
}

public HexToRGBA(colour, &r, &g, &b, &a) //By Betamaster
{
    r = (colour >> 24) & 0xFF;
    g = (colour >> 16) & 0xFF;
    b = (colour >> 8) & 0xFF;
    a = colour & 0xFF;
}
or
pawn Код:
stock hexstr(string[]) // By ******
{
    new
        ret,
        val,
        i;
    if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) i = 2;
    while (string[i])
    {
        ret <<= 4;
        val = string[i++] - '0';
        if (val > 0x09) val -= 0x07;
        if (val > 0x0F) val -= 0x20;
        if (val < 0x01) continue;
        if (val < 0x10) ret += val;
    }
    return ret;
}
Yeah, didnt realise ****** had that..

How would i store it in my database? As a string, then use this before i use it??

Also, do i include "0x" or "#" at the start of the string? so like:

0xFF0000
or
#FF0000

for Red
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)