File lines are overwriting
#1

So, I am making this log but it only writes on the first line, its overwriting the previous line over and over again, what is wrong?

pawn Код:
forward writecmdlog(text[]);
stock writecmdlog(text[])
{
   new File:cmdlog = fopen("realityrp/logs/commands.txt", io_write);
   fwrite(cmdlog, text);
   fwrite(cmdlog, "\r\n");
   fclose(cmdlog);
   return 1;
}
Reply
#2

I had this problem before too... I fixed it with using a timer wich DOESNT repeat :P
Reply
#3

Quote:
Originally Posted by milanosie
Посмотреть сообщение
So, I am making this log but it only writes on the first line, its overwriting the previous line over and over again, what is wrong?

pawn Код:
forward writecmdlog(text[]);
stock writecmdlog(text[])
{
   new File:cmdlog = fopen("realityrp/logs/commands.txt", io_write);
   fwrite(cmdlog, text);
   fwrite(cmdlog, "\r\n");
   fclose(cmdlog);
   return 1;
}
Try changing 'io_write' to 'io_append'
Reply
#4

Use io_append instead of io_write.
Reply
#5

Thanks, im completly new to Fwrite etc, always used ini stuff
Reply
#6

This happend to me using Mysql so doesnt matter what system i guess
Reply
#7

For safety..

pawn Код:
forward writecmdlog(text[]);
stock writecmdlog(text[])
{
    new File:LOG;
   
    if(!fexist("realityrp/logs/commands.txt"))
    LOG = fopen("realityrp/logs/commands.txt", io_write);
   
    else
    LOG = fopen("realityrp/logs/commands.txt", io_append);
   
    fwrite(LOG, text);
    fwrite(LOG, "\r\n");
    fclose(LOG);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)