19.08.2014, 13:13
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;
}