SA-MP Forums Archive
String with hex to pawn color - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: String with hex to pawn color (/showthread.php?tid=105613)



String with hex to pawn color - Dreftas - 30.10.2009

How to make pawn color (0xRRGGBBFF) from string which has "RRGGBB" ?


Re: String with hex to pawn color - Zeex - 30.10.2009

https://sampwiki.blast.hk/wiki/Sscanf

pawn Код:
new hex;
sscanf("0x112233FF", "x", hex);
printf("%x", hex);



Re: String with hex to pawn color - Dreftas - 30.10.2009

Quote:
Originally Posted by ZeeX
https://sampwiki.blast.hk/wiki/Sscanf

pawn Код:
new hex;
sscanf("0x112233FF", "x", hex);
printf("%x", hex);
Looking at this i need to write string like this "0x112233FF", but i need that string "112233" be converted to hexadecimal - 0x112233FF.
How to do this ?




Re: String with hex to pawn color - Dreftas - 30.10.2009

pawn Код:
new hex;
    sscanf("112233FF", "x", hex);
    printf("%x", hex);
Prints 112233FF, why not 0x112233FF then ?


Re: String with hex to pawn color - Finn - 30.10.2009

Quote:
Originally Posted by Dreft
pawn Код:
new hex;
    sscanf("112233FF", "x", hex);
    printf("%x", hex);
Prints 112233FF, why not 0x112233FF then ?
Try and check what it prints when you have '0x' in the hex code. Yes, the same thing.


Re: String with hex to pawn color - Dreftas - 30.10.2009

Quote:
Originally Posted by Finn
Try and check what it prints when you have '0x' in the hex code. Yes, the same thing.
pawn Код:
new hex;
    sscanf("0x112233FF", "x", hex);
    printf("%x", hex);
Prints 112233FF, i need 0x at beginning :/


Re: String with hex to pawn color - Correlli - 30.10.2009

Quote:
Originally Posted by Dreft
Prints 112233FF, i need 0x at beginning :/
Is it so hard to do it like this?

pawn Код:
new hex;
sscanf("0x112233FF", "x", hex);
printf("0x%x", hex);



Re: String with hex to pawn color - Dreftas - 30.10.2009

Oh, everything works now Thanks Zeex, ******.