[REP++] PROBLEM ! HEX TO ARGB
#1

Solved.
Reply
#2

Maybe use strval?
Reply
#3

SOLVED.
Reply
#4

Quote:
Originally Posted by buburuzu19
Посмотреть сообщение
I extract the colors from my database as VARCHARS.
WHY? Colors are numbers. Yes, it may look like -16777216 if you view it in your database, but so what? Storing and fetching as an integer is way more efficient than converting to and from string.
Reply
#5

Quote:
Originally Posted by buburuzu19
Посмотреть сообщение
Hello guys, i can't figure out how to convert hex to ARGB.
I need this for SetObjectMaterialText , the colors of the font must be 0xFFFFFFFF and i am getting them from my database as HEX like FF0000.
I tried to get them as ARGB from the mysql database (0xFFFFFFFF) but the text won't appear because i get them as string. (VARCHAR in the database)
Can someone help?
Thanks !
SA-MP has no ARGB pattern, but RGBA.
Here's a little piece of code that I wrote for You:
pawn Код:
stock addAlpha(&basecolor, amount)
    return (basecolor<<8)+amount;
Example:
pawn Код:
new hex = 0xFF0000;
    printf("Before: %x after: %x", hex, addAlpha(hex, 255));
Will print:
Код:
Before: FF0000 after: FF0000FF
Greetings.

-- Nevermind, didn't noticed that You are storing Your color as VARCHAR, my bad
Reply
#6

SOLVED.
Reply
#7

Quote:
Originally Posted by buburuzu19
Посмотреть сообщение
SetObjectMaterialText requires me to use 0xFFFFFFFF colors.
Give me an example of how to use all your code in SetObjectMaterialText and how should i store the color in the mysql database.
Thanks.

EDIT: My variable for colors is CarInfo[i][ttColor]
You can just as well use decimal numbers SetObjectMaterialText . hexidecimal numbers(0xabc) is just an different representation of numbers.

Store your numbers in a variable (CarInfo[i][ttColor] in your case) and simply store that variable to the database in a int column.
Reply
#8

SOLVED.
Reply
#9

SOLVED.
Reply
#10

TatooInfo[i][ttColor] is string array or integer?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)