String with hex to pawn color
#1

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

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

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

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 ?

Reply
#4

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

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.
Reply
#6

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 :/
Reply
#7

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);
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)