[REP++] PROBLEM ! HEX TO ARGB - 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)
+--- Thread: [REP++] PROBLEM ! HEX TO ARGB (
/showthread.php?tid=585403)
Solved. -
buburuzu19 - 13.08.2015
Solved.
AW: [REP++] PROBLEM ! HEX TO ARGB -
Kaliber - 13.08.2015
Maybe use strval?
Re: [REP++] PROBLEM ! HEX TO ARGB -
buburuzu19 - 13.08.2015
SOLVED.
Re: [REP++] PROBLEM ! HEX TO ARGB -
Vince - 13.08.2015
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.
Re: [REP++] PROBLEM ! HEX TO ARGB -
LetsOWN[PL] - 13.08.2015
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
Re: [REP++] PROBLEM ! HEX TO ARGB -
buburuzu19 - 13.08.2015
SOLVED.
Re: [REP++] PROBLEM ! HEX TO ARGB -
ikkentim - 13.08.2015
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.
Re: [REP++] PROBLEM ! HEX TO ARGB -
buburuzu19 - 13.08.2015
SOLVED.
Re: [REP++] PROBLEM ! HEX TO ARGB -
buburuzu19 - 13.08.2015
SOLVED.
Re: [REP++] PROBLEM ! HEX TO ARGB -
Jefff - 13.08.2015
TatooInfo[i][ttColor] is string array or integer?