Command Crash Server - 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: Command Crash Server (
/showthread.php?tid=652347)
Command Crash Server -
AfiqIqbal - 08.04.2018
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(playerid, params[])
{
new string[144], targetid, reason[MAX_PLAYERS], count = 0;
if(GetPVarInt(playerid, "TryToEscape") == 0) return SendClientMessage(playerid, 0xFF0000FF, "You have to log in to use this command!");
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, 0xFF0000FF, "Penggunaan: /report [playerid] [reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000FF, "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(string, sizeof(string), "%s have reported against %s reason: %s", IsPlayerName(playerid), IsPlayerName(targetid), reason);
SaveLogs("Reports", string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetPVarInt(i, "TryToEscape") == 1 && Account[i][Admin] > 0)
{
count ++;
SendClientMessage(i, 0xFF0000FF, string);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
}
}
format(string, sizeof(string), "Your report is being processed by the system. Thanks for your report!", count);
SendClientMessage(playerid, 0xFF0000FF, string);
count = 0;
return 1;
}
Re: Command Crash Server -
X337 - 08.04.2018
Show us your SaveLogs function.
Re: Command Crash Server -
AfiqIqbal - 08.04.2018
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 year, month, day;
getdate(year, month, day);
format(line, sizeof(line), "Logs/%s.txt", filename);
file = fopen(line, io_append);
format(string, sizeof(string), "[%02d/%02d/%02d] %s\r\n", day, month, year, text);
fwrite(file, string);
fclose(file);
return 1;
}
Re: Command Crash Server -
X337 - 08.04.2018
make sure there is "Logs" folder inside scriptfiles.
Re: Command Crash Server -
zookyy - 08.04.2018
Add crashdetect to your server and give us the output when you use that command.
Re: Command Crash Server -
RogueDrifter - 09.04.2018
If "Reports.txt" doesn't exist in server/scriptfiles/Logs then you got your answer.
Afaik an incorrect file handle can crash the server.