Is there a way to define color with number ?
#6

pawn Код:
/** BY DRACOBLUE
 *  Return the value of an hex-string
 *  @param string
 */

stock HexToInt(string[]) {
    if (string[0]==0) return 0;
    new i;
    new cur=1;
    new res=0;
    for (i=strlen(string);i>0;i--) {
        if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
        cur=cur*16;
    }
    return res;
}
All hex codes output an integer, for example 0xFFFFFFFF outputs -1.

The function I supplied you will convert your hexidecimal into an integer for you. You can always use an integer as a colour on functions, for example:

pawn Код:
// Player's Colour
SetPlayerColor( playerid, -1 ); // Will give white

//Client message
SendClientMessage( playerid, -255, "Hello World!" ); // Might give black (haven't tried)
All you do is save the output from that function to your ini. To load it, just retrieve it as an integer and store it in a variable.

I hope I helped!
Reply


Messages In This Thread
Is there a way to define color with number ? - by bustern - 05.09.2013, 10:01
Re: Is there a way to define color with number ? - by FiReAlEx - 05.09.2013, 10:03
Re: Is there a way to define color with number ? - by bustern - 05.09.2013, 10:07
Re: Is there a way to define color with number ? - by bustern - 05.09.2013, 12:04
Re: Is there a way to define color with number ? - by bustern - 05.09.2013, 12:16
Re: Is there a way to define color with number ? - by Lorenc_ - 05.09.2013, 12:27

Forum Jump:


Users browsing this thread: 1 Guest(s)