SA-MP Forums Archive
file.inc glitched? - 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: file.inc glitched? (/showthread.php?tid=239061)



file.inc glitched? - sciman001 - 12.03.2011

I made this simple script for my server. CODE:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new File:chatlog = fopen("/logs/chatlog.txt",io_append),chat[128],chater[128],hour,minute,second;
    GetPlayerName(playerid,chater,sizeof(chater));
    gettime(hour,minute,second);
    format(chat,sizeof(chat),"[%d:%d:%d]: ( %s ): %s\n",hour,minute,second,chater,text);
    if(chatlog)
    {
        if(fexist("chatlog.txt"))
        {
            fwrite(chatlog,chat);
            fclose(chatlog);
        }
    }
    return 1;
}
It creates the file and stuff. It just wont write to the file. What do


Re: file.inc glitched? - HyperZ - 12.03.2011

OnPlayerText:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new chater[MAX_PLAYER_NAME];
    GetPlayerName(playerid, chater, sizeof(chater));
    new chat[128], second, minute, hour;
    gettime(hour,minute,second);
    format(chat, sizeof(chat), "\n[%d:%d:%d] ( %s ) : %s", hour, minute, second, chater, text);
    ChatLog(chat);
    return 1;
}
Somewhere in your script:
pawn Код:
forward ChatLog(string[]);
public ChatLog(string[])
{
    new entry[128];
    format(entry, sizeof(entry), "%s",string);
    new File:hFile;
    hFile = fopen("Chat.txt", io_append);
    fwrite(hFile, entry);
    fwrite(hFile, "\n");
    fclose(hFile);
}



Re: file.inc glitched? - sciman001 - 12.03.2011

THANKS!!!!!


Re: file.inc glitched? - sciman001 - 12.03.2011

it doesnt make a new line? how fix


Respuesta: file.inc glitched? - Code8976Man - 12.03.2011

Yes, New Line exists, its [] symbol. Try to open it with pawno.


Re: file.inc glitched? - [L3th4l] - 12.03.2011

pawn Код:
format(entry, sizeof(entry), "%s\r\n",string);



Re: file.inc glitched? - Joe Staff - 12.03.2011

When pawno compiles, it use a chharacte for line breaks that notepad doesn't use. Issue is, if you open with wordpad, it over writes the pawno line breaks with wordpad line breaks. That will cause issues with loading the file


Re: file.inc glitched? - sciman001 - 12.03.2011

it wont work...


Re: file.inc glitched? - Scrip - 12.03.2011

pawn Код:
forward CmdLog(string[]);
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new y5, m5, d5;
    new h5,mi5,s5;
    getdate(y5,m5,d5);
    gettime(h5,mi5,s5);
    format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> %s",d5,m5,y5,h5,mi5,s5,sendername,cmdtext);
    CmdLog(string);
}

pawn Код:
public CmdLog(string[])
{
    new entry[256];
    format(entry, sizeof(entry), "%s\n",string);
    new File:hFile;
    hFile = fopen("logs/cmd.log", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}



Re: file.inc glitched? - sciman001 - 12.03.2011

the \n doesnt make he line go down... wat do?