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

Introduction

This is an advanced dynamic report using the latest MySQL plugin [R41-4] which is controllable in-game, you are able to view reports, clear 15 latest reports from the database, accept reports, deny reports.

How to use it

Download or compile the script, paste it into your filterscripts folder, load it in server.cfg and start your server, simple right?

Commands

There are 5 commands, one of them is a player command and 4 others for administrators.
  • /report - Player Command (/report [id] [reason] - used to report someone)
  • /reports - Admin Command (used to view 15 latest reports available)
  • /clearreports - Admin Command (use this to clear 15 latest reports if the dialog displays 15/15)
  • /ar - Admin Command (used to accept a report from the ID, it will accept the report even if the player who reported is not online).
  • /dr - Admin Command (used to deny a report from the ID, it will deny the report even if the player who reported is not online).
Screenshots

Here\'s a list of screenshots I made:
https://imgur.com/a/NCDz3Dz

Credits
  • SA-MP Team - a_samp
  • BlueG / maddinat0r - a_mysql
  • Y_Less - sscanf2
  • Zeex - zcmd
  • Emmet - easyDialog
  • Kar - foreach
  • Logic_ - Updating / improving the filterscript
Download
GitHub
Pastebin


Bugs

There were no bugs while testing this, but if you find any instead of being mean report it and I\'ll fix it.
Reply
#2

How come nobody noticed this? Good job!
Reply
#3

There are a few mistakes in the code and some additions that are needed. However, I\'ll mention them in the PR.


Good work.


UPDATE (an hour later): I\'ve took the time out of my day and made a pull request.
Reply
#4

Quote:
Originally Posted by Logic_
View Post
There are a few mistakes in the code and some additions that are needed. However, I\'ll mention them in the PR.


Good work.


UPDATE (an hour later): I\'ve took the time out of my day and made a pull request.
Will accept your request once I get home, on my phone right now.
Reply
#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
#6

Quote:
Originally Posted by Dennis12
View Post
And WTF is with that strings
Code:
new string[2300], rinfo[1000]
You\'re right about what u said above, but you cant talk about string character lengths because when I used less string length, it didn\'t show all the reports.
Reply
#7

good job.
Reply
#8

What about the sql file?
Reply
#9

^ forgot to upload, will do that later on
Reply
#10

Quote:
Originally Posted by Dennis12
View Post
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 WTF is with that strings
Code:
new string[2300], rinfo[1000]
It\'s not forbidden using strings with a large array, some cases need those. Maybe the report being made takes lots of characters, willbedie is right.
Reply
#11

Quote:
Originally Posted by RogueDrifter
View Post
It\'s not forbidden using strings with a large array, some cases need those. Maybe the report being made takes lots of characters, willbedie is right.
Yeah, idk why people always complain about large arrays of strings..
Reply
#12

Still no sql?
Reply
#13

Quote:
Originally Posted by KinderClans
View Post
Still no sql?
Uploaded on GitHub.
Reply
#14

Good release, i like this. I\'m going to test your fs.
Reply
#15

thanks ^^
Reply
#16

why do you have to save the reports, this is such a useless thing, reports are supposed to reset every server restart, waste of lines and storage.
Reply
#17

Quote:
Originally Posted by ConnorW
View Post
why do you have to save the reports, this is such a useless thing, reports are supposed to reset every server restart, waste of lines and storage.
I know I\'m late to this reply but I wasn\'t around, and before judging read the whole thread. You can reset the reports any time you want using the commands listed. I find this system very useful for my own server, and I think people will enjoy it too. If you don\'t like it, just don\'t bullshit here. Next time, read the whole thread.
Reply
#18

Quote:
Originally Posted by Dennis12
View Post
And WTF is with that strings
Code:
new string[2300], rinfo[1000]
A large string array for a dynamic system isn\'t a issue.

The issue is when people use a 256 array for a 11 count string.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)