Read and Write
#1

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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)