sscanf and decimals
#1

This is what I use to load my objects from files

pawn Код:
forward LoadObjects();
public LoadObjects()
{
    new File:file, str[128];
    format(str, sizeof str, "CoDS/Maps/%s/Map.ini", MapName);
    file = fopen(str, io_read);
    if (!file) return 0;
    new
      line[128],
      count,
      modelid,
      Float:X, Float:Y, Float:Z,
      Float:rX, Float:rY, Float:rZ;
    while (fread(file, line))
    {
      if (!sscanf(line, "iffffff", modelid, X, Y, Z, rX, rY, rZ))
      {
        CreateObject(modelid, X, Y, Z, rX, rY, rZ);
        count++;
      }
    }
    fclose(file);
    return count;
}
The only problem being if there is more than 6 decimal places it returns the float as 0.000000

Is there anyway I can fix this without having to go through every object and deleting some decimals?
Reply
#2

Is there any other way I can read the objects from a file?
Reply
#3

Try saving them as strings and then spawn the objects using strval()
Reply
#4

That didn't work at all.
Reply
#5

I had the same problem a while ago, the solution is
http://forum.sa-mp.com/index.php?top...2649#msg682649
Reply
#6

Quote:
Originally Posted by Doktor
I had the same problem a while ago, the solution is
http://forum.sa-mp.com/index.php?top...2649#msg682649
Thanks that helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)