SA-MP Forums Archive
Small file problem - 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: Small file problem (/showthread.php?tid=599403)



Small file problem - Squirrel - 25.01.2016

Alright so the problem is quite simple, when I restart the server, new logs are being created. Meaning that old file gets deleted and it starts creating a new one for some reason

This is the code

PHP код:
public TestLog(LogString[]) {
    new 
entry[128],YearMonthDayHourMinuteSecond;
    new 
File:SomeLogFilefopen("Logs/TestLog.log",io_append);
    
getdate(YearMonthDay);
    
gettime(HourMinuteSecond);
    
format(entrysizeof(entry), "\r\n[%02d/%02d/%d][%02d:%02d:%02d]%s",Day,Month,YearHourMinuteSecond,LogString);
    
fwrite(SomeLogFile,entry);
    
fclose(SomeLogFile);
    return 
true;




Re: Small file problem - K0P - 25.01.2016

This may solve your problem:
Код:
public TestLog(LogString[]) { 
    new entry[128],Year, Month, Day, Hour, Minute, Second; 
    new File:SomeLogFile= fopen("Logs/TestLog.log",io_append); 
    getdate(Year, Month, Day); 
    gettime(Hour, Minute, Second); 
    format(entry, sizeof(entry), "[%02d/%02d/%d][%02d:%02d:%02d]%s\n\r",Day,Month,Year, Hour, Minute, Second,LogString); 
    fwrite(SomeLogFile,entry); 
    fclose(SomeLogFile); 
    return true; 
}



Re: Small file problem - Squirrel - 25.01.2016

Nope that didnt help


Re: Small file problem - Sascha - 25.01.2016

that really is a weird problem...
Are you sure the file isn't created in some other part of the script? Or even exists when the server is starting and not being deleted when it shuts down for some reason?

The code snippet you posted seems to be correct, although I don't see a reason why this should create the file on a restart/start and not each time it is called...

So I'm pretty sure you have some "creating" part in your script on some other point...


Re: Small file problem - Squirrel - 25.01.2016

The thing is, it works great on my localhost, but like when I upload it to my host it starts doing that..
Could it be something thats problem with them or such?


Re: Small file problem - Vince - 25.01.2016

Linux OS' are case sensitive, so that might be one cause. Also check the file permissions. The server user should have full access to the scriptfiles directory and the file itself, so make sure that the directory and the file aren't owned by "root" or any other user.