SA-MP Forums Archive
adding a new line in 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: adding a new line in a file? (/showthread.php?tid=141831)



adding a new line in a file? - Naxix - 15.04.2010

Hi, i have made a /report cmd which save the name and the report of the player, but when you use it, it works fine, but if you use it again it just replaces the first line?

So how can you make it add a new line each time?

code:
Код:
dcmd_report(playerid,params[])
{
	new rep[128],name[MAX_PLAYER_NAME],string[128];
	if(sscanf(params,"s",rep)) return SendClientMessage(playerid,COLOUR_RED,"Usage: /report [Bug Report]");
	else
	{
		new File:openfile = fopen("BugReports.ini",io_write);
	  GetPlayerName(playerid,name,sizeof(name));
		format(string,sizeof(string),"%s - %s \n",name,rep);
		fwrite(openfile,string);
		fclose(openfile);
		SendClientMessage(playerid,COLOUR_GREEN,"Bug report has been sent!");
		return 1;
		}
}



Re: dini new line? - Torran - 15.04.2010

This dosent answer your thing but why do you have dini in your topic name when your not even using it


Re: dini new line? - Naxix - 15.04.2010

Quote:
Originally Posted by Joe Torran C
This dosent answer your thing but why do you have dini in your topic name when your not even using it
lol, your right xD I'm just started using dini, so i guess i just wrote it lol. Fixed



Re: adding a new line in a file? - Thrarod - 15.04.2010

Add \r\n to end of the string each time if a line comes after it


Re: adding a new line in a file? - Naxix - 15.04.2010

Thanks, i will try that (:


Re: adding a new line in a file? - Naxix - 15.04.2010

Quote:
Originally Posted by Thrarod
Add \r\n to end of the string each time if a line comes after it
Umm

Код:
format(string,sizeof(string),"%s - %s\r\n",name,rep);
Does not work, it still just overwrite the first line.


Re: adding a new line in a file? - Thrarod - 15.04.2010

Hmm lemme see... It must work? https://sampwiki.blast.hk/wiki/Fwrite ??


Re: adding a new line in a file? - Naxix - 15.04.2010

Quote:
Originally Posted by Thrarod
Hmm lemme see... It must work? https://sampwiki.blast.hk/wiki/Fwrite ??
Hmm.. It looks like it actully add a new line, but it just overwrite the first line, but the new line is there just empty?


Re: adding a new line in a file? - Thrarod - 15.04.2010

Код:
format(string,sizeof(string),"\r\n%s - %s",name,rep);



Re: adding a new line in a file? - Naxix - 15.04.2010

Quote:
Originally Posted by Thrarod
Код:
format(string,sizeof(string),"\r\n%s - %s",name,rep);
Thanks, but now it's just the first line empty, and the next line have text but gets overwritten lol