String to HEX - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: String to HEX (
/showthread.php?tid=218185)
String to HEX -
Jeffry - 29.01.2011
Hello guys,
I've searched for this, but I did not find it.
I need a function that converts a string (Inputtext at Dialog) to a Hex, which gets stored afterwards in a variable.
Ex:
pawn Код:
MyHexVar = StringToHex(inputtext);
TextDrawColor(MyTextDraw, MyHexVar);
That's what I need. I hope someone can help me.
Greetings,
Jeffry
Re: String to HEX -
Jeffry - 31.01.2011
No reply after 2 days.
Is there no such function, or just any way?
Re: String to HEX -
Vince - 31.01.2011
https://sampwiki.blast.hk/wiki/Colors_List
pawn Код:
stock HexToInt(string[])
{
if (string[0] == 0)
{
return 0;
}
new i;
new cur = 1;
new res = 0;
for (i = strlen(string); i > 0; i--)
{
if (string[i-1] < 58)
{
res = res + cur * (string[i - 1] - 48);
}
else
{
res = res + cur * (string[i-1] - 65 + 10);
cur = cur * 16;
}
}
return res;
}
Re: String to HEX -
Jeffry - 31.01.2011
Alright, thanks Vince, I'll try this out soon (Busy alot^^).
@******: I searched on forums at all, but okey, I'll check there next time.
EDIT: The function of Vince doesn't work correctly.
But the link helped, DracoBlue's one works.
Thanks guys.