SA-MP Forums Archive
Read and Write - 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: Read and Write (/showthread.php?tid=96568)



Read and Write - Master_FM - 09.09.2009

Hi,

i want to read some data out of a file and also write it on another file, but it doesnt work. Here is a shortcut of my script

Код:
if (strcmp(cmd, "/change", true) ==0 )
	{
		if(IsPlayerConnected(playerid))

 		{
               new a, b;
				format(string, sizeof(string), "Users/%s.ini", name);
				new File: UserFile = fopen(string, io_write);
//				ClearChatbox(giveplayerid, 10);
			  new key[ 256 ] , val[ 256 ];
			  new Data[ 256 ];
			  while ( fread( UserFile , Data , sizeof( Data ) ) )
				{
					key = ini_GetKey( Data );
					if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); a = strval( val ); }
			  	if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); b = strval( val ); }
        fclose(UserFile);
				format(string, sizeof(string), "Users/%s.ini", name);
				new File: Ffile = fopen(string, io_write);
				if (Ffile)
				{
//  				strmid(PlayerInfo[giveplayerid][pKey], tmppass, 0, strlen(tmppass), 255);
			  	new var[32];);
					format(var, 32, "Level=%d\n",a);fwrite(Ffile, var);
					format(var, 32, "AdminLevel=%d\n",b);fwrite(Ffile, var);
					fclose(Ffile);
				}
			}
One of both dont work. Anything he didnt read or didnt write it sets everytime Level=0
Anything is wrong i hope anyone can help me