24.03.2017, 14:16
Hello Everyone.
I have an /report system that saves the report into a text file.
How can i make it show the latest 10-20 reports when typing /lastreports?
Can anybody explain to me/give me an example on this?
The Command:
I have an /report system that saves the report into a text file.
How can i make it show the latest 10-20 reports when typing /lastreports?
Can anybody explain to me/give me an example on this?
The Command:
PHP код:
CMD:report(playerid,params[])
{
new Target,reason[50],rstring[128],str[128];
if(IsJailedOrMuted(playerid))return 1;
if(sscanf(params,"us[50]",Target,reason))return SendClientMessage(playerid,GREY,"USAGE: /report [playerid] [reason]");
if(gettime() - Temp[playerid] < 5) return ShowPlayerDialog(playerid, DIALOG_NONE, DIALOG_STYLE_MSGBOX, "Anti Spam", "Please wait before doing this again", "OK", "");
if(Target==playerid) return SendClientMessage(playerid,GREY,"You cannot report yourself");
if(!IsPlayerConnectedEx(Target)) return SendClientMessage(playerid,GREY,"Invalid player ID");
if(strlen(reason) > 50) return SendClientMessage(playerid,GREY,"Reason can't be longer than 50 characters");
format(rstring,sizeof(rstring),"SERVER: {FFFFFF}%s reported %s(Reason: %s)",PlayerName(playerid),PlayerName(Target),reason);
SendMessageToAdmins(RED,rstring);
format(str,sizeof(str),"use /acceptreport %i to accept the report",playerid);
SendMessageToAdmins(COLOR_WHITE,str);
SendClientMessage(playerid,YELLOW,"Your report has been sucessfully sent to the online admins");
Temp[playerid] = gettime();
PlayerInfo[playerid][Reporting2] = 1;
new File:log = fopen("Logs/playerreports.txt", io_append);
if(log)
{
getdate(Year, Month, Day);
gettime(hours, minutes, seconds);
format(string,sizeof(string),"[%d/%d/%d][%d:%d:%d]%s SERVER: {FFFFFF}%s reported %s(Reason: %s)'\n\n",Day,Month,Year,hours,minutes,seconds,PlayerName(playerid),PlayerName(Target),reason);
fwrite(log, string);
fclose(log);
}
else
{
print("Failed to open file \"playerreports.txt\".");
}
return 1;
}