SA-MP Forums Archive
sscanf and decimals - 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: sscanf and decimals (/showthread.php?tid=100525)



sscanf and decimals - Gappy - 05.10.2009

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?


Re: sscanf and decimals - Gappy - 05.10.2009

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


Re: sscanf and decimals - dice7 - 05.10.2009

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


Re: sscanf and decimals - Gappy - 05.10.2009

That didn't work at all.


Re: sscanf and decimals - Doktor - 05.10.2009

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


Re: sscanf and decimals - Gappy - 05.10.2009

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