/report command help
#1

pawn Code:
CMD:report(playerid, params[])
{
    new text[128], giveplayerid;
    if(PlayerInfo[playerid][pAdmin] >= 2 && PlayerInfo[playerid][pAdmin] < 1338)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You can't submit reports as an administrator.");
        return 1;
    }
    if(JustReported[playerid] > 0)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "Wait 25 seconds before sending another report!");
        return 1;
    }

    if (sscanf(params, "rs", giveplayerid, text)) return SendClientMessage(playerid, COLOR_GRAD2, "Usage: /report [id] [reason]");
    JustReported[playerid]=25;
    SendReportToQue(playerid, text[128]);
    SendClientMessageEx(playerid, COLOR_YELLOW, "Your report was sent to Administrators.");
    return 1;
}
I get this error:
Code:
error 032: array index out of bounds (variable "text")
In this line:
pawn Code:
SendReportToQue(playerid, text[128]);
And this is the SendReportToQue:
pawn Code:
stock SendReportToQue(reportfrom, reportto, report[])
{
    new bool:breakingloop = false, newid = INVALID_REPORT_ID;

    for(new i=0;i<MAX_REPORTS;i++)
    {
        if(!breakingloop)
        {
            if(Reports[i][HasBeenUsed] == 0)
            {
                breakingloop = true;
                newid = i;
            }
        }
    }
    if(newid != INVALID_REPORT_ID)
    {
        strmid(Reports[newid][Report], report, 0, strlen(report), 128);
        Reports[newid][ReportFrom] = reportfrom;
        Reports[newid][ReportTo] = reportto;
        Reports[newid][HasBeenUsed] = 1;
        Reports[newid][BeingUsed] = 1;
        new string[128];
        format(string, sizeof(string), "%s [%i] reported %s (RID: %i): %s", GetPlayerNameEx(reportfrom), reportfrom, GetPlayerNameEx(reportto), reportto, newid, (report));
        ABroadCast(COLOR_REPORT,string,2);
    }
    else
    {
        ClearReports();
        SendReportToQue(reportfrom, reportto, report);
    }
    if(PlayerInfo[reportfrom][pDonateRank] == 4)
    {
        new string[128];
        format(string, sizeof(string), "~r~Priority Report: ~g~%d", newid);
        foreach(Player, i)
        {
            if(PlayerInfo[i][pAdmin] >= 2)
            {
                GameTextForPlayer(i, string, 1500, 1);
            }
        }
    }
}
Reply
#2

The parameters required are reportfrom, reportto, report. And where you use SendReportToQue(playerid, text); you don't need the "[128]".
Reply
#3

It should be:
pawn Code:
if (sscanf(params, "rs[128]", giveplayerid, text)) return SendClientMessage(playerid, COLOR_GRAD2, "Usage: /report [id] [reason]");
// Specifier "s" needs the size and it becomes: "s[size_here]".
And this function has 3 parameters and you have only 2 here. Change to:
pawn Code:
if( giveplayerid != INVALID_PLAYER_ID ) SendReportToQue(playerid, giveplayerid, text);
Reply
#4

Quote:
Originally Posted by Konstantinos
View Post
It should be:
pawn Code:
if (sscanf(params, "rs[128]", giveplayerid, text)) return SendClientMessage(playerid, COLOR_GRAD2, "Usage: /report [id] [reason]");
// Specifier "s" needs the size and it becomes: "s[size_here]".
And this function has 3 parameters and you have only 2 here. Change to:
pawn Code:
if( giveplayerid != INVALID_PLAYER_ID ) SendReportToQue(playerid, giveplayerid, text);
I get this error:
Code:
error 035: argument type mismatch (argument 2)
On this line:
pawn Code:
SendReportToQue(playerid, text);
EDIT: Worked, repped+
Reply
#5

Re-read what I said. SendReportToQue needs:
1) the player who report
2) the player who was reported
3) the report text

Check if the id a player typed is not invalid and replace, the playerid (the player who reported), the giveplayerid (the player who was reported by another player) and the text (report message).
pawn Code:
if( giveplayerid != INVALID_PLAYER_ID ) SendReportToQue(playerid, giveplayerid, text);
Reply
#6

You are missing parameters:
pawn Code:
SendReportToQue(playerid, text); // Only 2 parameters...
stock SendReportToQue(reportfrom, reportto, report[])  // You have 3 parameters here
You should use SendReportToQue(playerid, giveplayerid, text);
Edit: Late, late, late...
Reply
#7

Thank you, both repped+!
Reply
#8

Damn, now In-Game it doesn't appear the reason. It appears everything except it...
Reply
#9

Debug it:
pawn Code:
stock SendReportToQue(reportfrom, reportto, report[])
{
    printf("SendReportToQue(%d, %d, \"%s\")", reportfrom, reportto, report);
    // rest of the code
}
And make sure it is:
pawn Code:
if (sscanf(params, "rs[128]", giveplayerid, text)) return SendClientMessage(playerid, COLOR_GRAD2, "Usage: /report [id] [reason]");
// Specifier "s" needs the size and it becomes: "s[size_here]".
What does it print to the console?
Reply
#10

It prints what I typed but In-Game it doesn't say anything
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)