adding a new line in a file?
#1

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;
		}
}
Reply
#2

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

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
Reply
#4

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

Thanks, i will try that (:
Reply
#6

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.
Reply
#7

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

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?
Reply
#9

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)