Help with file writing - 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)
+--- Thread: Help with file writing (
/showthread.php?tid=385716)
Help with file writing -
Bullfr0g - 17.10.2012
Okay, take a look at the following codes:
pawn Код:
CMD:something(playerid,params[]) //ignore what the cmd is...
{
//~~~~~~~~~~
new Day,Month,Year,Hour,Minute,Second,text[250];
gettime(Hour,Minute,Second); getdate(Year, Month, Day);
format(text,sizeof(text)," || %d/%d/%d - %d:%d:%d || [Admin Log]: %s has done something...
",Day,Month,Year,Day,Month,Year,Hour,Minute,Second,name);
AdminLog(text);
//~~~~~~
forward AdminLog(string[]);
public AdminLog(string[])
{
new entry[500];
format(entry, sizeof(entry), "%s\r\n",string);
new File:hFile;
hFile = fopen("/Logs/Admin.txt", io_append);
fwrite(hFile, entry);
fwrite(hFile," \n ");
fclose(hFile);
}
Okay, as you can see, all it does is write the logs to a file Admin.txt
Its supposed to enter line by line in the file, but when I open the file, everything's in a mixed up state.
This is how it looks like:
It's hard to read and understand anything. (But when I turn off word wrap, everything comes in a straight line)
Also notice that the player name doesn't show up properly in the line at the end, a 'Ь' comes in front of the name.
Please do help.
Re: Help with file writing -
TzAkS. - 17.10.2012
Try it like this..maybe will work
Код:
format(text,sizeof(text)," || %d/%d/%d - %d:%d:%d || [Admin Log]: %s has done something...\n
",Day,Month,Year,Day,Month,Year,Hour,Minute,Second,name);
Re: Help with file writing -
Bullfr0g - 17.10.2012
But the text is already getting reformatted in the AdminLog() function right? So, I don't see what difference it could possibly make.