SA-MP Forums Archive
[HELP] Confused with making a report system - 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: [HELP] Confused with making a report system (/showthread.php?tid=619772)



[HELP] Confused with making a report system - StrikerZ - 22.10.2016

Hi there. I've done making /report system. But i'm confused like hell on how should i save the reports using their report numbers. So that i can use /reports and see the all pending reports with their ids and can use /closerep [report id] to close them. But i dunno how would i save the /report string


Re: [HELP] Confused with making a report system - IceBilizard - 22.10.2016

take this as example

Put this somewhere in your script
PHP Code:
fdeleteline(filename[], line)
{
  new 
countstring[256], File:fileFile:temp;
  
filefopen(filenameio_read);
  
temp fopen("tmpfile.tmp"io_write);
  while (
fread(filestring))
    if (++
count != line)
      
fwrite(tempstring);
  
fclose(file);
  
fclose(temp);
  
filefopen(filenameio_write);
  
temp fopen("tmpfile.tmp"io_read);
  while (
fread(tempstring))
    
fwrite(filestring);
  
fclose(file);
  
fclose(temp);
  
fremove("tmpfile.tmp");

Then for read reports
PHP Code:
CMD:reports(playeridparams[])
{
    if (!
IsPlayerAdmin(playerid)) return 0;
    new 
strings[128], Filefile fopen("Asystem/Reports.ini"io_read), idxx=1;//You can change your folder destination
    
SendClientMessage(playeridCOLOR_ORANGE"[Reports]:");
    while(
fread(filestrings))
    {
        
format(stringssizeof(strings), "%d) %s"idxxstrings);
        
SendClientMessage(playeridCOLOR_ORANGEstrings);
        
idxx ++;
    }
    
fclose(file);
    return 
1;

Then Delete a report
PHP Code:
CMD:deletereport(playeridparams[])
{
    new 
line;
    new 
ppname[MAX_PLAYER_NAME];
    if (!
IsPlayerAdmin(playerid)) return 0;
    if(
sscanf(params"d"line)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /deletereport [reportid]");
    
SendClientMessage(playeridCOLOR_YELLOW"Report deleted.");
    if(
line 1) return SendClientMessage(playeridCOLOR_RED"Invalid report id.");
    
fdeleteline("Asystem/Reports.ini"line);//You can change your folder destination
    
return 1;




Re: [HELP] Confused with making a report system - StrikerZ - 22.10.2016

But how can i save the string by leaving a line FOR EX-
1. [report #1]
2. [report #2]

Right now its showing like this
1. [report #1] [report #2]
Code:
CMD:report(playerid, params[])
{
	new reason[24],string[120],id,reportid=0,File: file = fopen("Reports/Reports.ini", io_append);
	if(sscanf(params,"us[24]",id,reason)) return SCM(playerid,COLOR_ORANGE,"USAGE: /report [playerid] [reason]");
	format(string,sizeof(string),"[REPORT #%d] %s[%d] has reported %s[%d]. Reason: (%s).",reportid+1,PN(playerid),playerid,PN(id),id,reason);
	MSGADMIN(COLOR_GREEN,string);
	SCM(playerid,COLOR_GREEN,"   Your report has been sent to admins.");
	fwrite(file,string);
	fclose(file);
	return 1;
}



Re: [HELP] Confused with making a report system - X337 - 22.10.2016

Code:
CMD:report(playerid, params[])
{
	new reason[24],string[120],id,reportid=0,File: file = fopen("Reports/Reports.ini", io_append);
	if(sscanf(params,"us[24]",id,reason)) return SCM(playerid,COLOR_ORANGE,"USAGE: /report [playerid] [reason]");
	format(string,sizeof(string),"[REPORT #%d] %s[%d] has reported %s[%d]. Reason: (%s).\r\n",reportid+1,PN(playerid),playerid,PN(id),id,reason);
	MSGADMIN(COLOR_GREEN,string);
	SCM(playerid,COLOR_GREEN,"   Your report has been sent to admins.");
	fwrite(file,string);
	fclose(file);
	return 1;
}
Use \n for new line


Re: [HELP] Confused with making a report system - StrikerZ - 22.10.2016

Thanks! After testing it the [Report #%d] the %d remains 1 it won't increase by 1. What's the problem?


Re: [HELP] Confused with making a report system - lackmail - 22.10.2016

because new reportid created and set to 0 everytime player use /report do this:

change this line:
Code:
	new reason[24],string[120],id,reportid=0,File: file = fopen("Reports/Reports.ini", io_append);
to thisremoved reportid=0)
Code:
	new reason[24],string[120],id,File: file = fopen("Reports/Reports.ini", io_append);
then put this in top of your script:
Code:
new reportid=0;



Re: [HELP] Confused with making a report system - StrikerZ - 22.10.2016

Pls halp its not working


Re: [HELP] Confused with making a report system - Sew_Sumi - 22.10.2016

Quote:
Originally Posted by Sunehildeep
View Post
Pls halp its not working
ProTip: Don't listen to people who have been signed up for less than a month, and simply throw out random lines to paste in when the initial code came from someone more rep-worthy.

I'd just wait for IceBlizzard... They've got the plan.


Re: [HELP] Confused with making a report system - IceBilizard - 22.10.2016

try this
PHP Code:
CMD:report(playeridparams[])
{
    new 
reason[24],string[120],id,reportid=0;
    if(
sscanf(params,"us[24]",id,reason)) return SCM(playerid,COLOR_ORANGE,"USAGE: /report [playerid] [reason]");
    
format(string,sizeof(string),"[REPORT #%d] %s[%d] has reported %s[%d]. Reason: (%s).\r\n",reportid+1,PN(playerid),playerid,PN(id),id,reason);
    
MSGADMIN(COLOR_GREEN,string);
    
SCM(playerid,COLOR_GREEN,"   Your report has been sent to admins.");
    new 
Filefile fopen("Reports/Reports.ini"io_append);
    
fwrite(filestring);
    
fclose(file);
    return 
1;




Re: [HELP] Confused with making a report system - StrikerZ - 22.10.2016

Quote:
Originally Posted by IceBilizard
View Post
try this
PHP Code:
CMD:report(playeridparams[])
{
    new 
reason[24],string[120],id,reportid=0;
    if(
sscanf(params,"us[24]",id,reason)) return SCM(playerid,COLOR_ORANGE,"USAGE: /report [playerid] [reason]");
    
format(string,sizeof(string),"[REPORT #%d] %s[%d] has reported %s[%d]. Reason: (%s).\r\n",reportid+1,PN(playerid),playerid,PN(id),id,reason);
    
MSGADMIN(COLOR_GREEN,string);
    
SCM(playerid,COLOR_GREEN,"   Your report has been sent to admins.");
    new 
Filefile fopen("Reports/Reports.ini"io_append);
    
fwrite(filestring);
    
fclose(file);
    return 
1;

Still displaying 1 at each report