SA-MP Forums Archive
[Help]: /reports command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help]: /reports command (/showthread.php?tid=445470)



[Help]: /reports command - Areax - 21.06.2013

Hello!

I have one question and that is, How to make the /reports command. I have searched, but I didn't find anything


This command will show a DIALOG_STYLE_MSGBOX dialog and the last 3 reports from my command /report...

/report
pawn Код:
CMD:report(playerid, params[])
{
    new hacker; new reason[50]; new string[200]; new str[200];
    if(sscanf(params, "us[50]", hacker, reason))return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /report {FF0000}[PlayerID] {FF0000}[Reason]");
    if(!IsPlayerConnected(hacker))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected!");
    format(string, sizeof(string), "[REPORT]: {800080}%s(ID:%d) {FFFFFF}has Reported {800080}%s(ID:%d) {FFFFFF}|| Reason: {800080}%s", GetName(playerid), playerid, GetName(hacker), hacker, reason);
    SendAdminMessage(COLOR_RED, string);
    format(str, sizeof(str), "[SYSTEM]: {FFFFFF}You have Reported {800080}%s(ID:%d) {FFFFFF}|| Reason: {800080}%s", GetName(hacker), hacker, reason);
    SendClientMessage(playerid, COLOR_GREEN, str);
    SendAdminGameText("~w~New ~g~Report!");
    return 1;
}
Thanks for HELP


Re: [Help]: /reports command - ScripteRNaBEEL - 21.06.2013

Try this bro

Код:
CMD:report(playerid,params[]) {
    new reported, tmp[128], tmp2[128], Index;		tmp = strtok(params,Index), tmp2 = strtok(params,Index);
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /report [playerid] [reason]");
	reported = strval(tmp);

 	if(IsPlayerConnected(reported) && reported != INVALID_PLAYER_ID) {
		if(PlayerInfo[reported][Level] == ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot report this administrator");
		if(playerid == reported) return SendClientMessage(playerid,red,"ERROR: You Cannot report yourself");
		if(strlen(params) > 7) {
			new reportedname[MAX_PLAYER_NAME], reporter[MAX_PLAYER_NAME], str[128], hour,minute,second; gettime(hour,minute,second);
			GetPlayerName(reported, reportedname, sizeof(reportedname));	GetPlayerName(playerid, reporter, sizeof(reporter));
			format(str, sizeof(str), "||NewReport||  %s(%d) reported %s(%d) Reason: %s |@%d:%d:%d|", reporter,playerid, reportedname, reported, params[strlen(tmp)+1], hour,minute,second);
			MessageToAdmins(COLOR_WHITE,str);
			SaveToFile("ReportLog",str);
			format(str, sizeof(str), "Report(%d:%d:%d): %s(%d) reported %s(%d) Reason: %s", hour,minute,second, reporter,playerid, reportedname, reported, params[strlen(tmp)+1]);
			for(new i = 1; i < MAX_REPORTS-1; i++) Reports[i] = Reports[i+1];
			Reports[MAX_REPORTS-1] = str;
			return SendClientMessage(playerid,yellow, "Your report has been sent to online administrators.");
		} else return SendClientMessage(playerid,red,"ERROR: Must be a valid reason");
	} else return SendClientMessage(playerid, red, "Player is not connected");
}



Re: [Help]: /reports command - Areax - 21.06.2013

I don't need the /report command.


Re: [Help]: /reports command - ScripteRNaBEEL - 21.06.2013

ok then what


Re: [Help]: /reports command - Areax - 21.06.2013

Quote:
Originally Posted by ScripteRNaBEEL
Посмотреть сообщение
ok then what
Read again..


Re: [Help]: /reports command - Goldilox - 21.06.2013

I will make it for you later today. You need file function to save the reports in a specific file in scripfiles. And then later you can open that file and get the first three lines.


Re: [Help]: /reports command - Kindred - 21.06.2013

Quote:
Originally Posted by Goldilox
Посмотреть сообщение
I will make it for you later today. You need file function to save the reports in a specific file in scripfiles. And then later you can open that file and get the first three lines.
Need
Verb

Require something because it's essential or very important.


Nope, it's not needed to save reports. This is an example, not sure if it will work. (Never done anything like this, not sure if this would work)

pawn Код:
#define MAX_REPORTS 3

enum ReportData
{
    Reason[128],
    ReportedID,
    InUse
}
new ReportInfo[MAX_REPORTS][ReportData];
new LastReport;

CMD:report(playerid, params[])
{
    new hacker; new reason[50]; new string[200]; new str[200];
    if(sscanf(params, "us[50]", hacker, reason))return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /report {FF0000}[PlayerID] {FF0000}[Reason]");
    if(!IsPlayerConnected(hacker))return SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected!");
    format(string, sizeof(string), "[REPORT]: {800080}%s(ID:%d) {FFFFFF}has Reported {800080}%s(ID:%d) {FFFFFF}|| Reason: {800080}%s", GetName(playerid), playerid, GetName(hacker), hacker, reason);
    SendAdminMessage(COLOR_RED, string);
    format(str, sizeof(str), "[SYSTEM]: {FFFFFF}You have Reported {800080}%s(ID:%d) {FFFFFF}|| Reason: {800080}%s", GetName(hacker), hacker, reason);
    SendClientMessage(playerid, COLOR_GREEN, str);
    SendAdminGameText("~w~New ~g~Report!");
    LastReport = GetAvailableReport();
    format(ReportInfo[GetAvailableReport();][Reason], 128, "%s", reason);
    ReportInfo[GetAvailableReport();][ReportedID] = hacker;
    ReportInfo[GetAvailableReport();][InUse] = 1;
    return 1;
}

CMD:reports(playerid, params[])
{
    if(AdminVariableHere[playerid] = AdminValue) //Change to your admin variable
    {
        new string[128], reports = 0;
        for(new i = 0; i < MAX_REPORTS; i++)
        {
            if(ReportInfo[i][InUse] == 1)
            {
                reports ++;
                format(string, sizeof(string), "%s\nReported: %s (%i) || Reason: %s", string, GetName(ReportInfo[i][ReportedID]), ReportInfo[i][ReportedID], ReportInfo[i][Reason]);
            }
        }
        if(reports == 0)
        {
            ShowPlayerDialog(playerid, DIALOG_REPORTS, DIALOG_STYLE_MSGBOX, "Reports", "There are no reports to show!", "Close", "");
        }
        else
        {
            ShowPlayerDialog(playerid, DIALOG_REPORTS, DIALOG_STYLE_MSGBOX, "Reports", string, "Close", "");
        }
    }
    return 1;
}

stock GetAvailableReport()
{
    for(new i = 0; i < MAX_REPORTS; i++)
    {
        if(ReportInfo[i][InUse] == 0)
        {
            return i;
        }
    }
    if(LastReport = 2) return 0;
    else return LastReport + 1;
}



Re: [Help]: /reports command - Areax - 22.06.2013

I get this errors:

pawn Код:
C:\Users\tadej\Desktop\SA-MP\gamemodes\TDM(1.0).pwn(129) : warning 211: possibly unintended assignment
C:\Users\tadej\Desktop\SA-MP\gamemodes\TDM(1.0).pwn(739) : error 001: expected token: "]", but found ";"
C:\Users\tadej\Desktop\SA-MP\gamemodes\TDM(1.0).pwn(739) : error 029: invalid expression, assumed zero
C:\Users\tadej\Desktop\SA-MP\gamemodes\TDM(1.0).pwn(739) : error 029: invalid expression, assumed zero
C:\Users\tadej\Desktop\SA-MP\gamemodes\TDM(1.0).pwn(739) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
On this lines:

pawn Код:
format(ReportInfo[GetAvailableReport();][Reason], 128, "%s", reason); // <------Line 739
pawn Код:
if(LastReport = 2) return 0; // <------Line 129