Hexadecimal save -
Kraeror - 15.09.2017
Hello guys, how can I save hexadecimal numbers, using sscanf and ysi_ini?
PLEASE, I realy need help! Give me only the saving and loading hexadecimal numbers!
Thanks
Re: Hexadecimal save -
Vince - 15.09.2017
Like any other integer value. They might come out looking like -15786300 or something like that but that's normal. The reason you can use -1 in SendClientMessage to get white is that -1 is exactly the same as 0xFFFFFFFF, just represented differently.
Re: Hexadecimal save -
Kraeror - 15.09.2017
Okay, than can you give me convertor from Hexadecimal to Decimal Value as stock? I can save and load it as string so can you tell me how to convert it to Decimal, because SetPlayerColor can't write strings?
Re: Hexadecimal save -
Vince - 15.09.2017
There is no need to convert between decimal and hexadecimal because there is nothing to convert. It's the same number. Just fetch and store with the regular Int functions like you would any other number, like score or money.
Unless you are constantly going to edit the files manually, storing a hexadecimal string is useless.
Re: Hexadecimal save -
Kraeror - 16.09.2017
I tried it, but it is not working, when I type something like: 0xFF0000FF it saves it as 0 and it loads it as black color!
When type in 4278190335, it saves as -16776961 and it loads it as red color(because 0xFF0000FF is red color)!
So when I'm using Deciminal value, it works perfect!
Can anyone help me, please?
+1 REP
Re: Hexadecimal save -
Silentx9 - 16.09.2017
Try using this calculator for decimal to hex
Quote:
#define COL(%0,%1,%2,%3) (((%0 << 24)&0xFF000000) + ((%1<<16)&0xFF0000) + ((%2<< 8 )&0xFF00) + (%3))
|
Put it on top of your script for global use.
Here
%0 - RR
%1 - GG
%2 - BB
%3 - AA
Please check the parenthesis once more.
The use is like
Quote:
SendClientMessage(playerid,COL(255,255,255,255),"T his text is white");
|
Re: Hexadecimal save -
Kraeror - 16.09.2017
Guys I want, when I type in dialog 0xFFFFFFFF it saves as white color and loads as white color. I'm using it for SetPlayerColor(playerid,color); Can you give me code for format it FROM HEX TO DECIMAL(for save the color) and FROM DECIMAL TO HEX(to load the color).
Thanks!
Re: Hexadecimal save -
Kraeror - 16.09.2017
Quote:
Originally Posted by Silentx9
Try using this calculator for decimal to hex
Put it on top of your script for global use.
Here
%0 - RR
%1 - GG
%2 - BB
%3 - AA
Please check the parenthesis once more.
The use is like
|
EDIT: SOLVED, I just saved the HEX as string and load it as string and after I used the function HexToInt(string[]).
Thanks trying help all, I will +1 REP you all!