Read Color from File
#1

Hi, I'm working on a system to read vehicles and classes from a file.
Everything works fine, but I don't know how to read the color code. Because it's not a string and it's not an integer.
This is how my system works:

Код:
ClassInfo[idx][Y] = floatstr(arrCoords[...]); // Float
ClassInfo[idx][Interior] = strval(arrCoords[...]); // Integer
strmid(ClassInfo[idx][Name], arrCoords[...], 0, strlen(arrCoords[...]), 255); // String
But what's the function to read a hex code/color code and in which format I have to write it into the file?
Thanks for replies.
Reply
#2

Are you using dini or dudb or something?

I don't really know what you would call the color code or w.e. If I had a guess I would guess it was a hex sort of thing which would be %x in formats.

If your using like dini or dudb, I would try saving it and retrieving it as a string and see what happens
Reply
#3

this is tricky for me, but i did run across "HexToInt", maybe this will get you started, you could read more about it to try and figure it out.

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;
    }
and an example was something like

pawn Код:
new Color = GetPlayerColor(playerid);
    PlayerInfo[i][Color] = HexToInt(Color);
good luck

edit: some threads

http://forum.sa-mp.com/index.php?topic=89879.0
http://forum.sa-mp.com/index.php?topic=54420.0
http://forum.sa-mp.com/index.php?top...2976#msg182976
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)