Help with file writing
#1

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

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);
Reply
#3

But the text is already getting reformatted in the AdminLog() function right? So, I don't see what difference it could possibly make.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)