SA-MP Forums Archive
How to save & load hex color on MySQL? - 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: How to save & load hex color on MySQL? (/showthread.php?tid=316727)



How to save & load hex color on MySQL? - T0pAz - 08.02.2012

Well the title says it all. I've tried using integer but it's all messed up. I want to know an efficient way of saving and loading it.


Re: How to save & load hex color on MySQL? - Vince - 08.02.2012

What exactly doesn't work? Can we see your saving and loading code?


Re: How to save & load hex color on MySQL? - T0pAz - 08.02.2012

It only saves the digits.


Re: How to save & load hex color on MySQL? - Vince - 08.02.2012

The what? I don't quite understand.


Re: How to save & load hex color on MySQL? - CaHbKo - 08.02.2012

Digits is 1 4 6 8 0, ie. numbers.

This guy doesn't know how to save hex values
0xFFFFFF 0xABCDEF etc


Re: How to save & load hex color on MySQL? - T0pAz - 08.02.2012

Quote:
Originally Posted by CaHbKo
Посмотреть сообщение
Digits is 1 4 6 8 0, ie. numbers.

This guy doesn't know how to save hex values
0xFFFFFF 0xABCDEF etc
Right.


Re: How to save & load hex color on MySQL? - Niko_boy - 08.02.2012

well u can try sscanf ! for saving
its like >>

u can try that ^^
u know mysql right?


Re: How to save & load hex color on MySQL? - T0pAz - 08.02.2012

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
well u can try sscanf ! for saving
its like >>

u can try that ^^
u know mysql right?
Could you please explain properly?

Edit: Any other way? Because it gets messed up after it got inserted on mysql db.


Re: How to save & load hex color on MySQL? - Vince - 08.02.2012

Colors are numbers, and numbers can be changed into any notation you'd like.

Suppose you have this: 0x0000FF99, which is a blue color. If you save it as integer in MySQL you would get 65433 as a value for that field, which is the correct decimal value for that hex color. Doing this works:
pawn Код:
SendClientMessage(playerid, 65433, "This message is blue!");
As does this:
pawn Код:
printf("Hex: %08x - Decimal: %d", 65433, 0x0000FF99);



Re: How to save & load hex color on MySQL? - T0pAz - 08.02.2012

@Vince - Never knew it! You deserve reputation from me.
@****** - I already got the solution but I will surely look at that thread and learn more about colors.