SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/09/2017, 09:52 PM   #1
Kraeror
Gangsta
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default Hexadecimal save

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
Kraeror is offline   Reply With Quote
Old 15/09/2017, 09:55 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,083
Reputation: 2655
Default Re: Hexadecimal save

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.
__________________
Vince is offline   Reply With Quote
Old 15/09/2017, 09:58 PM   #3
Kraeror
Gangsta
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default Re: Hexadecimal save

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?
Kraeror is offline   Reply With Quote
Old 15/09/2017, 10:18 PM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,083
Reputation: 2655
Default Re: Hexadecimal save

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.
__________________
Vince is offline   Reply With Quote
Old 16/09/2017, 11:32 AM   #5
Kraeror
Gangsta
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default Re: Hexadecimal save

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
Kraeror is offline   Reply With Quote
Old 16/09/2017, 12:14 PM   #6
Silentx9
Little Clucker
 
Join Date: Aug 2017
Posts: 4
Reputation: 1
Default Re: Hexadecimal save

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");
Silentx9 is offline   Reply With Quote
Old 16/09/2017, 12:52 PM   #7
Kraeror
Gangsta
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default Re: Hexadecimal save

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!
Kraeror is offline   Reply With Quote
Old 16/09/2017, 01:34 PM   #8
Kraeror
Gangsta
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default Re: Hexadecimal save

Quote:
Originally Posted by Silentx9 View Post
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!
Kraeror is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hexadecimal in phpMyAdmin AiRaLoKa Scripting Help 0 17/05/2014 05:35 AM
[Tutorial] Binários & Hexadecimal RebeloX Lançamentos/Releases 25 13/09/2013 09:44 PM
[Ajuda] Hexadecimal Dr_Pawno Português/Portuguese 1 15/08/2012 12:21 AM
Best way to save hexadecimal using sscanf and mysql? LiamM Scripting Help 0 03/01/2012 11:02 AM
hexadecimal codes Kar Help Archive 8 04/06/2010 10:47 PM


All times are GMT. The time now is 03:25 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.