Report ID -
JaKe Elite - 19.08.2014
Hello SA-MP Team, Today i am building a report system which bases on ReportID, then the player waits till an Admin handles the ReportID, now below is the code of my report system, it works well as i expected. However, there are some few issues in this report system, The ReportID is bugged, Once the ReportID 0 is used, And the report was closed/trashed/cancelled, The ReportID 0 is not usable anymore, it will proceed to next digit id, till it reaches the Max Report, Mind helping me out guys?
pawn Код:
stock ResetReport(reportid)
{
ReportInfo[reportid][rid] = 0;
ReportInfo[reportid][repid] = INVALID_PLAYER_ID;
ReportInfo[reportid][repedid] = INVALID_PLAYER_ID;
ReportInfo[reportid][reporthr] = 0;
ReportInfo[reportid][reportsec] = 0;
ReportInfo[reportid][reportmin] = 0;
format(ReportInfo[reportid][reporter], 24, "None");
format(ReportInfo[reportid][reported], 24, "None");
format(ReportInfo[reportid][reporttext], 128, "Invalid");
ReportInfo[reportid][handled] = 0;
format(ReportInfo[reportid][handler], 24, "None");
ReportInfo[reportid][used] = 0;
ReportInfo[reportid][handleid] = INVALID_PLAYER_ID;
return 1;
}
stock SendReport(rids, playerid, reportid, reason[])
{
new string[190];
ReportInfo[rids][rid] = rids;
format(ReportInfo[rids][reporter], 24, "%s", GetName(playerid));
format(ReportInfo[rids][reported], 24, "%s", GetName(reportid));
format(ReportInfo[rids][reporttext], 128, "%s", reason);
gettime(ReportInfo[rids][reporthr], ReportInfo[rids][reportmin], ReportInfo[rids][reportsec]);
ReportInfo[rids][handled] = 0;
format(ReportInfo[rids][handler], 24, "None");
ReportInfo[rids][used] = 1;
ReportInfo[rids][repid] = playerid;
ReportInfo[rids][repedid] = reportid;
format(string, sizeof(string), "** [RID %d] "lightblue"%s(%d) has just reported %s(%d) for "red"%s", rids, GetName(playerid), playerid, GetName(reportid), reportid, reason);
SendAdmin(-1, string);
SendAdmin(-1, "** To handle the report, Simply /handlereport, otherwise ignore it, to trash it, /trashreport.");
format(string, sizeof(string), "** You reported "blue"%s "white"for "red"%s "white"<%d:%02d:%02d>", GetName(reportid), reason, ReportInfo[rids][reporthr], ReportInfo[rids][reportmin], ReportInfo[rids][reportsec]);
SendClientMessage(playerid, -1, string);
SendClientMessage(playerid, COLOR_GREEN, "Your report has been sent to online admins, Wait for an admin to response to your report.");
Sent_Report[playerid] = 1;
return 1;
}
stock HandleReport(reportid, playerid)
{
if(ReportInfo[reportid][used] == 0)
{
SendClientMessage(playerid, COLOR_RED, "Report ID doesn't exist!");
return 1;
}
if(ReportInfo[reportid][handled] == 1)
{
SendClientMessage(playerid, COLOR_RED, "Report is being handled by another Admin already!");
return 1;
}
new id = ReportInfo[reportid][repid];
new string[190];
format(string, sizeof(string), "** "green"Admin %s has handled your report, Wait for the admin to reply regarding to your report.", GetName(playerid));
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You handled "green"%s's "white"report (/rtp to reply to the player)", GetName(id));
SendClientMessage(playerid, -1, string);
SendClientMessage(playerid, -1, "If you think it's time to close the report, Simply /closereport.");
handling_R[playerid] = 1;
handling_ID[playerid] = reportid;
ReportInfo[reportid][handleid] = playerid;
ReportInfo[reportid][handled] = 1;
format(ReportInfo[reportid][handler], 24, "%s", GetName(playerid));
return 1;
}
stock CloseReport(reportid, playerid)
{
if(handling_R[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "You do not handle any reports at the moment.");
return 1;
}
new id = ReportInfo[reportid][repid];
new string[190];
format(string, sizeof(string), "** "red"Admin %s has closed your report, The report has been solved or disregard, Contact the admin for more info.", GetName(playerid));
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You closed "green"%s's "white"report.", GetName(id));
SendClientMessage(playerid, -1, string);
handling_R[playerid] = 0;
handling_ID[playerid] = -1;
ResetReport(reportid);
return 1;
}
stock TrashReport(reportid, playerid)
{
if(ReportInfo[reportid][used] == 0)
{
SendClientMessage(playerid, COLOR_RED, "Report ID doesn't exist!");
return 1;
}
if(ReportInfo[reportid][handled] == 1)
{
SendClientMessage(playerid, COLOR_RED, "Report is being handled by another Admin already!");
return 1;
}
new id = ReportInfo[reportid][repid];
new string[190];
format(string, sizeof(string), "** "red"Admin %s has trashed your report for some reasons, Contact the admin for more info regarding to it.", GetName(playerid));
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You trashed "green"%s's "white"report.", GetName(id));
SendClientMessage(playerid, -1, string);
ResetReport(reportid);
return 1;
}
Re: Report ID -
Threshold - 19.08.2014
The problem would be with the value that you are using in
SendReport. So can you show us where you're using that function?
Re: Report ID -
JaKe Elite - 19.08.2014
I am using the values and the strings for the HandleReport, CloseReport and TrashReport (including ResetReport)
Re: Report ID -
Threshold - 19.08.2014
pawn Код:
SendReport(rids, playerid, reportid, reason[])
The value of 'rids' is most likely your issue.
Re: Report ID -
JaKe Elite - 20.08.2014
Possibly,
Mind telling me how to fix the issue, what am i trying to do here is:
• Assign the report in a ID.
• If the report ID is cancelled / trashed, it will be filled with the next /report.
Re: Report ID -
Threshold - 20.08.2014
That's what I am trying to ask you for...
I need to see where you're actually using 'SendReport' in order for an actual report to be saved.
Re: Report ID -
JaKe Elite - 20.08.2014
Ahh i found it.
pawn Код:
CMD:report(playerid, params[])
{
new id, reason[128];
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /report <playerid> <report>");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player not connected.");
SendReport(reportCount, playerid, id, reason);
reportCount++;
return 1;
}
I am using that vaue 'rids' for the global variable i made, the var "ReportCount"
Re: Report ID -
Threshold - 20.08.2014
Exactly. So when you handle a report, 'reportCount' does not decrease. Although simply adding 'reportCount--;' to your HandleReport function won't fix this either. What you need to do is this:
pawn Код:
CMD:report(playerid, params[])
{
new id, reason[128];
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /report <playerid> <report>");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player not connected.");
for(new i = 0; i < MAX_REPORTS; i++) //Replace 'MAX_REPORTS' with the maximum number of reports you will allow
{
if(ReportInfo[i][rid]) continue;
SendReport(i, playerid, id, reason);
break;
}
//reportCount++;
return 1;
}
This finds the next available report id. (One that is not being used)
Simply just by checking whether the 'rid' variable is greater than 0 or not.
Re: Report ID -
JaKe Elite - 20.08.2014
Alright i think it works, however now the /reports won't work properly, only the latest reportid was shown in /reports.
pawn Код:
CMD:reports(playerid, params[])
{
new existingReports=0;
if(pInfo[playerid][Admin] >= 1)
{
new string[190];
for(new i=0; i<MAX_REPORTS; i++)
{
if(ReportInfo[i][used] == 1)
{
existingReports++;
if(ReportInfo[i][handled] == 0)
{
format(string, sizeof(string), "<%d:%02d:%02d> %s reported %s for %s <RID %d>", ReportInfo[i][reporthr], ReportInfo[i][reportmin], ReportInfo[i][reportsec], ReportInfo[i][reporter], ReportInfo[i][reported], ReportInfo[i][reporttext], i);
SendClientMessage(playerid, -1, string);
}
else
{
format(string, sizeof(string), "<%d:%02d:%02d> %s reported %s for %s <RID %d>", ReportInfo[i][reporthr], ReportInfo[i][reportmin], ReportInfo[i][reportsec], ReportInfo[i][reporter], ReportInfo[i][reported], ReportInfo[i][reporttext], i);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "Handled by: %s", ReportInfo[i][handler]);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
}
if(existingReports==0) return SendClientMessage(playerid, -1, "No reports at the moment.");
}
else
{
SendClientMessage(playerid, COLOR_RED, "** This command is admin restricted only!");
}
return 1;
}
Re: Report ID -
JaKe Elite - 20.08.2014
Alright the code you given to me didn't work.