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

I am trying to make color saving system, but Y_INI system can save only numbers, and i tryied to #define 3 0xFFFF00AA
But i cant, so is there a way to define color with number or another way to save colors ?
Reply
#2

You can save it with words.
#define Yellow 0xFFFF00AA
Reply
#3

Nope, i tried and in .INI file it looks like that:Color: -12312
Reply
#4

The problem is:When i try to make color saving system, colors in USER file .INI shows -2321321
Reply
#5

I want that too I am using register system which is using Y_INI...
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)