PDA

View Full Version : Report System - Need help


TheHonnor
12/07/2016, 09:31 AM
Hi yall!

Recently I begun a Report System which is based on reported player id.


I've made a command called "/res". This command is for admins only, and with this command you can solve a report.

My question is, if I can delete only one report with that command from the /Reports list

Photo:http://i.imgur.com/rejs1jb.png

Thanks in advance!!!

minijackc
12/07/2016, 09:56 AM
From what you're saying you want reports to have ASSIGNED ID's so you can delete them after they have been resolved?

Make a variable that stores Report ID's so everytime someone accepts a report it gets deleted.

TheHonnor
12/07/2016, 10:04 AM
This list is a string only. I was thinking if I can delete an report from that list.

minijackc
12/07/2016, 10:10 AM
Pretty sure its still possible, Maybe wait for someone more experienced to answer your question. Check other gamemodes or filterscripts to see if someone has something similar you can learn from

Jonesy96
12/07/2016, 10:22 AM
Hi,

Why not create an enum for the reports, and store the data for each one in an enum. This will make it a lot easier to track and delete a certain report.

EDIT: Assuning youve already done the above. Whichever the listitem is equal to, just reset the values of that iteration of the enum if that makes sense.

I.e. Reports[listitem][variables]

TheHonnor
12/07/2016, 10:37 AM
Well, I have already tried with enumerator. I used a variable to store the id for each report.
But actually, my problem is , that i don't know how to delete one item/report only from that list.

Jonesy96
12/07/2016, 01:14 PM
Well, I have already tried with enumerator. I used a variable to store the id for each report.
But actually, my problem is , that i don't know how to delete one item/report only from that list.

If you have all your reports in a enum with the ID stored, then that's perfect.

All you need to do is reset the enum:



new tmpReport[eReport] //'eReport' being the name of your enum clearly
Report[reportID] = tmpReport //this sets that specific enum instance to your enum defaults(so basically empties the enum at Report[reportID])



Then where your code is to format the string for the dialog, that you pass through ShowPlayerDialog. You'll need to do a for loop, to loop through each report and add to list, which I would imagine you're already doing for your dialog. Inside this for loop, just do an if statement to check the Report enum to see if the variables inside are set. If so, display in list, else break from the loop.


I don't know if any of that make sense, it's kind of hard to explain. If not, could you post your code please, and I can help you that way.

TheHonnor
12/07/2016, 02:57 PM
ENUMERATOR:
enum ReportData
{
Reported, Reporter, rReason[128], rText[256]
};

new Report[MAX_PLAYERS][ReportData];

CMD:reports
CMD:reports(playerid, params[])
{
if(PlayerInfo[playerid][Level] < 3) return SendError(playerid, "You need to be Admin Level 3 to use that command!");
//--------------------------------------------------------------------------
new ReportCounter = 0; Str[0] = '\0';
//--------------------------------------------------------------------------
for(new i = 1; i < MAX_REPORTS; i++) if(strcmp(Reports[i], "NoReports", true) != 0) ReportCounter++, format(Str, sizeof(Str), "%s\n{FFFFFF}%s", Str, Reports[i]);
//--------------------------------------------------------------------------
if(ReportCounter == 0) return SendClientMessage(playerid, Red, "There are no reports.");
else return ShowPlayerDialog(playerid, 123, DIALOG_STYLE_LIST, "{FF0000}Active reports {FFFFFF}- Use {FFD700}/res [id] [text] {FFFFFF}to solve the report!", Str, "Close", "");
}

CMD:res
CMD:res(playerid, params[])
{
new Player, Solve[128], LittleCounter[10]; Str[0] = '\0'; eString[0] = '\0';
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
if(PlayerInfo[playerid][Level] < 3) return SendError(playerid, "You are not authorized to use that command!");
if(sscanf(params, "us[128]", Player, Solve)) return SendUsage(playerid, "/Res [ID] [Method]");
if(Player == INVALID_PLAYER_ID) return SendError2(playerid, "Jucatorul cu acest ID nu este conectat!", "The player with this ID is not connected!");
if(Report[Player][Reporter] == -1) return SendError2(playerid, "Acest jucator nu a fost raportat niciun jucator.", "That player has been reported by no-one.");
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
format(Str, sizeof(Str), "{375FFF}Admin {15FF00}%s {375FFF}has solved report with id: {15FF00}%d#{375FFF}!", PlayerName(playerid), Player), SendMessageToAdmins(Str);
format(Str, sizeof(Str), "{FFFF00}Administrator %s has solved your report! (Method: %s)", PlayerName(playerid), Solve); SendClientMessage(Player, -1, Str);
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
format(LittleCounter, 10, "i", ServerInfo[ServerReports]); TextDrawSetString(ReportInfo[1], LittleCounter);
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
foreach(new i: Player) if(PlayerInfo[i][Level] >= 3)
{
if(ServerInfo[ServerReports] == 0) TextDrawHideForPlayer(i, ReportInfo[0]), TextDrawHideForPlayer(i, ReportInfo[1]);
else TextDrawShowForPlayer(i, ReportInfo[0]), TextDrawHideForPlayer(i, ReportInfo[1]);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
format(Report[Player][rText], 256, ""), format(Report[Player][rReason], 128, "");
Report[Player][Reported] = -1; Str[0] = '\0'; Report[Player][Reporter] = -1;
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
foreach(new i: Player) if(Report[i][Reporter] != -1) format(Str, sizeof(Str), "{00FF00}%d {FF8000}%s {FFFFFF}reported {FF0000}%s {FFFFFF}: %s", Report[i][Reported], PlayerName(Report[i][Reporter]), PlayerName(Report[i][Reported]), Report[i][rReason]);
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
for(new i = 1; i < MAX_REPORTS-1; i++) Reports[i] = Reports[i+1]; Reports[MAX_REPORTS-1] = Str;
//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++
ServerInfo[ServerReports]--; return 1;
}

I know that there are more loops but I was thinking that this method should work.

TheHonnor
12/07/2016, 05:25 PM
Thanks yall for your help. But, with a variable called „ReportedBy” and with some loops, I ve done this system successfully.

The commands that i left here, are available no more. I remade these commands.
Good luck !