[FilterScript] [MySQL R41-4] Dynamic Report System
#5

You made a few holes through the code, but it overlooks, it\'s pretty .. ok, but there are some mistakes here and it could be done better.

For example, why use a 200-character value for a simple reason? Maybe 32 characters were enough.

Code:
new targetid, reason[200], query[300];
    if(sscanf(params, "ds[200]", targetid, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[USAGE]: {FFFFFF}/report [targetid] [reason]");
Maybe this:

Code:
new targetid, reason[32], query[300];
    if(sscanf(params, "ds[32]", targetid, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[USAGE]: {FFFFFF}/report [targetid] [reason]");
And don\'t use "cache method"
Use mysql_tquery, it\'s much better.

Something like that:

Code:
CMD:reports(playerid, params[])
{
    new query[300];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}You are not authorized to use that command.");
    mysql_tquery(Database, query, "showReports", "SELECT * FROM `reports` ORDER BY `Date` LIMIT 15;", "i"); 
    return 1;
}

forward showReports(playerid);
public showReports(playerid) 
{

    if(cache_num_rows())
    {
        new string[2300], rinfo[1000], Reporter[24], Reported[24], Reason[200], Date[30], reportid, Accepted;
        strcat(string, "Displaying 15 latest reports:

");
        for(new i = 0; i < cache_num_rows(); i++)
        {
            cache_get_value_name(i, "Reporter", Reporter, 24);
            cache_get_value_name(i, "Reported", Reported, 24);
            cache_get_value_name(i, "Reason", Reason, 200);
            cache_get_value_name(i, "Date", Date, 30);
            cache_get_value_name_int(i, "ID", reportid);
            cache_get_value_name_int(i, "Accepted", Accepted);
            switch(Accepted)
            {
                case 0: format(rinfo, sizeof(rinfo), "{AFAFAF}[ID: %d]: {FFFFFF}%s has reported %s for the reason {AFAFAF}\'%s\'{FFFFFF} on %s - {AFAFAF}Not Checked
", reportid, Reporter, Reported, Reason, Date);
                case 1: format(rinfo, sizeof(rinfo), "{AFAFAF}[ID: %d]: {FFFFFF}%s has reported %s for the reason {AFAFAF}\'%s\'{FFFFFF} on %s - {00AA00}Accepted
", reportid, Reporter, Reported, Reason, Date);
                case 2: format(rinfo, sizeof(rinfo), "{AFAFAF}[ID: %d]: {FFFFFF}%s has reported %s for the reason {AFAFAF}\'%s\'{FFFFFF} on %s - {FF0000}Denied
", reportid, Reporter, Reported, Reason, Date);
            }
            strcat(string, rinfo);
        }
        Dialog_Show(playerid, DIALOG_REPORTS, DIALOG_STYLE_MSGBOX, "Latest 15 Reports", string, "Okay", "");
    }
    else
    {
        Dialog_Show(playerid, DIALOG_REPORTS, DIALOG_STYLE_MSGBOX, "No reports were found", "No reports were found on the MySQL database.", "Close", "");
    }

}
And WTF is with that strings
Code:
new string[2300], rinfo[1000]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)