Showing latest reports
#1

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:
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(playeridDIALOG_NONEDIALOG_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(YearMonthDay);
        
gettime(hoursminutesseconds);
        
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(logstring);
       
fclose(log);
            }
            else
            {
            print(
"Failed to open file \"playerreports.txt\".");
            }
    return 
1;

Reply
#2

bump
Reply
#3

Use MySQL man
Reply
#4

bump
Reply
#5

bump
Reply
#6

https://sampwiki.blast.hk/wiki/Fread
Reply
#7

How much does it save ?

Sunny was faster :P
Reply
#8

I know about fread. I need to know how to send the data into a string or something.
It saves every report. Is it possible to show only 10-20 when there are much more?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)