SA-MP Forums Archive
Whats wrong with loading from a file? - 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: Whats wrong with loading from a file? (/showthread.php?tid=134091)



Whats wrong with loading from a file? - ДitisOnHuora - 15.03.2010

http://pawn.pastebin.com/ArYQaVAn

Somehow it doesnt load from ini, but it saves fine.. ?


Re: Whats wrong with loading from a file? - ДitisOnHuora - 15.03.2010

It saves good and stuff, but then after restart it wont load from the file, and everything is 0..


Re: Whats wrong with loading from a file? - Finn - 15.03.2010

You can try this:
pawn Код:
public LoadFamily()
{
  new File: file = fopen("family.ini", io_read);
  if ( file )
  {
    new key[ 256 ], Data[ 256 ];
    while ( fread( file , Data , sizeof( Data ) ) )
    {
      key[0] = EOS;
      strcat(key, ini_GetKey( Data ), sizeof( key ) );

      if( strcmp( key , "FX" , true ) == 0 ) FX = floatstr( ini_GetValue( Data ) );
      else if( strcmp( key , "FY" , true ) == 0 ) FY = floatstr( ini_GetValue( Data ) );
      else if( strcmp( key , "FZ" , true ) == 0 ) FZ = floatstr( ini_GetValue( Data ) );
      else if( strcmp( key , "FerMat" , true ) == 0 ) FerMat = strval( ini_GetValue( Data ) );
      else if( strcmp( key , "FerPot" , true ) == 0 ) FerPot = strval( ini_GetValue( Data ) );
      else if( strcmp( key , "FerMoney" , true ) == 0 ) FerMoney = strval( ini_GetValue( Data ) );
      else if( strcmp( key , "MX" , true ) == 0 ) MX = floatstr( ini_GetValue( Data ) );
      else if( strcmp( key , "MY" , true ) == 0 ) MY = floatstr( ini_GetValue( Data ) );
      else if( strcmp( key , "MZ" , true ) == 0 ) MZ = floatstr( ini_GetValue( Data ) );
      else if( strcmp( key , "MiyMat" , true ) == 0 ) MiyMat = strval( ini_GetValue( Data ) );
      else if( strcmp( key , "MiyPot" , true ) == 0 ) MiyPot = strval( ini_GetValue( Data ) );
      else if( strcmp( key , "MiyMoney" , true ) == 0 ) MiyMoney = strval( ini_GetValue( Data ) );
    }
    fclose(file);
  }
  return 1;
}
I don't like the way you put spaces everywhere.


Re: Whats wrong with loading from a file? - ДitisOnHuora - 15.03.2010

Omg Finn... -.- ..


I LOVE YOU!