Function crash the server.
#9

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
You must set the permissions to 777, so it will manage to write into the file

There is an option to filezilla with right click, you will find it then set it to 777
Local server.

Quote:
Originally Posted by jlalt
Посмотреть сообщение
It's crashing on fwrite so maybe the file doesn't exist try this...

PHP код:
WriteLogs(const playername[], file[30], const author[], const reason[], const other[])
{
    static 
daymonthhourminutesecondeyearstringW[190];
    if(
strfind(file".log"false0) == -1format(filesizeof(file), "%s.log"file);
    
format(filesizeof(file), "/Logs/%s"file);
    if(!
fexist(file)) {
       new 
File:pos=fopen(fileio_write);
       
fclose(pos);
    }
    new 
File:pos=fopen(fileio_append);
    
gettime(hourminuteseconde);
    
getdate(yearmonthday);
    
format(stringW,sizeof(stringW),"\r\n[%02i/%02i/%02i] %02i:%02i:%02i | %s %s %s : %s"daymonthyearhourminutesecondeauthorreasonplayernameother);
    
fwrite(pos,stringW);
    
fclose(pos);

Now it's crashing on fclose. Put a print before fclose.
PHP код:
[18:09:04fclose inc.
[
18:09:04] [debugServer crashed while executing dmsystem.amx
[18:09:04] [debugAMX backtrace:
[
18:09:04] [debug#0 native fclose () from samp-server.exe
[18:09:04] [debug#1 00029d1c in ?? (17393428, 17393828, 17393884, 17393912, 17413044) from dmsystem.amx
[18:09:04] [debug#2 0002944c in ?? (0, 17413044) from dmsystem.amx
[18:09:04] [debug#3 00022d80 in public cmd_resetsetdata (0, 17397024) from dmsystem.amx
[18:09:04] [debug#4 native CallLocalFunction () from samp-server.exe
[18:09:04] [debug#5 00000664 in public OnPlayerCommandText (0, 17396960) from dmsystem.amx
[18:09:04] [debugNative backtrace:
[
18:09:04] [debug#0 0049939b in ?? () from samp-server.exe
[18:09:04] [debug#1 004056cd in ?? () from samp-server.exe
[18:09:04] [debug#2 637b62ca in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#3 637b8b28 in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#4 637b09c7 in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#5 637b631a in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#6 004746be in ?? () from samp-server.exe
[18:09:04] [debug#7 004010b6 in ?? () from samp-server.exe
[18:09:04] [debug#8 637b62ca in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#9 637b8b28 in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#10 637b09c7 in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#11 637b631a in ?? () from plugins\crashdetect.dll
[18:09:04] [debug#12 0046b168 in ?? () from samp-server.exe 
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Код:
new File:pos=fopen(file, io_append);
if the value of "pos" variable is 0 and is used in fwrite will crash the server. To prevent it:
pawn Код:
new File:pos=fopen(file, io_append);
if (!pos) return;
but since it won't open the file, it won't write either. You may as well add return values like if pos is 0, return 0 otherwise 1 and if you do:
pawn Код:
if (!WriteLogs(...)) ...
you can print in the console that it failed to open the file etc.
Alright, I'll try it soon.

Thanks all for your help.
Reply


Messages In This Thread
Function crash the server. - by Dayrion - 21.06.2016, 15:44
Re: Function crash the server. - by ATGOggy - 21.06.2016, 15:47
Re: Function crash the server. - by Dayrion - 21.06.2016, 15:49
Re: Function crash the server. - by Konstantinos - 21.06.2016, 15:51
Re: Function crash the server. - by Dayrion - 21.06.2016, 16:00
Re: Function crash the server. - by jlalt - 21.06.2016, 16:04
Re: Function crash the server. - by Konstantinos - 21.06.2016, 16:08
Re: Function crash the server. - by SecretBoss - 21.06.2016, 16:12
Re: Function crash the server. - by Dayrion - 21.06.2016, 16:33
Re: Function crash the server. - by Dayrion - 21.06.2016, 17:25

Forum Jump:


Users browsing this thread: 2 Guest(s)