Command Crash Server
#1

It crashes my server after I use /report command, idk why.. can u guys please point it out for me, what causes it??

The command :
PHP код:
CMD:report(playeridparams[])
{
    new 
string[144], targetidreason[MAX_PLAYERS], count 0;
    if(
GetPVarInt(playerid"TryToEscape") == 0) return SendClientMessage(playerid0xFF0000FF"You have to log in to use this command!");
    if(
sscanf(params"us[128]"targetidreason)) return SendClientMessage(playerid0xFF0000FF"Penggunaan: /report [playerid] [reason]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xFF0000FF"This player is not logged in!");
    if(
GetPVarInt(targetid"TryToEscape") == 0) return SendClientMessage(playerid, -1"This player is not logged in");
    if(
strlen(reason) < 6) return SendClientMessage(playerid, -1"Your report is too short"); //
    
format(stringsizeof(string), "%s have reported against %s reason: %s"IsPlayerName(playerid), IsPlayerName(targetid), reason);
    
SaveLogs("Reports"string);
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && GetPVarInt(i"TryToEscape") == && Account[i][Admin] > 0)
        {
            
count ++;
            
SendClientMessage(i0xFF0000FFstring);
            
PlayerPlaySound(playerid10570.00.00.0);
        }
    }
    
format(stringsizeof(string), "Your report is being processed by the system. Thanks for your report!"count);
    
SendClientMessage(playerid0xFF0000FFstring);
    
count 0;
    return 
1;

Reply
#2

Show us your SaveLogs function.
Reply
#3

Quote:
Originally Posted by X337
Посмотреть сообщение
Show us your SaveLogs function.
PHP код:
forward SaveLogs(filename[], text[]);
public 
SaveLogs(filename[], text[])
{
    new 
File:file,
        
line[256],
        
string[256];
    new 
yearmonthday;
    
getdate(yearmonthday);
    
format(linesizeof(line), "Logs/%s.txt"filename);
    
file fopen(lineio_append);
    
format(stringsizeof(string), "[%02d/%02d/%02d] %s\r\n"daymonthyeartext);
    
fwrite(filestring);
    
fclose(file);
    return 
1;

Reply
#4

make sure there is "Logs" folder inside scriptfiles.
Reply
#5

Add crashdetect to your server and give us the output when you use that command.
Reply
#6

If "Reports.txt" doesn't exist in server/scriptfiles/Logs then you got your answer.

Afaik an incorrect file handle can crash the server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)