@ Sithis, I have this now:
PHP код:
CMD:reports(playerid,params[])
{
new str[1024], string2[1024], string[1024], szQuery[128], status[25], reportid[25];
if(AdminLevel[playerid] >=2)
{
for(new i = MAX_REPORTS; i > 0; i --)
{
new reportstatus[5];
new DBResult:REPORTS_RESULT_FINAL;
format(szQuery, sizeof(szQuery), "SELECT * FROM `REPORTS` WHERE `ID` = '%d'", i);
REPORTS_RESULT_FINAL = db_query(LARP_DATABASE, szQuery);
db_get_field_assoc(REPORTS_RESULT_FINAL, "ID", reportid, sizeof(reportid));
ReportInfo[i][ReportID] = strval(reportid);
db_get_field_assoc(REPORTS_RESULT_FINAL, "Status", reportstatus, sizeof(reportstatus));
db_get_field_assoc(REPORTS_RESULT_FINAL, "PlayerName", ReportInfo[i][ReportedName], 124);
db_get_field_assoc(REPORTS_RESULT_FINAL, "Reported", ReportInfo[i][ReportedBy], 124);
db_get_field_assoc(REPORTS_RESULT_FINAL, "Report", ReportInfo[i][ReportedReason], 124);
db_get_field_assoc(REPORTS_RESULT_FINAL, "Date", ReportInfo[i][ReportedDate], 124);
if(ReportInfo[i][ReportID] != 0)
{
ReportInfo[i][ReportStatus] = strval(reportstatus);
if(ReportInfo[i][ReportStatus] == 0) {status="{FF8000}Pending";}
if(ReportInfo[i][ReportStatus] == 1) {status="{00CC00}Open";}
format(str,sizeof(str),"%d\t%q\t%q\t%q\n", ReportInfo[i][ReportID], ReportInfo[i][ReportedName], ReportInfo[i][ReportedReason],status);
strcat(string2,str);
}
db_free_result(REPORTS_RESULT_FINAL);
}
format(str,sizeof(str),"Report ID\tReported Name\tReason\tStatus\n%s", string2);
strcat(string,str);
ShowPlayerDialog(playerid, DIALOG_PENDINGREPORTS+1, DIALOG_STYLE_TABLIST_HEADERS, "Pending Reports", string, "Select", "Back");
}
return 1;
}
Could it be done any better/ more efficient?
This is my table for reports:
Код:
CREATE TABLE `REPORTS` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT, `Status` INTEGER NOT NULL, `PlayerName` TEXT NOT NULL, `Reporter` TEXT NOT NULL, `Report` TEXT NOT NULL, `Date` TEXT NOT NULL, 'Admin' TEXT NOT NULL DEFAULT 'None', 'Solution' TEXT NOT NULL DEFAULT 'None', 'DateClosed' TEXT NOT NULL DEFAULT 'NA')