File Read Problem
#1

Hi ! I made one script which when one leader invites one member in his faction, it saves automatically the name of the invited member into a file . When one leader types /wipe , the server should read that file and it should edit the user's file . But it reads one space at the end of the name, because of \n . Thus that space must be deleted . Do you know how to read the member's name without that extra space ? Thank you !
Reply
#2

pawn Код:
static len;
while((len = fread(file,string)))
{
    if(string[ len - 1 ] == '\n')
        string[ len - 1] = EOS;
}
Reply
#3

When I use /wipe , the server restarts , look the code:

Код:
new File:hFile = fopen(string2, io_read);
			if(hFile)
			{
			        static len;
				    while((len = fread(hFile, Data, sizeof(Data))))
					{
					    if(strcmp(Data, PlayerName(playerid), true))
					    {
					        if(Data[ len - 1 ] == '\n')
									Data[ len - 1] = EOS;
					    
							new var[64];
							format(string, strlen(Data) - 1, "users/%s.ini", Data);
							SendClientMessage(playerid, COLOR_WHITE, string);
		       				new File:file = fopen(string, io_append);
		       				if(file)
		       				{
								SendClientMessage(playerid, COLOR_WHITE, "Test 1");
								format(var, sizeof(var), "Member=0\n"); fwrite(file, var);
								format(var, sizeof(var), "Team=3\n"); fwrite(file, var);
								format(var, sizeof(var), "Rank=0\n"); fwrite(file, var);
							 	format(var, sizeof(var), "FacWarns=0\n"); fwrite(file, var);
								format(var, sizeof(var), "Char=0\n"); fwrite(file, var);
							}
							
							fclose(file);
						}
					}
			}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)